From: Junio C Hamano Date: Thu, 26 Mar 2015 18:57:13 +0000 (-0700) Subject: Merge branch 'jk/test-chain-lint' X-Git-Tag: v2.4.0-rc0~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/30db51a3fec68bfa5a59b9b3886162f536e37320?ds=inline;hp=-c Merge branch 'jk/test-chain-lint' People often forget to chain the commands in their test together with &&, leaving a failure from an earlier command in the test go unnoticed. The new GIT_TEST_CHAIN_LINT mechanism allows you to catch such a mistake more easily. * jk/test-chain-lint: (36 commits) t9001: drop save_confirm helper t0020: use test_* helpers instead of hand-rolled messages t: simplify loop exit-code status variables t: fix some trivial cases of ignored exit codes in loops t7701: fix ignored exit code inside loop t3305: fix ignored exit code inside loop t0020: fix ignored exit code inside loops perf-lib: fix ignored exit code inside loop t6039: fix broken && chain t9158, t9161: fix broken &&-chain in git-svn tests t9104: fix test for following larger parents t4104: drop hand-rolled error reporting t0005: fix broken &&-chains t7004: fix embedded single-quotes t0050: appease --chain-lint t9001: use test_when_finished t4117: use modern test_* helpers t6034: use modern test_* helpers t1301: use modern test_* helpers t0020: use modern test_* helpers ... --- 30db51a3fec68bfa5a59b9b3886162f536e37320 diff --combined t/t1700-split-index.sh index 92f7298fba,a55f5bc0a1..193d55c3f4 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@@ -10,18 -10,9 +10,18 @@@ sane_unset GIT_TEST_SPLIT_INDE test_expect_success 'enable split index' ' git update-index --split-index && test-dump-split-index .git/index >actual && + indexversion=$(test-index-version <.git/index) && + if test "$indexversion" = "4" + then + own=432ef4b63f32193984f339431fd50ca796493569 + base=508851a7f0dfa8691e9f69c7f055865389012491 + else + own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339 + base=39d890139ee5356c7ef572216cebcd27aa41f9df + fi && cat >expect <actual && cat >expect <actual && cat >expect <output + COLUMNS=200 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb COLUMNS (big change)" ' - COLUMNS=200 git $cmd $args --graph >output + COLUMNS=200 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@@ -122,15 -122,15 +122,15 @@@ EO while read verb expect cmd args do test_expect_success "$cmd $verb not enough COLUMNS (big change)" ' - COLUMNS=40 git $cmd $args >output + COLUMNS=40 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" ' - COLUMNS=40 git $cmd $args --graph >output + COLUMNS=40 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@@ -150,15 -150,15 +150,15 @@@ EO while read verb expect cmd args do test_expect_success "$cmd $verb statGraphWidth config" ' - git -c diff.statGraphWidth=26 $cmd $args >output + git -c diff.statGraphWidth=26 $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb statGraphWidth config" ' - git -c diff.statGraphWidth=26 $cmd $args --graph >output + git -c diff.statGraphWidth=26 $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@@ -179,33 -179,33 +179,33 @@@ EO while read cmd args do test_expect_success "$cmd --stat=width with big change" ' - git $cmd $args --stat=40 >output + git $cmd $args --stat=40 >output && grep " | " output >actual && test_cmp expect actual ' test_expect_success "$cmd --stat-width=width with big change" ' - git $cmd $args --stat-width=40 >output + git $cmd $args --stat-width=40 >output && grep " | " output >actual && test_cmp expect actual ' test_expect_success "$cmd --stat-graph-width with big change" ' - git $cmd $args --stat-graph-width=26 >output + git $cmd $args --stat-graph-width=26 >output && grep " | " output >actual && test_cmp expect actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --stat-width=width --graph with big change" ' - git $cmd $args --stat-width=40 --graph >output + git $cmd $args --stat-width=40 --graph >output && grep " | " output >actual && test_cmp expect-graph actual ' test_expect_success "$cmd --stat-graph-width --graph with big change" ' - git $cmd $args --stat-graph-width=26 --graph >output + git $cmd $args --stat-graph-width=26 --graph >output && grep " | " output >actual && test_cmp expect-graph actual ' @@@ -236,7 -236,7 +236,7 @@@ d test_cmp expect actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --stat=width --graph with big change is balanced" ' git $cmd $args --stat-width=60 --graph >output && @@@ -265,15 -265,15 +265,15 @@@ EO while read verb expect cmd args do test_expect_success "$cmd $verb COLUMNS (long filename)" ' - COLUMNS=200 git $cmd $args >output + COLUMNS=200 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb COLUMNS (long filename)" ' - COLUMNS=200 git $cmd $args --graph >output + COLUMNS=200 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@@ -294,16 -294,16 +294,16 @@@ while read verb expect cmd arg do test_expect_success COLUMNS_CAN_BE_1 \ "$cmd $verb prefix greater than COLUMNS (big change)" ' - COLUMNS=1 git $cmd $args >output + COLUMNS=1 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success COLUMNS_CAN_BE_1 \ "$cmd --graph $verb prefix greater than COLUMNS (big change)" ' - COLUMNS=1 git $cmd $args --graph >output + COLUMNS=1 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@@ -320,7 -320,7 +320,7 @@@ EO test_expect_success 'merge --stat respects COLUMNS (big change)' ' git checkout -b branch HEAD^^ && COLUMNS=100 git merge --stat --no-ff master^ >output && - grep " | " output >actual + grep " | " output >actual && test_cmp expect actual ' @@@ -329,7 -329,7 +329,7 @@@ cat >expect <<'EOF EOF test_expect_success 'merge --stat respects COLUMNS (long filename)' ' COLUMNS=100 git merge --stat --no-ff master >output && - grep " | " output >actual + grep " | " output >actual && test_cmp expect actual ' diff --combined t/t4202-log.sh index f111705e70,85230a87b4..1b2e981a00 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@@ -113,11 -113,7 +113,7 @@@ test_expect_success 'diff-filter=M' actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && expect=$(echo second) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@@ -125,11 -121,7 +121,7 @@@ test_expect_success 'diff-filter=D' actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && expect=$(echo sixth ; echo third) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@@ -137,11 -129,7 +129,7 @@@ test_expect_success 'diff-filter=R' actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && expect=$(echo third) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@@ -149,11 -137,7 +137,7 @@@ test_expect_success 'diff-filter=C' actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && expect=$(echo fourth) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@@ -161,11 -145,7 +145,7 @@@ test_expect_success 'git log --follow' actual=$(git log --follow --pretty="format:%s" ichi) && expect=$(echo third ; echo second ; echo initial) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@@ -481,7 -461,7 +461,7 @@@ test_expect_success 'log.decorate confi git log --oneline --no-decorate >actual && test_cmp expect.none actual && git log --oneline --decorate >actual && - test_cmp expect.short actual + test_cmp expect.short actual && test_unconfig log.decorate && git log --pretty=raw >expect.raw && @@@ -887,8 -867,4 +867,8 @@@ test_expect_success GPG 'log --graph -- grep "^| | gpg: Good signature" actual ' +test_expect_success 'log --graph --no-walk is forbidden' ' + test_must_fail git log --graph --no-walk +' + test_done diff --combined t/t5541-http-push-smart.sh index 1ecb5881ac,47cee537c7..9cf27e8c99 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@@ -158,7 -158,7 +158,7 @@@ test_http_push_nonff "$HTTPD_DOCUMENT_R test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' ' # create a dissimilarly-named remote ref so that git is unable to match the # two refs (viz. local, remote) unless an explicit refspec is provided. - git push origin master:retsam + git push origin master:retsam && echo "change changed" > path2 && git commit -a -m path2 --amend && @@@ -324,6 -324,12 +324,6 @@@ test_expect_success 'push into half-aut test_cmp expect actual ' -run_with_limited_cmdline () { - (ulimit -s 128 && "$@") -} - -test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true' - test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' ' sha1=$(git rev-parse HEAD) && test_seq 2000 | diff --combined t/t5551-http-fetch-smart.sh index df47851752,cf0a6ea538..66439e58fc --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@@ -83,7 -83,7 +83,7 @@@ test_expect_success 'clone http reposit test_expect_success 'fetch changes via http' ' echo content >>file && git commit -a -m two && - git push public + git push public && (cd clone && git pull) && test_cmp file clone/file ' @@@ -169,7 -169,7 +169,7 @@@ test_expect_success 'GIT_SMART_HTTP ca ' test_expect_success 'invalid Content-Type rejected' ' - test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual + test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual && grep "not valid:" actual ' @@@ -209,25 -209,14 +209,25 @@@ test_expect_success 'cookies stored in git config http.cookiefile cookies.txt && git config http.savecookies true && git ls-remote $HTTPD_URL/smart_cookies/repo.git master && - tail -3 cookies.txt > cookies_tail.txt + tail -3 cookies.txt >cookies_tail.txt && test_cmp expect_cookies.txt cookies_tail.txt ' -test_expect_success EXPENSIVE 'create 50,000 tags in the repo' ' +test_expect_success 'transfer.hiderefs works over smart-http' ' + test_commit hidden && + test_commit visible && + git push public HEAD^:refs/heads/a HEAD:refs/heads/b && + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ + config transfer.hiderefs refs/heads/a && + git clone --bare "$HTTPD_URL/smart/repo.git" hidden.git && + test_must_fail git -C hidden.git rev-parse --verify a && + git -C hidden.git rev-parse --verify b +' + +test_expect_success 'create 2,000 tags in the repo' ' ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - for i in `test_seq 50000` + for i in $(test_seq 2000) do echo "commit refs/heads/too-many-refs" echo "mark :$i" @@@ -248,22 -237,13 +248,22 @@@ ) ' -test_expect_success EXPENSIVE 'clone the 50,000 tag repo to check OS command line overflow' ' - git clone $HTTPD_URL/smart/repo.git too-many-refs && +test_expect_success CMDLINE_LIMIT \ + 'clone the 2,000 tag repo to check OS command line overflow' ' + run_with_limited_cmdline git clone $HTTPD_URL/smart/repo.git too-many-refs && ( cd too-many-refs && - test $(git for-each-ref refs/tags | wc -l) = 50000 + git for-each-ref refs/tags >actual && + test_line_count = 2000 actual ) ' +test_expect_success 'large fetch-pack requests can be split across POSTs' ' + GIT_CURL_VERBOSE=1 git -c http.postbuffer=65536 \ + clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err && + grep "^> POST" err >posts && + test_line_count = 2 posts +' + stop_httpd test_done diff --combined t/t6000-rev-list-misc.sh index 1f58b46e1f,7911ed9af6..3e752ce032 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@@ -42,7 -42,7 +42,7 @@@ test_expect_success 'rev-list --object test_tick && git commit -m that && - ONE=$(git rev-parse HEAD:one) + ONE=$(git rev-parse HEAD:one) && git rev-list --objects HEAD two >output && grep "$ONE two/three" output && ! grep one output @@@ -85,7 -85,7 +85,7 @@@ test_expect_success 'rev-list can show # - we do not show the root tree; since we updated the index, it # does not have a valid cache tree # - cat >expect <<-\EOF + cat >expect <<-\EOF && 8e4020bb5a8d8c873b25de15933e75cc0fc275df one d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index 9200b628cf9dc883a85a7abc8d6e6730baee589c two @@@ -96,8 -96,4 +96,8 @@@ test_cmp expect actual ' +test_expect_success '--bisect and --first-parent can not be combined' ' + test_must_fail git rev-list --bisect --first-parent HEAD +' + test_done diff --combined t/t7004-tag.sh index 8bfeef9b0b,efb08c3496..fa207f3b8c --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@@ -1180,8 -1180,8 +1180,8 @@@ test_expect_success 'message in editor test_expect_success \ 'message in editor has initial comment: remainder' ' # remove commented lines from the remainder -- should be empty - >rest.expect - sed -e 1d -e '/^#/d' rest.actual && + >rest.expect && + sed -e 1d -e "/^#/d" rest.actual && test_cmp rest.expect rest.actual ' @@@ -1459,34 -1459,6 +1459,34 @@@ test_expect_success 'invalid sort param test_cmp expect actual ' +test_expect_success 'version sort with prerelease reordering' ' + git config --unset tag.sort && + git config versionsort.prereleaseSuffix -rc && + git tag foo1.6-rc1 && + git tag foo1.6-rc2 && + git tag -l --sort=version:refname "foo*" >actual && + cat >expect <<-\EOF && + foo1.3 + foo1.6-rc1 + foo1.6-rc2 + foo1.6 + foo1.10 + EOF + test_cmp expect actual +' + +test_expect_success 'reverse version sort with prerelease reordering' ' + git tag -l --sort=-version:refname "foo*" >actual && + cat >expect <<-\EOF && + foo1.10 + foo1.6 + foo1.6-rc2 + foo1.6-rc1 + foo1.3 + EOF + test_cmp expect actual +' + run_with_limited_stack () { (ulimit -s 128 && "$@") } diff --combined t/t7510-signed-commit.sh index 3cef18cfda,fc1ff45283..13331e533b --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@@ -42,7 -42,7 +42,7 @@@ test_expect_success GPG 'create signed git tag seventh-unsigned && test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ && - git tag seventh-signed + git tag seventh-signed && echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 && git tag eighth-signed-alt @@@ -86,8 -86,8 +86,8 @@@ test_expect_success GPG 'show signed co git show -s --show-signature initial >show && git verify-commit -v initial >verify.1 2>verify.2 && git cat-file commit initial >cat && - grep -v "gpg: " show >show.commit && - grep "gpg: " show >show.gpg && + grep -v -e "gpg: " -e "Warning: " show >show.commit && + grep -e "gpg: " -e "Warning: " show >show.gpg && grep -v "^ " cat | grep -v "^gpgsig " >cat.commit && test_cmp show.commit commit && test_cmp show.gpg verify.2 && diff --combined t/t9903-bash-prompt.sh index 46d7d37a51,0c6acddc1b..49d58e6726 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@@ -166,7 -166,7 +166,7 @@@ test_expect_success 'prompt - inside ba ' test_expect_success 'prompt - interactive rebase' ' - printf " (b1|REBASE-i 2/3)" >expected + printf " (b1|REBASE-i 2/3)" >expected && write_script fake_editor.sh <<-\EOF && echo "exec echo" >"$1" echo "edit $(git log -1 --format="%h")" >>"$1" @@@ -397,17 -397,6 +397,17 @@@ test_expect_success 'prompt - untracke test_cmp expected "$actual" ' +test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' ' + printf " (master %%)" >expected && + ( + mkdir -p ignored_dir && + cd ignored_dir && + GIT_PS1_SHOWUNTRACKEDFILES=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' ' printf " (master)" >expected && test_config bash.showUntrackedFiles false && diff --combined t/test-lib.sh index 9914d3e1cf,50b3d3f45d..4ea99a209d --- a/t/test-lib.sh +++ b/t/test-lib.sh @@@ -152,7 -152,10 +152,7 @@@ unset UNZI case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in 1|2|true) - echo "* warning: Some tests will not work if GIT_TRACE" \ - "is set as to trace on STDERR ! *" - echo "* warning: Please set GIT_TRACE to something" \ - "other than 1, 2 or true ! *" + GIT_TRACE=4 ;; esac @@@ -229,6 -232,12 +229,12 @@@ d --root=*) root=$(expr "z$1" : 'z[^=]*=\(.*\)') shift ;; + --chain-lint) + GIT_TEST_CHAIN_LINT=1 + shift ;; + --no-chain-lint) + GIT_TEST_CHAIN_LINT=0 + shift ;; -x) trace=t verbose=t @@@ -296,7 -305,6 +302,7 @@@ die () GIT_EXIT_OK= trap 'die' EXIT +trap 'exit $?' INT # The user-facing functions are loaded from a separate file so that # test_perf subshells can have them too @@@ -522,6 -530,16 +528,16 @@@ test_eval_ () test_run_ () { test_cleanup=: expecting_failure=$2 + + if test "${GIT_TEST_CHAIN_LINT:-0}" != 0; then + # 117 is magic because it is unlikely to match the exit + # code of other programs + test_eval_ "(exit 117) && $1" + if test "$?" != 117; then + error "bug in the test script: broken &&-chain: $1" + fi + fi + setup_malloc_check test_eval_ "$1" eval_ret=$? @@@ -1062,9 -1080,3 +1078,9 @@@ test_lazy_prereq UNZIP "$GIT_UNZIP" -v test $? -ne 127 ' + +run_with_limited_cmdline () { + (ulimit -s 128 && "$@") +} + +test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true'