summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/README48
-rw-r--r--t/helper/test-pkt-line.c23
-rw-r--r--t/lib-submodule-update.sh2
-rwxr-xr-xt/t0000-basic.sh55
-rwxr-xr-xt/t0001-init.sh13
-rwxr-xr-xt/t0070-fundamental.sh6
-rwxr-xr-xt/t0300-credentials.sh26
-rwxr-xr-xt/t1400-update-ref.sh10
-rwxr-xr-xt/t2016-checkout-patch.sh11
-rwxr-xr-xt/t2024-checkout-dwim.sh11
-rwxr-xr-xt/t2060-switch.sh5
-rwxr-xr-xt/t2071-restore-patch.sh8
-rwxr-xr-xt/t2200-add-update.sh3
-rwxr-xr-xt/t2402-worktree-list.sh10
-rwxr-xr-xt/t3200-branch.sh16
-rwxr-xr-xt/t3201-branch-contains.sh8
-rwxr-xr-xt/t3203-branch-output.sh4
-rwxr-xr-xt/t3205-branch-color.sh8
-rwxr-xr-xt/t3435-rebase-gpg-sign.sh56
-rwxr-xr-xt/t3436-rebase-more-options.sh4
-rwxr-xr-xt/t4013-diff-various.sh41
-rw-r--r--t/t4013/diff.log_-IA_-IB_-I1_-I2_-p_master99
-rwxr-xr-xt/t4018-diff-funcname.sh1
-rw-r--r--t/t4018/bash-arithmetic-function4
-rw-r--r--t/t4018/bash-bashism-style-compact6
-rw-r--r--t/t4018/bash-bashism-style-function4
-rw-r--r--t/t4018/bash-bashism-style-whitespace4
-rw-r--r--t/t4018/bash-conditional-function4
-rw-r--r--t/t4018/bash-missing-parentheses6
-rw-r--r--t/t4018/bash-mixed-style-compact4
-rw-r--r--t/t4018/bash-mixed-style-function4
-rw-r--r--t/t4018/bash-nested-functions6
-rw-r--r--t/t4018/bash-other-characters4
-rw-r--r--t/t4018/bash-posix-style-compact4
-rw-r--r--t/t4018/bash-posix-style-function4
-rw-r--r--t/t4018/bash-posix-style-whitespace4
-rw-r--r--t/t4018/bash-subshell-function4
-rw-r--r--t/t4018/bash-trailing-comment4
-rw-r--r--t/t4018/css-attribute-value-selector4
-rw-r--r--t/t4018/css-block-level-@-statements10
-rw-r--r--t/t4018/css-class-selector4
-rw-r--r--t/t4018/css-id-selector4
-rw-r--r--t/t4018/css-root-selector4
-rw-r--r--t/t4018/php-abstract-method7
-rw-r--r--t/t4018/php-final-method7
-rw-r--r--t/t4018/rust-macro-rules6
-rwxr-xr-xt/t4068-diff-symmetric-merge-base.sh193
-rwxr-xr-xt/t4068-diff-symmetric.sh91
-rwxr-xr-xt/t4114-apply-typechange.sh7
-rwxr-xr-xt/t4127-apply-same-fn.sh9
-rwxr-xr-xt/t5319-multi-pack-index.sh15
-rwxr-xr-xt/t5324-split-commit-graph.sh13
-rwxr-xr-xt/t5505-remote.sh43
-rwxr-xr-xt/t5510-fetch.sh8
-rwxr-xr-xt/t5526-fetch-submodules.sh70
-rwxr-xr-xt/t5533-push-cas.sh137
-rwxr-xr-xt/t5606-clone-options.sh71
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh6
-rwxr-xr-xt/t6006-rev-list-format.sh2
-rwxr-xr-xt/t6012-rev-list-simplify.sh2
-rwxr-xr-xt/t6200-fmt-merge-msg.sh2
-rwxr-xr-xt/t6302-for-each-ref-filter.sh24
-rwxr-xr-xt/t6423-merge-rename-directories.sh592
-rwxr-xr-xt/t7006-pager.sh84
-rwxr-xr-xt/t7101-reset-empty-subdirs.sh66
-rwxr-xr-xt/t7102-reset.sh307
-rwxr-xr-xt/t7201-co.sh102
-rwxr-xr-xt/t7518-ident-corner-cases.sh2
-rwxr-xr-xt/t7900-maintenance.sh222
-rwxr-xr-xt/t9304-fast-import-marks.sh51
-rwxr-xr-xt/t9801-git-p4-branch.sh12
-rwxr-xr-xt/t9832-unshelve.sh3
-rwxr-xr-xt/t9902-completion.sh58
-rw-r--r--t/test-lib-functions.sh16
-rw-r--r--t/test-lib.sh28
75 files changed, 2193 insertions, 623 deletions
diff --git a/t/README b/t/README
index 2adaf7c2d2..c730a70770 100644
--- a/t/README
+++ b/t/README
@@ -258,16 +258,21 @@ For an individual test suite --run could be used to specify that
only some tests should be run or that some tests should be
excluded from a run.
-The argument for --run is a list of individual test numbers or
-ranges with an optional negation prefix that define what tests in
-a test suite to include in the run. A range is two numbers
-separated with a dash and matches a range of tests with both ends
-been included. You may omit the first or the second number to
-mean "from the first test" or "up to the very last test"
-respectively.
-
-Optional prefix of '!' means that the test or a range of tests
-should be excluded from the run.
+The argument for --run, <test-selector>, is a list of description
+substrings or globs or individual test numbers or ranges with an
+optional negation prefix (of '!') that define what tests in a test
+suite to include (or exclude, if negated) in the run. A range is two
+numbers separated with a dash and matches a range of tests with both
+ends been included. You may omit the first or the second number to
+mean "from the first test" or "up to the very last test" respectively.
+
+The argument to --run is split on commas into separate strings,
+numbers, and ranges, and picks all tests that match any of the
+individual selection criteria. If the substring of the description
+text that you want to match includes a comma, use the glob character
+'?' instead. For example --run='rebase,merge?cherry-pick' would match
+on all tests that match either the glob *rebase* or the glob
+*merge?cherry-pick*.
If --run starts with an unprefixed number or range the initial
set of tests to run is empty. If the first item starts with '!'
@@ -275,9 +280,6 @@ all the tests are added to the initial set. After initial set is
determined every test number or range is added or excluded from
the set one by one, from left to right.
-Individual numbers or ranges could be separated either by a space
-or a comma.
-
For example, to run only tests up to a specific test (21), one
could do this:
@@ -290,7 +292,7 @@ or this:
Common case is to run several setup tests (1, 2, 3) and then a
specific test (21) that relies on that setup:
- $ sh ./t9200-git-cvsexport-commit.sh --run='1 2 3 21'
+ $ sh ./t9200-git-cvsexport-commit.sh --run='1,2,3,21'
or:
@@ -298,17 +300,17 @@ or:
or:
- $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21'
+ $ sh ./t9200-git-cvsexport-commit.sh --run='-3,21'
As noted above, the test set is built by going through the items
from left to right, so this:
- $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3'
+ $ sh ./t9200-git-cvsexport-commit.sh --run='1-4,!3'
will run tests 1, 2, and 4. Items that come later have higher
precedence. It means that this:
- $ sh ./t9200-git-cvsexport-commit.sh --run='!3 1-4'
+ $ sh ./t9200-git-cvsexport-commit.sh --run='!3,1-4'
would just run tests from 1 to 4, including 3.
@@ -317,6 +319,18 @@ test in the test suite except from 7 up to 11:
$ sh ./t9200-git-cvsexport-commit.sh --run='!7-11'
+Sometimes there may be multiple tests with e.g. "setup" in their name
+that are needed and rather than figuring out the number for all of them
+we can just use "setup" as a substring/glob to match against the test
+description:
+
+ $ sh ./t0050-filesystem.sh --run=setup,9-11
+
+or one could select both the setup tests and the rename ones (assuming all
+relevant tests had those words in their descriptions):
+
+ $ sh ./t0050-filesystem.sh --run=setup,rename
+
Some tests in a test suite rely on the previous tests performing
certain actions, specifically some tests are designated as
"setup" test, so you cannot _arbitrarily_ disable one test and
diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c
index 69152958e5..5e638f0b97 100644
--- a/t/helper/test-pkt-line.c
+++ b/t/helper/test-pkt-line.c
@@ -84,6 +84,25 @@ static void unpack_sideband(void)
}
}
+static int send_split_sideband(void)
+{
+ const char *part1 = "Hello,";
+ const char *primary = "\001primary: regular output\n";
+ const char *part2 = " world!\n";
+
+ send_sideband(1, 2, part1, strlen(part1), LARGE_PACKET_MAX);
+ packet_write(1, primary, strlen(primary));
+ send_sideband(1, 2, part2, strlen(part2), LARGE_PACKET_MAX);
+ packet_response_end(1);
+
+ return 0;
+}
+
+static int receive_sideband(void)
+{
+ return recv_sideband("sideband", 0, 1);
+}
+
int cmd__pkt_line(int argc, const char **argv)
{
if (argc < 2)
@@ -95,6 +114,10 @@ int cmd__pkt_line(int argc, const char **argv)
unpack();
else if (!strcmp(argv[1], "unpack-sideband"))
unpack_sideband();
+ else if (!strcmp(argv[1], "send-split-sideband"))
+ send_split_sideband();
+ else if (!strcmp(argv[1], "receive-sideband"))
+ receive_sideband();
else
die("invalid argument '%s'", argv[1]);
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 87a759149f..bd3fa3c6da 100644
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -144,7 +144,7 @@ create_lib_submodule_repo () {
git checkout -b valid_sub1 &&
git revert HEAD &&
- git checkout master
+ git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}"
)
}
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 923281af93..22489c24dc 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -430,7 +430,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
test_expect_success '--run basic' "
run_sub_test_lib_test run-basic \
- '--run basic' --run='1 3 5' <<-\\EOF &&
+ '--run basic' --run='1,3,5' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -472,7 +472,7 @@ test_expect_success '--run with a range' "
test_expect_success '--run with two ranges' "
run_sub_test_lib_test run-two-ranges \
- '--run with two ranges' --run='1-2 5-6' <<-\\EOF &&
+ '--run with two ranges' --run='1-2,5-6' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -556,7 +556,7 @@ test_expect_success '--run with basic negation' "
test_expect_success '--run with two negations' "
run_sub_test_lib_test run-two-neg \
- '--run with two negations' --run='"'!3 !6'"' <<-\\EOF &&
+ '--run with two negations' --run='"'!3,!6'"' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -577,7 +577,7 @@ test_expect_success '--run with two negations' "
test_expect_success '--run a range and negation' "
run_sub_test_lib_test run-range-and-neg \
- '--run a range and negation' --run='"'-4 !2'"' <<-\\EOF &&
+ '--run a range and negation' --run='"'-4,!2'"' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -620,7 +620,7 @@ test_expect_success '--run range negation' "
test_expect_success '--run include, exclude and include' "
run_sub_test_lib_test run-inc-neg-inc \
'--run include, exclude and include' \
- --run='"'1-5 !1-3 2'"' <<-\\EOF &&
+ --run='"'1-5,!1-3,2'"' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -664,7 +664,7 @@ test_expect_success '--run include, exclude and include, comma separated' "
test_expect_success '--run exclude and include' "
run_sub_test_lib_test run-neg-inc \
'--run exclude and include' \
- --run='"'!3- 5'"' <<-\\EOF &&
+ --run='"'!3-,5'"' <<-\\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
@@ -705,7 +705,31 @@ test_expect_success '--run empty selectors' "
EOF
"
-test_expect_success '--run invalid range start' "
+test_expect_success '--run substring selector' "
+ run_sub_test_lib_test run-substring-selector \
+ '--run empty selectors' \
+ --run='relevant' <<-\\EOF &&
+ test_expect_success \"relevant test\" 'true'
+ for i in 1 2 3 4 5 6
+ do
+ test_expect_success \"other test #\$i\" 'true'
+ done
+ test_done
+ EOF
+ check_sub_test_lib_test run-substring-selector <<-\\EOF
+ > ok 1 - relevant test
+ > ok 2 # skip other test #1 (--run)
+ > ok 3 # skip other test #2 (--run)
+ > ok 4 # skip other test #3 (--run)
+ > ok 5 # skip other test #4 (--run)
+ > ok 6 # skip other test #5 (--run)
+ > ok 7 # skip other test #6 (--run)
+ > # passed all 7 test(s)
+ > 1..7
+ EOF
+"
+
+test_expect_success '--run keyword selection' "
run_sub_test_lib_test_err run-inv-range-start \
'--run invalid range start' \
--run='a-5' <<-\\EOF &&
@@ -735,21 +759,6 @@ test_expect_success '--run invalid range end' "
EOF_ERR
"
-test_expect_success '--run invalid selector' "
- run_sub_test_lib_test_err run-inv-selector \
- '--run invalid selector' \
- --run='1?' <<-\\EOF &&
- test_expect_success \"passing test #1\" 'true'
- test_done
- EOF
- check_sub_test_lib_test_err run-inv-selector \
- <<-\\EOF_OUT 3<<-\\EOF_ERR
- > FATAL: Unexpected exit with code 1
- EOF_OUT
- > error: --run: invalid non-numeric in test selector: '1?'
- EOF_ERR
-"
-
test_set_prereq HAVEIT
haveit=no
@@ -1191,7 +1200,7 @@ test_expect_success 'writing this tree with --missing-ok' '
test_expect_success 'git read-tree followed by write-tree should be idempotent' '
rm -f .git/index &&
git read-tree $tree &&
- test -f .git/index &&
+ test_path_is_file .git/index &&
newtree=$(git write-tree) &&
test "$newtree" = "$tree"
'
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 2f7c3dcd0f..69a320489f 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -553,14 +553,21 @@ test_expect_success '--initial-branch' '
test_expect_success 'overridden default initial branch name (config)' '
test_config_global init.defaultBranch nmb &&
- git init initial-branch-config &&
+ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git init initial-branch-config &&
git -C initial-branch-config symbolic-ref HEAD >actual &&
grep nmb actual
'
+test_expect_success 'overridden default main branch name (env)' '
+ test_config_global init.defaultBranch nmb &&
+ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=env git init main-branch-env &&
+ git -C main-branch-env symbolic-ref HEAD >actual &&
+ grep env actual
+'
+
test_expect_success 'invalid default branch name' '
- test_config_global init.defaultBranch "with space" &&
- test_must_fail git init initial-branch-invalid 2>err &&
+ test_must_fail env GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME="with space" \
+ git init initial-branch-invalid 2>err &&
test_i18ngrep "invalid branch name" err
'
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 7b111a56fd..357201640a 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -34,4 +34,10 @@ test_expect_success 'check for a bug in the regex routines' '
test-tool regex --bug
'
+test_expect_success 'incomplete sideband messages are reassembled' '
+ test-tool pkt-line send-split-sideband >split-sideband &&
+ test-tool pkt-line receive-sideband <split-sideband 2>err &&
+ grep "Hello, world" err
+'
+
test_done
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index bc2d74098f..a18f8a473b 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -265,6 +265,32 @@ test_expect_success 'internal getpass does not ask for known username' '
EOF
'
+test_expect_success 'git-credential respects core.askPass' '
+ write_script alternate-askpass <<-\EOF &&
+ echo >&2 "alternate askpass invoked"
+ echo alternate-value
+ EOF
+ test_config core.askpass "$PWD/alternate-askpass" &&
+ (
+ # unset GIT_ASKPASS set by lib-credential.sh which would
+ # override our config, but do so in a subshell so that we do
+ # not interfere with other tests
+ sane_unset GIT_ASKPASS &&
+ check fill <<-\EOF
+ protocol=http
+ host=example.com
+ --
+ protocol=http
+ host=example.com
+ username=alternate-value
+ password=alternate-value
+ --
+ alternate askpass invoked
+ alternate askpass invoked
+ EOF
+ )
+'
+
HELPER="!f() {
cat >/dev/null
echo username=foo
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 770e7be363..4c01e08551 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -585,10 +585,10 @@ test_expect_success 'stdin fails on unbalanced quotes' '
grep "fatal: badly quoted argument: \\\"master" err
'
-test_expect_success 'stdin fails on invalid escape' '
- echo "create $a \"ma\zter\"" >stdin &&
+test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' '
+ echo "create $a \"ma\zn\"" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
+ grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err
'
test_expect_success 'stdin fails on junk after quoted argument' '
@@ -704,9 +704,9 @@ test_expect_success 'stdin succeeds with quoted argument' '
test_cmp expect actual
'
-test_expect_success 'stdin succeeds with escaped character' '
+test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin succeeds with escaped character' '
git update-ref -d $a &&
- echo "create $a \"ma\\163ter\"" >stdin &&
+ echo "create $a \"ma\\151n\"" >stdin &&
git update-ref --stdin <stdin &&
git rev-parse $m >expect &&
git rev-parse $a >actual &&
diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh
index 47aeb0b167..d91a329eb3 100755
--- a/t/t2016-checkout-patch.sh
+++ b/t/t2016-checkout-patch.sh
@@ -18,6 +18,10 @@ test_expect_success PERL 'setup' '
# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
+# NEEDSWORK: Since the builtin add-p is used when $GIT_TEST_ADD_I_USE_BUILTIN
+# is given, we should replace the PERL prerequisite with an ADD_I prerequisite
+# which first checks if $GIT_TEST_ADD_I_USE_BUILTIN is defined before checking
+# PERL.
test_expect_success PERL 'saying "n" does nothing' '
set_and_save_state dir/foo work head &&
test_write_lines n n | git checkout -p &&
@@ -59,6 +63,13 @@ test_expect_success PERL 'git checkout -p HEAD with change already staged' '
verify_state dir/foo head head
'
+test_expect_success PERL 'git checkout -p HEAD^...' '
+ # the third n is to get out in case it mistakenly does not apply
+ test_write_lines n y n | git checkout -p HEAD^... &&