TAP support for Git
v4 cover TAP support for Git
This is v4 of the TAP series for Git. This version fixes the failure Junio had with it (see <[email protected]>).
It does this by reverting the removal of the test_external_* functions. Now they're made TAP aware instead with a global `test_external_has_tap' that can be set by tests who wish to output their own TAP.
Thus t9700-perl-git.sh will again fail if it has any output on stderr, but since it sets `test_external_has_tap=1' we'll let it finalize its own TAP plan.
Not removing the test_external_* makes the impact of this series smaller, and preserves compatibility with other topics in-flight, such as the Gettext series.
This is the diff --stat from v3:
t/t9700-perl-git.sh | 11 ++++-- t/test-lib.sh | 97 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 101 insertions(+), 7 deletions(-)
Most of the additions are the restorations of the test_external_* functions, in slightly altered form.
Ævar Arnfjörð Bjarmason (5):
test-lib: Adjust output to be valid TAP format
test-lib: Make the test_external_* functions TAP-aware
test-lib: output a newline before "ok" under a TAP harness
tests: Skip tests in a way that makes sense under TAP
tests: Say "pass" rather than "ok" on empty lines for TAP
t/README | 55 ++++++++++++++++------- t/lib-git-svn.sh | 4 +- t/lib-httpd.sh | 3 +- t/t1020-subdirectory.sh | 12 +++--- t/t1304-default-acl.sh | 9 +++- t/t1509-root-worktree.sh | 6 +- t/t2007-checkout-symlink.sh | 2 +- t/t2102-update-index-symlinks.sh | 2 +- t/t3300-funny-names.sh | 2 +- t/t3302-notes-index-expensive.sh | 2 +- t/t3600-rm.sh | 2 +- t/t3700-add.sh | 12 +++--- t/t3701-add-interactive.sh | 4 +- t/t3902-quoted.sh | 2 +- t/t4004-diff-rename-symlink.sh | 2 +- t/t4011-diff-symlink.sh | 2 +- t/t4016-diff-quote.sh | 2 +- t/t4023-diff-rename-typechange.sh | 2 +- t/t4114-apply-typechange.sh | 2 +- t/t4115-apply-symlink.sh | 2 +- t/t4122-apply-symlink-inside.sh | 2 +- t/t5302-pack-index.sh | 2 +- t/t5503-tagfollow.sh | 2 +- t/t5522-pull-symlink.sh | 2 +- t/t5540-http-push.sh | 2 +- t/t5541-http-push.sh | 2 +- t/t5550-http-fetch.sh | 2 +- t/t5551-http-fetch.sh | 2 +- t/t5561-http-backend.sh | 2 +- t/t5705-clone-2gb.sh | 2 +- t/t6035-merge-dir-to-symlink.sh | 2 +- t/t7004-tag.sh | 2 +- t/t7006-pager.sh | 2 +- t/t7800-difftool.sh | 2 +- t/t9001-send-email.sh | 4 +- t/t9100-git-svn-basic.sh | 2 +- t/t9119-git-svn-info.sh | 2 +- t/t9129-git-svn-i18n-commitencoding.sh | 2 +- t/t9143-git-svn-gc.sh | 2 +- t/t9200-git-cvsexportcommit.sh | 4 +- t/t9400-git-cvsserver-server.sh | 6 +- t/t9401-git-cvsserver-crlf.sh | 6 +- t/t9600-cvsimport.sh | 2 +- t/t9700-perl-git.sh | 7 ++- t/t9700/test.pl | 11 +++++ t/test-lib.sh | 76 +++++++++++++++++++++++-------- 46 files changed, 178 insertions(+), 103 deletions(-)
PATCH v4 1/5 test-lib: Adjust output to be valid TAP format
TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. test-lib.sh's output was already very close to being valid TAP. This change brings it all the way there. Before:
$ ./t0005-signals.sh * ok 1: sigchain works * passed all 1 test(s)
And after:
$ ./t0005-signals.sh ok 1 - sigchain works # passed all 1 test(s) 1..1
The advantage of using TAP is that any program that reads the format (a "test harness") can run the tests. The most popular of these is the prove(1) utility that comes with Perl. It can run tests in parallel, display colored output, format the output to console, file, HTML etc., and much more. An example:
$ prove ./t0005-signals.sh ./t0005-signals.sh .. ok All tests successful. Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.01 cusr 0.02 csys = 0.06 CPU) Result: PASS
prove(1) gives you human readable output without being too verbose. Running the test suite in parallel with make test -j15 produces a flood of text. Running them with prove -j 15 ./t[0-9]*.sh makes it easy to follow what's going on.
All this patch does is re-arrange the output a bit so that it conforms with the TAP spec, everything that the test suite did before continues to work. That includes aggregating results in t/test-results/, the --verbose, --debug and other options for tests, and the test color output.
TAP harnesses ignore everything that they don't know about, so running the tests with --verbose works:
$ prove ./t0005-signals.sh :: --verbose --debug
./t0005-signals.sh .. Terminated
./t0005-signals.sh .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.01 cusr 0.01 csys = 0.05 CPU)
Result: PASSJust supply the -v option to prove itself to get all the verbose output that it suppresses:
$ prove -v ./t0005-signals.sh :: --verbose --debug
./t0005-signals.sh ..
Initialized empty Git repository in /home/avar/g/git/t/trash directory.t0005-signals/.git/
expecting success:
test-sigchain >actual
case "$?" in
143) true ;; # POSIX w/ SIGTERM=15
3) true ;; # Windows
*) false ;;
esac &&
test_cmp expect actual
Terminated
ok 1 - sigchain works
# passed all 1 test(s)
1..1
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr 0.01 csys = 0.04 CPU)
Result: PASS--- t/README | 55 +++++++++++++++++++++++++++++++++++++++---------------- t/test-lib.sh | 30 ++++++++++++++++++------------ 2 files changed, 57 insertions(+), 28 deletions(-)
t/README +41 -18
@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs all the tests. *** t0000-basic.sh *** - * ok 1: .git/objects should be empty after git-init in an empty repo. - * ok 2: .git/objects should have 256 subdirectories. - * ok 3: git-update-index without --add should fail adding. + ok 1 - .git/objects should be empty after git init in an empty repo. + ok 2 - .git/objects should have 3 subdirectories. + ok 3 - success is reported like this ... - * ok 23: no diff after checkout and git-update-index --refresh. - * passed all 23 test(s) - *** t0100-environment-names.sh *** - * ok 1: using old names should issue warnings. - * ok 2: using old names but having new names should not issue warnings. - ... - -Or you can run each test individually from command line, like -this: - - $ sh ./t3001-ls-files-killed.sh - * ok 1: git-update-index --add to add various paths. - * ok 2: git-ls-files -k to show killed files. - * ok 3: validate git-ls-files -k output. - * passed all 3 test(s) + ok 43 - very long name in the index handled sanely + # fixed 1 known breakage(s) + # still have 1 known breakage(s) + # passed all remaining 42 test(s) + 1..43 + *** t0001-init.sh *** + ok 1 - plain + ok 2 - plain with GIT_WORK_TREE + ok 3 - plain bare + +Since the tests all output TAP (see http://testanything.org) they can +be run with any TAP harness. Here's an example of paralell testing +powered by a recent version of prove(1): + + $ prove --timer --jobs 15 ./t[0-9]*.sh + [19:17:33] ./t0005-signals.sh ................................... ok 36 ms + [19:17:33] ./t0022-crlf-rename.sh ............................... ok 69 ms + [19:17:33] ./t0024-crlf-archive.sh .............................. ok 154 ms + [19:17:33] ./t0004-unwritable.sh ................................ ok 289 ms + [19:17:33] ./t0002-gitfile.sh ................................... ok 480 ms + ===( 102;0 25/? 6/? 5/? 16/? 1/? 4/? 2/? 1/? 3/? 1... )=== + +prove and other harnesses come with a lot of useful options. The +--state option in particular is very useful: + + # Repeat until no more failures + $ prove -j 15 --state=failed,save ./t[0-9]*.sh + +You can also run each test individually from command line, like this: + + $ sh ./t3010-ls-files-killed-modified.sh + ok 1 - git update-index --add to add various paths. + ok 2 - git ls-files -k to show killed files. + ok 3 - validate git ls-files -k output. + ok 4 - git ls-files -m to show modified files. + ok 5 - validate git ls-files -m output. + # passed all 5 test(s) + 1..5 You can pass --verbose (or -v), --debug (or -d), and --immediate (or -i) command line argument to the test, or by setting GIT_TEST_OPTS
t/test-lib.sh +18 -12
@@ -160,7 +160,7 @@ if test -n "$color"; then *) test -n "$quiet" && return;; esac shift - printf "* %s" "$*" + printf "%s" "$*" tput sgr0 echo )
@@ -169,7 +169,7 @@ else say_color() { test -z "$1" && test -n "$quiet" && return shift - echo "* $*" + echo "$*" } fi
@@ -339,25 +339,25 @@ test_have_prereq () { test_ok_ () { test_success=$(($test_success + 1)) - say_color "" " ok $test_count: $@" + say_color "" "ok $test_count - $@" } test_failure_ () { test_failure=$(($test_failure + 1)) - say_color error "FAIL $test_count: $1" + say_color error "not ok - $test_count $1" shift - echo "$@" | sed -e 's/^/ /' + echo "$@" | sed -e 's/^/# /' test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } } test_known_broken_ok_ () { test_fixed=$(($test_fixed+1)) - say_color "" " FIXED $test_count: $@" + say_color "" "ok $test_count - $@ # TODO known breakage" } test_known_broken_failure_ () { test_broken=$(($test_broken+1)) - say_color skip " still broken $test_count: $@" + say_color skip "not ok $test_count - $@ # TODO known breakage" } test_debug () {
@@ -390,7 +390,7 @@ test_skip () { case "$to_skip" in t) say_color skip >&3 "skipping test: $@" - say_color skip "skip $test_count: $1" + say_color skip "ok $test_count: # skip $1" : true ;; *)
@@ -620,18 +620,22 @@ test_done () { if test "$test_fixed" != 0 then - say_color pass "fixed $test_fixed known breakage(s)" + say_color pass "# fixed $test_fixed known breakage(s)" fi if test "$test_broken" != 0 then - say_color error "still have $test_broken known breakage(s)" + say_color error "# still have $test_broken known breakage(s)" msg="remaining $(($test_count-$test_broken)) test(s)" else msg="$test_count test(s)" fi case "$test_failure" in 0) - say_color pass "passed all $msg" + # Maybe print SKIP message + [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" + + say_color pass "# passed all $msg" + say "1..$test_count$skip_all" test -d "$remove_trash" && cd "$(dirname "$remove_trash")" &&
@@ -640,7 +644,9 @@ test_done () { exit 0 ;; *) - say_color error "failed $test_failure among $msg" + say_color error "# failed $test_failure among $msg" + say "1..$test_count" + exit 1 ;; esac
Signature · 1 line
1.7.1.251.g92a7
Re: [PATCH v4 1/5] test-lib: Adjust output to be valid TAP format
Quoted 9 lines · Ævar Arnfjörð Bjarmason
TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. test-lib.sh's output was already very close to being valid TAP. This change brings it all the way there. Before:
$ ./t0005-signals.sh * ok 1: sigchain works * passed all 1 test(s)
Quoted 6 lines
And after:
$ ./t0005-signals.sh ok 1 - sigchain works # passed all 1 test(s) 1..1
This is incomplete information. It only tells us how the output is changed for the case when all test_expect_success tests passes. This commit message doesn't tell us how failing tests looks like, and how test_expect_failure results gets translated.
Take for example a following test script:
-- >8 --
#!/bin/sh
test_description='this is a sample test.
This test is here to see various test outputs.'
. ./test-lib.sh
say 'diagnostic message'
test_expect_success 'true test' 'true'test_expect_success 'false test' 'false'
test_expect_failure 'true test (todo)' 'true'test_expect_failure 'false test (todo)' 'false'
test_debug 'echo "debug message"'
test_done
-- 8< --
This test script output looks like the following (the comments are not part of output, but denote color of given line of test output):
----
* diagnostic message # yellow
* ok 1: true test
* FAIL 2: false test # bold red
false
* FIXED 3: true test (todo)
* still broken 4: false test (todo) # bold green * fixed 1 known breakage(s) # green * still have 1 known breakage(s) # bold red * failed 1 among remaining 3 test(s) # bold red
----
How would the output of this test look like after TAP-ification? Would it still provide color output when run on terminal?
This test also generates summary of test run in a file in test-results/ subdirectory. Currently such file can be e.g. named test-results/test_test-8030, and consist of
-- >8 --
total 4
success 1
fixed 1
broken 1
failed 1
-- 8< --
Would TAP-ification change that? Even if there is no change, this is worth a sentence or a few words in a commit message.
P.S. With current output pass / fail results of test_expect_failure are justified on ':' separator. This is not the case of TAP output.
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Re: [PATCH v4 1/5] test-lib: Adjust output to be valid TAP format
Quoted 73 lines · Jakub Narebski
Quoted 9 lines · Ævar Arnfjörð Bjarmason
TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. test-lib.sh's output was already very close to being valid TAP. This change brings it all the way there. Before:
$ ./t0005-signals.sh * ok 1: sigchain works * passed all 1 test(s)Quoted 6 lines
And after:
$ ./t0005-signals.sh ok 1 - sigchain works # passed all 1 test(s) 1..1This is incomplete information. It only tells us how the output is changed for the case when all
test_expect_successtests passes. This commit message doesn't tell us how failing tests looks like, and howtest_expect_failureresults gets translated.Take for example a following test script:
-- >8 --
#!/bin/shtest_description='this is a sample test.
This test is here to see various test outputs.'
. ./test-lib.sh
say 'diagnostic message'
test_expect_success'true test' 'true'test_expect_success'false test' 'false'
test_expect_failure'true test (todo)' 'true'test_expect_failure'false test (todo)' 'false'
test_debug'echo "debug message"'
test_done
-- 8< --This test script output looks like the following (the comments are not part of output, but denote color of given line of test output):
----
* diagnostic message # yellow
* ok 1: true test
* FAIL 2: false test # bold red
false
* FIXED 3: true test (todo)
* still broken 4: false test (todo) # bold green
* fixed 1 known breakage(s) # green
* still have 1 known breakage(s) # bold red
* failed 1 among remaining 3 test(s) # bold red
----How would the output of this test look like after TAP-ification? Would it still provide color output when run on terminal?
This test also generates summary of test run in a file in test-results/ subdirectory. Currently such file can be e.g. named test-results/test_test-8030, and consist of
-- >8 --
total 4
success 1
fixed 1
broken 1
failed 1
Quoted 4 lines
-- 8< --
Would TAP-ification change that? Even if there is no change, this is worth a sentence or a few words in a commit message.
To all of the above: I could be more verbose in the commit message in needed, but after you raised similar questions in a previous version of this series I added this to the above commit message:
All this patch does is re-arrange the output a bit so that it conforms with the TAP spec, everything that the test suite did before continues to work. That includes aggregating results in t/test-results/, the --verbose, --debug and other options for tests, and the test color output.
I.e. aside from turning "FAIL" into "not ok" and removing the "* " prefix from lines everything else works exactly as before, that includes color output and the aggregation in t/test-results/.
I can expand on that paragraph with more examples if you think it's necessary.
Here's how the output from the above test script looks under TAP:
diagnostic message
ok 1 - true test
not ok - 2 false test
# false
ok 3 - true test (todo) # TODO known breakage not ok 4 - false test (todo) # TODO known breakage # fixed 1 known breakage(s)
# still have 1 known breakage(s)
# failed 1 among remaining 3 test(s)
1..4
Quoted 2 lines
P.S. With current output pass / fail results oftest_expect_failureare justified on ':' separator. This is not the case of TAP output.
TAP output is conventionally not justified, unlike the existing output. I don't know if anything would break if it were, i.e.:
ok 1 - foo
not ok 2 - bar
PATCH v5 1/5 test-lib: Adjust output to be valid TAP format
TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. test-lib.sh's output was already very close to being valid TAP. This change brings it all the way there. Before:
$ ./t0005-signals.sh
* ok 1: sigchain works
* passed all 1 test(s)And after:
$ ./t0005-signals.sh
ok 1 - sigchain works
# passed all 1 test(s)
1..1The advantage of using TAP is that any program that reads the format (a "test harness") can run the tests. The most popular of these is the prove(1) utility that comes with Perl. It can run tests in parallel, display colored output, format the output to console, file, HTML etc., and much more. An example:
$ prove ./t0005-signals.sh
./t0005-signals.sh .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.01 cusr 0.02 csys = 0.06 CPU)
Result: PASSprove(1) gives you human readable output without being too verbose. Running the test suite in parallel with make test -j15 produces a flood of text. Running them with prove -j 15 ./t[0-9]*.sh makes it easy to follow what's going on.
All this patch does is re-arrange the output a bit so that it conforms with the TAP spec, everything that the test suite did before continues to work. That includes aggregating results in t/test-results/, the --verbose, --debug and other options for tests, and the test color output.
TAP harnesses ignore everything that they don't know about, so running the tests with --verbose works:
$ prove ./t0005-signals.sh :: --verbose --debug
./t0005-signals.sh .. Terminated
./t0005-signals.sh .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.01 cusr 0.01 csys = 0.05 CPU)
Result: PASSJust supply the -v option to prove itself to get all the verbose output that it suppresses:
$ prove -v ./t0005-signals.sh :: --verbose --debug
./t0005-signals.sh ..
Initialized empty Git repository in /home/avar/g/git/t/trash directory.t0005-signals/.git/
expecting success:
test-sigchain >actual
case "$?" in
143) true ;; # POSIX w/ SIGTERM=15
3) true ;; # Windows
*) false ;;
esac &&
test_cmp expect actual
Terminated
ok 1 - sigchain works
# passed all 1 test(s)
1..1
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr 0.01 csys = 0.04 CPU)
Result: PASSAs a further example, consider this test script that uses a lot of test-lib.sh features by Jakub Narebski:
#!/bin/sh
test_description='this is a sample test.
This test is here to see various test outputs.'
. ./test-lib.sh
say 'diagnostic message'
test_expect_success 'true test' 'true'
test_expect_success 'false test' 'false'
test_expect_failure 'true test (todo)' 'true' test_expect_failure 'false test (todo)' 'false'
test_debug 'echo "debug message"'
test_done
The output of that was previously:
* diagnostic message # yellow
* ok 1: true test
* FAIL 2: false test # bold red
false
* FIXED 3: true test (todo)
* still broken 4: false test (todo) # bold green
* fixed 1 known breakage(s) # green
* still have 1 known breakage(s) # bold red
* failed 1 among remaining 3 test(s) # bold red
But is now:
diagnostic message # yellow
ok 1 - true test
not ok - 2 false test # bold red
# false
ok 3 - true test (todo) # TODO known breakage
not ok 4 - false test (todo) # TODO known breakage # bold green
# fixed 1 known breakage(s) # green
# still have 1 known breakage(s) # bold red
# failed 1 among remaining 3 test(s) # bold red
1..4
All the coloring is preserved when the test is run manually. Under prove(1) the test performs as expected, even with --debug and --verbose options:
$ prove ./example.sh :: --debug --verbose
./example.sh .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests
(1 TODO test unexpectedly succeeded) Test Summary Report
-------------------
./example.sh (Wstat: 256 Tests: 4 Failed: 1)
Failed test: 2
TODO passed: 3
Non-zero exit status: 1
Files=1, Tests=4, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.00 cusr 0.01 csys = 0.03 CPU)
Result: FAIL
The TAP harness itself doesn't get confused by the color output, they aren't used by test-lib.sh stdout isn't open to a terminal (test -t 1).
---
Quoted 2 lines
To all of the above: I could be more verbose in the commit message in needed.
Here's v5 of this patch which does that. I used the example Jakub provided and explained how it works with regards to colors and interaction with a TAP harness.
t/README | 55 +++++++++++++++++++++++++++++++++++++++---------------- t/test-lib.sh | 30 ++++++++++++++++++------------ 2 files changed, 57 insertions(+), 28 deletions(-)
t/README +41 -18
@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs all the tests. *** t0000-basic.sh *** - * ok 1: .git/objects should be empty after git-init in an empty repo. - * ok 2: .git/objects should have 256 subdirectories. - * ok 3: git-update-index without --add should fail adding. + ok 1 - .git/objects should be empty after git init in an empty repo. + ok 2 - .git/objects should have 3 subdirectories. + ok 3 - success is reported like this ... - * ok 23: no diff after checkout and git-update-index --refresh. - * passed all 23 test(s) - *** t0100-environment-names.sh *** - * ok 1: using old names should issue warnings. - * ok 2: using old names but having new names should not issue warnings. - ... - -Or you can run each test individually from command line, like -this: - - $ sh ./t3001-ls-files-killed.sh - * ok 1: git-update-index --add to add various paths. - * ok 2: git-ls-files -k to show killed files. - * ok 3: validate git-ls-files -k output. - * passed all 3 test(s) + ok 43 - very long name in the index handled sanely + # fixed 1 known breakage(s) + # still have 1 known breakage(s) + # passed all remaining 42 test(s) + 1..43 + *** t0001-init.sh *** + ok 1 - plain + ok 2 - plain with GIT_WORK_TREE + ok 3 - plain bare + +Since the tests all output TAP (see http://testanything.org) they can +be run with any TAP harness. Here's an example of paralell testing +powered by a recent version of prove(1): + + $ prove --timer --jobs 15 ./t[0-9]*.sh + [19:17:33] ./t0005-signals.sh ................................... ok 36 ms + [19:17:33] ./t0022-crlf-rename.sh ............................... ok 69 ms + [19:17:33] ./t0024-crlf-archive.sh .............................. ok 154 ms + [19:17:33] ./t0004-unwritable.sh ................................ ok 289 ms + [19:17:33] ./t0002-gitfile.sh ................................... ok 480 ms + ===( 102;0 25/? 6/? 5/? 16/? 1/? 4/? 2/? 1/? 3/? 1... )=== + +prove and other harnesses come with a lot of useful options. The +--state option in particular is very useful: + + # Repeat until no more failures + $ prove -j 15 --state=failed,save ./t[0-9]*.sh + +You can also run each test individually from command line, like this: + + $ sh ./t3010-ls-files-killed-modified.sh + ok 1 - git update-index --add to add various paths. + ok 2 - git ls-files -k to show killed files. + ok 3 - validate git ls-files -k output. + ok 4 - git ls-files -m to show modified files. + ok 5 - validate git ls-files -m output. + # passed all 5 test(s) + 1..5 You can pass --verbose (or -v), --debug (or -d), and --immediate (or -i) command line argument to the test, or by setting GIT_TEST_OPTS
t/test-lib.sh +18 -12
@@ -160,7 +160,7 @@ if test -n "$color"; then *) test -n "$quiet" && return;; esac shift - printf "* %s" "$*" + printf "%s" "$*" tput sgr0 echo )
@@ -169,7 +169,7 @@ else say_color() { test -z "$1" && test -n "$quiet" && return shift - echo "* $*" + echo "$*" } fi
@@ -339,25 +339,25 @@ test_have_prereq () { test_ok_ () { test_success=$(($test_success + 1)) - say_color "" " ok $test_count: $@" + say_color "" "ok $test_count - $@" } test_failure_ () { test_failure=$(($test_failure + 1)) - say_color error "FAIL $test_count: $1" + say_color error "not ok - $test_count $1" shift - echo "$@" | sed -e 's/^/ /' + echo "$@" | sed -e 's/^/# /' test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } } test_known_broken_ok_ () { test_fixed=$(($test_fixed+1)) - say_color "" " FIXED $test_count: $@" + say_color "" "ok $test_count - $@ # TODO known breakage" } test_known_broken_failure_ () { test_broken=$(($test_broken+1)) - say_color skip " still broken $test_count: $@" + say_color skip "not ok $test_count - $@ # TODO known breakage" } test_debug () {
@@ -390,7 +390,7 @@ test_skip () { case "$to_skip" in t) say_color skip >&3 "skipping test: $@" - say_color skip "skip $test_count: $1" + say_color skip "ok $test_count: # skip $1" : true ;; *)
@@ -620,18 +620,22 @@ test_done () { if test "$test_fixed" != 0 then - say_color pass "fixed $test_fixed known breakage(s)" + say_color pass "# fixed $test_fixed known breakage(s)" fi if test "$test_broken" != 0 then - say_color error "still have $test_broken known breakage(s)" + say_color error "# still have $test_broken known breakage(s)" msg="remaining $(($test_count-$test_broken)) test(s)" else msg="$test_count test(s)" fi case "$test_failure" in 0) - say_color pass "passed all $msg" + # Maybe print SKIP message + [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" + + say_color pass "# passed all $msg" + say "1..$test_count$skip_all" test -d "$remove_trash" && cd "$(dirname "$remove_trash")" &&
@@ -640,7 +644,9 @@ test_done () { exit 0 ;; *) - say_color error "failed $test_failure among $msg" + say_color error "# failed $test_failure among $msg" + say "1..$test_count" + exit 1 ;; esac
Signature · 1 line
1.7.1.251.g92a7
Re: [PATCH v5 1/5] test-lib: Adjust output to be valid TAP format
t/README The easiest way to run tests is to say "make". This runs all
Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/README +0
-0@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs all
This describes the general framework of tests from the point of view of a person who runs them and reads their output well. I'll replace ab/tap topic with these five patches.
I'd however like to ask you to update the sections in t/README to help test writers. You have gained enough experience with patches 4 and 5 (and with patch 2 for Perl tests) to know what kind of script constructs, used by people who are used to the old way of writing our tests, would cause the TAP stuff to break, and are in the ideal position to rewrite that section. Two examples of what is drastically different from the old world order are "do not print to the standard output strings that begin with XX (or partial lines)" and "here is how to skip the remainder of the tests", but you may have a handful of more rules. I expect that "Writing Tests" through "Test harness library" sections would be affected.
Earlier I kept wondering if this series is worth the trouble. Having to learn and follow the set of these new rules is exactly what I meant by "trouble". Let's make sure that the new rules are clear, small, and easy to follow for other contributors.
Thanks.
Re: [PATCH v5 1/5] test-lib: Adjust output to be valid TAP format
Quoted 24 lines · Junio C Hamano
t/README The easiest way to run tests is to say "make". This runs all
Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/README +0
-0@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs allThis describes the general framework of tests from the point of view of a person who runs them and reads their output well. I'll replace ab/tap topic with these five patches.
I'd however like to ask you to update the sections in t/README to help test writers. You have gained enough experience with patches 4 and 5 (and with patch 2 for Perl tests) to know what kind of script constructs, used by people who are used to the old way of writing our tests, would cause the TAP stuff to break, and are in the ideal position to rewrite that section. Two examples of what is drastically different from the old world order are "do not print to the standard output strings that begin with XX (or partial lines)" and "here is how to skip the remainder of the tests", but you may have a handful of more rules. I expect that "Writing Tests" through "Test harness library" sections would be affected.
Quoted 4 lines
Earlier I kept wondering if this series is worth the trouble. Having to learn and follow the set of these new rules is exactly what I meant by "trouble". Let's make sure that the new rules are clear, small, and easy to follow for other contributors.
I'll write those docs, but I probably won't have time in the next few days so I'll submit a patch for that it separately if that's OK.
Re: [PATCH v5 1/5] test-lib: Adjust output to be valid TAP format
Quoted 17 lines · Ævar Arnfjörð Bjarmason
Quoted 16 lines · Junio C Hamano
t/README The easiest way to run tests is to say "make". This runs all
Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/README +0
-0@@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs allThis describes the general framework of tests from the point of view of a person who runs them and reads their output well. I'll replace ab/tap topic with these five patches.
...
I'd however like to ask you to update the sections in t/README to help test writers....
Quoted 7 lines
Quoted 4 lines
Earlier I kept wondering if this series is worth the trouble. Having to learn and follow the set of these new rules is exactly what I meant by "trouble". Let's make sure that the new rules are clear, small, and easy to follow for other contributors.
I'll write those docs, but I probably won't have time in the next few days so I'll submit a patch for that it separately if that's OK.
Oh, absolutely. I meant to say that v4/v5 round already has a good documentation for test users/readers; a follow-up patch to help test writers would make the series more complete.
Thanks.
Re: [PATCH v5 1/5] test-lib: Adjust output to be valid TAP format
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Ævar Arnfjörð Bjarmason
I'll write those docs, but I probably won't have time in the next few days so I'll submit a patch for that it separately if that's OK.
Oh, absolutely. I meant to say that v4/v5 round already has a good documentation for test users/readers; a follow-up patch to help test writers would make the series more complete.
Sweet, yeah I'll make the t/README more awesomer later, good to hear that v4/v5 is good enough.
Thanks!
PATCH v4 2/5 test-lib: Make the test_external_* functions TAP-aware
In reply to Ævar Arnfjörð BjarmasonBefore TAP we just ran the Perl test and assumed that it failed if nothing was printed on STDERR. Continue doing that, but introduce a `test_external_has_tap' variable which tests can set to indicate that they're outputting TAP.
If it's set we won't output a test plan, but trust the external test to do so. That way we can make external tests work with a TAP harness, but still maintain compatibility with test-lib's own way of tracking tests through the test-results directory.
--- t/t9700-perl-git.sh | 3 +++ t/t9700/test.pl | 11 +++++++++++ t/test-lib.sh | 51 +++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 12 deletions(-)
t/t9700-perl-git.sh +3 -0
@@ -46,6 +46,9 @@ test_expect_success \ git config --add test.int 2k ' +# The external test will outputs its own plan +test_external_has_tap=1 + test_external_without_stderr \ 'Perl API' \ "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
t/t9700/test.pl +11 -0
@@ -7,6 +7,13 @@ use strict; use Test::More qw(no_plan); +BEGIN { + # t9700-perl-git.sh kicks off our testing, so we have to go from + # there. + $Test::Builder::Test->{Curr_Test} = 1; + $Test::Builder::Test->{No_Ending} = 1; +} + use Cwd; use File::Basename;
@@ -105,3 +112,7 @@ my $last_commit = $r2->command_oneline(qw(rev-parse --verify HEAD)); like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash'); my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.'); isnt($last_commit, $dir_commit, 'log . does not show last commit'); + +printf "1..%d\n", $Test::Builder::Test->{Curr_Test}; + +exit($Test::Builder::Test->{Is_Passing} ? 0 : 1);
t/test-lib.sh +39 -12
103 lines not on this page · raw message
Signature · 1 line
1.7.1.251.g92a7
PATCH v4 3/5 test-lib: output a newline before "ok" under a TAP harness
In reply to Ævar Arnfjörð BjarmasonSome tests in the testsuite will emit a line that doesn't end with a newline, right before we're about to output "ok" or "not ok". This breaks the TAP output with "Tests out of sequence" errors since a TAP harness can't understand this:
ok 1 - A test
[some output here]ok 2 - Another test
ok 3 - Yet another test
Work around it by emitting an empty line before we're about to say "ok" or "not ok", but only if we're running under --verbose and HARNESS_ACTIVE=1 is set, which'll only be the case when running under a harnesses like prove(1).
I think it's better to do this than fix each tests by adding `&& echo' everywhere. More tests might be added that break TAP in the future, and a human isn't going to look at the extra whitespace, since HARNESS_ACTIVE=1 always means a harness is reading it.
The tests that had issues were:
t1007, t3410, t3413, t3409, t3414, t3415, t3416, t3412, t3404, t5407, t7402, t7003, t9001
With this workaround the entire test suite runs without errors under:
prove -j 10 ./t[0-9]*.sh :: --verbose
--- t/test-lib.sh | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
t/test-lib.sh +3 -0
@@ -371,6 +371,9 @@ test_run_ () { eval >&3 2>&4 "$1" eval_ret=$? eval >&3 2>&4 "$test_cleanup" + if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then + echo "" + fi return 0 }
Signature · 1 line
1.7.1.251.g92a7
PATCH v4 4/5 tests: Skip tests in a way that makes sense under TAP
In reply to Ævar Arnfjörð BjarmasonSKIP messages are now part of the TAP plan. A TAP harness now knows why a particular test was skipped and can report that information. The non-TAP harness built into Git's test-lib did nothing special with these messages, and is unaffected by these changes.
--- t/lib-git-svn.sh | 4 ++-- t/lib-httpd.sh | 3 +-- t/t1304-default-acl.sh | 9 ++++++--- t/t1509-root-worktree.sh | 6 +++--- t/t2007-checkout-symlink.sh | 2 +- t/t3300-funny-names.sh | 2 +- t/t3302-notes-index-expensive.sh | 2 +- t/t3600-rm.sh | 2 +- t/t3701-add-interactive.sh | 4 ++-- t/t3902-quoted.sh | 2 +- t/t4004-diff-rename-symlink.sh | 2 +- t/t4011-diff-symlink.sh | 2 +- t/t4016-diff-quote.sh | 2 +- t/t4023-diff-rename-typechange.sh | 2 +- t/t4114-apply-typechange.sh | 2 +- t/t4115-apply-symlink.sh | 2 +- t/t4122-apply-symlink-inside.sh | 2 +- t/t5302-pack-index.sh | 2 +- t/t5503-tagfollow.sh | 2 +- t/t5522-pull-symlink.sh | 2 +- t/t5540-http-push.sh | 2 +- t/t5541-http-push.sh | 2 +- t/t5550-http-fetch.sh | 2 +- t/t5551-http-fetch.sh | 2 +- t/t5561-http-backend.sh | 2 +- t/t5705-clone-2gb.sh | 2 +- t/t6035-merge-dir-to-symlink.sh | 2 +- t/t7004-tag.sh | 2 +- t/t7006-pager.sh | 2 +- t/t7800-difftool.sh | 2 +- t/t9001-send-email.sh | 4 ++-- t/t9100-git-svn-basic.sh | 2 +- t/t9119-git-svn-info.sh | 2 +- t/t9129-git-svn-i18n-commitencoding.sh | 2 +- t/t9143-git-svn-gc.sh | 2 +- t/t9200-git-cvsexportcommit.sh | 4 ++-- t/t9400-git-cvsserver-server.sh | 6 +++--- t/t9401-git-cvsserver-crlf.sh | 6 +++--- t/t9600-cvsimport.sh | 2 +- t/t9700-perl-git.sh | 4 ++-- 40 files changed, 56 insertions(+), 54 deletions(-)
t/lib-git-svn.sh +2 -2
@@ -5,11 +5,11 @@ git_svn_id=git""-svn-id if test -n "$NO_SVN_TESTS" then - say 'skipping git svn tests, NO_SVN_TESTS defined' + skip_all='skipping git svn tests, NO_SVN_TESTS defined' test_done fi if ! test_have_prereq PERL; then - say 'skipping git svn tests, perl not available' + skip_all='skipping git svn tests, perl not available' test_done fi
t/lib-httpd.sh +1 -2
@@ -5,8 +5,7 @@ if test -z "$GIT_TEST_HTTPD" then - say "skipping test, network testing disabled by default" - say "(define GIT_TEST_HTTPD to enable)" + skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)" test_done fi
t/t1304-default-acl.sh +6 -3
@@ -15,9 +15,12 @@ umask 077 # is a good candidate: exists on all unices, and it has permission # anyway, so we don't create a security hole running the testsuite. -if ! setfacl -m u:root:rwx .; then - say "Skipping ACL tests: unable to use setfacl" - test_done +setfacl_out="$(setfacl -m u:root:rwx . 2>&1)" +setfacl_ret=$? + +if [ $setfacl_ret != 0 ]; then + skip_all="Skipping ACL tests: unable to use setfacl (output: '$setfacl_out'; return code: '$setfacl_ret')" + test_done fi check_perms_and_acl () {
t/t1509-root-worktree.sh +3 -3
@@ -99,17 +99,17 @@ test_foobar_foobar() { } if ! test_have_prereq POSIXPERM || ! [ -w / ]; then - say "Dangerous test skipped. Read this test if you want to execute it" + skip_all="Dangerous test skipped. Read this test if you want to execute it" test_done fi if [ "$IKNOWWHATIAMDOING" != "YES" ]; then - say "You must set env var IKNOWWHATIAMDOING=YES in order to run this test" + skip_all="You must set env var IKNOWWHATIAMDOING=YES in order to run this test" test_done fi if [ "$UID" = 0 ]; then - say "No you can't run this with root" + skip_all="No you can't run this with root" test_done fi
t/t2007-checkout-symlink.sh +1 -1
@@ -8,7 +8,7 @@ test_description='git checkout to switch between branches with symlink<->dir' if ! test_have_prereq SYMLINKS then - say "symbolic links not supported - skipping tests" + skip_all="symbolic links not supported - skipping tests" test_done fi
t/t3300-funny-names.sh +1 -1
@@ -26,7 +26,7 @@ echo 'Foo Bar Baz' >"$p2" test -f "$p1" && cmp "$p0" "$p1" || { # since FAT/NTFS does not allow tabs in filenames, skip this test - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done }
t/t3302-notes-index-expensive.sh +1 -1
@@ -8,7 +8,7 @@ test_description='Test commit notes index (expensive!)' . ./test-lib.sh test -z "$GIT_NOTES_TIMING_TESTS" && { - say Skipping timing tests + skip_all="Skipping timing tests" test_done exit }
t/t3600-rm.sh +1 -1
@@ -39,7 +39,7 @@ if test -f test-file then test_set_prereq RO_DIR else - say 'skipping removal failure test (perhaps running as root?)' + skip_all='skipping removal failure test (perhaps running as root?)' fi chmod 775 . rm -f test-file
t/t3701-add-interactive.sh +2 -2
@@ -4,7 +4,7 @@ test_description='add -i basic tests' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git add -i tests, perl not available' + skip_all='skipping git add -i tests, perl not available' test_done fi
@@ -154,7 +154,7 @@ rm -f .gitignore if test "$(git config --bool core.filemode)" = false then - say 'skipping filemode tests (filesystem does not properly support modes)' + say '# skipping filemode tests (filesystem does not properly support modes)' else test_set_prereq FILEMODE fi
t/t3902-quoted.sh +1 -1
@@ -17,7 +17,7 @@ DQ='"' echo foo 2>/dev/null > "Name and an${HT}HT" test -f "Name and an${HT}HT" || { # since FAT/NTFS does not allow tabs in filenames, skip this test - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done }
t/t4004-diff-rename-symlink.sh +1 -1
@@ -14,7 +14,7 @@ by an edit for them. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t4011-diff-symlink.sh +1 -1
@@ -11,7 +11,7 @@ test_description='Test diff of symlinks. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t4016-diff-quote.sh +1 -1
@@ -14,7 +14,7 @@ P2='pathname with SP' P3='pathname with LF' : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || { - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done }
t/t4023-diff-rename-typechange.sh +1 -1
@@ -6,7 +6,7 @@ test_description='typechange rename detection' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t4114-apply-typechange.sh +1 -1
@@ -11,7 +11,7 @@ test_description='git apply should not get confused with type changes. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t4115-apply-symlink.sh +1 -1
@@ -11,7 +11,7 @@ test_description='git apply symlinks and partial files if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t4122-apply-symlink-inside.sh +1 -1
@@ -5,7 +5,7 @@ test_description='apply to deeper directory without getting fooled with symlink' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t5302-pack-index.sh +1 -1
@@ -74,7 +74,7 @@ if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) || then test_set_prereq OFF64_T else - say "skipping tests concerning 64-bit offsets" + say "# skipping tests concerning 64-bit offsets" fi test_expect_success OFF64_T \
t/t5503-tagfollow.sh +1 -1
@@ -6,7 +6,7 @@ test_description='test automatic tag following' case $(uname -s) in *MINGW*) - say "GIT_DEBUG_SEND_PACK not supported - skipping tests" + skip_all="GIT_DEBUG_SEND_PACK not supported - skipping tests" test_done esac
t/t5522-pull-symlink.sh +1 -1
@@ -6,7 +6,7 @@ test_description='pulling from symlinked subdir' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t5540-http-push.sh +1 -1
@@ -11,7 +11,7 @@ This test runs various sanity checks on http-push.' if git http-push > /dev/null 2>&1 || [ $? -eq 128 ] then - say "skipping test, USE_CURL_MULTI is not defined" + skip_all="skipping test, USE_CURL_MULTI is not defined" test_done fi
t/t5541-http-push.sh +1 -1
@@ -7,7 +7,7 @@ test_description='test smart pushing over http via http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi
t/t5550-http-fetch.sh +1 -1
@@ -4,7 +4,7 @@ test_description='test dumb fetching over http via static file' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi
t/t5551-http-fetch.sh +1 -1
@@ -4,7 +4,7 @@ test_description='test smart fetching over http via http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi
t/t5561-http-backend.sh +1 -1
@@ -4,7 +4,7 @@ test_description='test git-http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi
t/t5705-clone-2gb.sh +1 -1
@@ -4,7 +4,7 @@ test_description='Test cloning a repository larger than 2 gigabyte' . ./test-lib.sh test -z "$GIT_TEST_CLONE_2GB" && -say "Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" && +skip_all="Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" && test_done && exit
t/t6035-merge-dir-to-symlink.sh +1 -1
@@ -5,7 +5,7 @@ test_description='merging when a directory was replaced with a symlink' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi
t/t7004-tag.sh +1 -1
@@ -583,7 +583,7 @@ test_expect_success \ # subsequent tests require gpg; check if it is available gpg --version >/dev/null 2>/dev/null if [ $? -eq 127 ]; then - say "gpg not found - skipping tag signing and verification tests" + say "# gpg not found - skipping tag signing and verification tests" else # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19 # the gpg version 1.0.6 didn't parse trust packets correctly, so for
t/t7006-pager.sh +1 -1
@@ -37,7 +37,7 @@ then } test_set_prereq TTY else - say no usable terminal, so skipping some tests + say "# no usable terminal, so skipping some tests" fi test_expect_success 'setup' '
t/t7800-difftool.sh +1 -1
@@ -11,7 +11,7 @@ Testing basic diff tool invocation . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping difftool tests, perl not available' + skip_all='skipping difftool tests, perl not available' test_done fi
t/t9001-send-email.sh +2 -2
@@ -4,7 +4,7 @@ test_description='git send-email' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git send-email tests, perl not available' + skip_all='skipping git send-email tests, perl not available' test_done fi
@@ -58,7 +58,7 @@ test_no_confirm () { # Exit immediately to prevent hang if a no-confirm test fails check_no_confirm () { test -f no_confirm_okay || { - say 'No confirm test failed; skipping remaining tests to prevent hanging' + skip_all='confirm test failed; skipping remaining tests to prevent hanging' test_done } }
t/t9100-git-svn-basic.sh +1 -1
@@ -15,7 +15,7 @@ case "$GIT_SVN_LC_ALL" in test_set_prereq UTF8 ;; *) - say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)" + say "# UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)" ;; esac
t/t9119-git-svn-info.sh +1 -1
@@ -13,7 +13,7 @@ case $v in 1.[456].*) ;; *) - say "skipping svn-info test (SVN version: $v not supported)" + skip_all="skipping svn-info test (SVN version: $v not supported)" test_done ;; esac
t/t9129-git-svn-i18n-commitencoding.sh +1 -1
@@ -23,7 +23,7 @@ if test -n "$a_utf8_locale" then test_set_prereq UTF8 else - say "UTF-8 locale not available, some tests are skipped" + say "# UTF-8 locale not available, some tests are skipped" fi compare_svn_head_with () {
t/t9143-git-svn-gc.sh +1 -1
@@ -43,7 +43,7 @@ then gunzip .git/svn/refs/remotes/git-svn/unhandled.log.gz ' else - say "Perl Compress::Zlib unavailable, skipping gunzip test" + say "# Perl Compress::Zlib unavailable, skipping gunzip test" fi test_expect_success 'git svn gc does not change unhandled.log files' '
t/t9200-git-cvsexportcommit.sh +2 -2
@@ -7,14 +7,14 @@ test_description='Test export of commits to CVS' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git cvsexportcommit tests, perl not available' + skip_all='skipping git cvsexportcommit tests, perl not available' test_done fi cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git cvsexportcommit tests, cvs not found' + skip_all='skipping git cvsexportcommit tests, cvs not found' test_done fi
t/t9400-git-cvsserver-server.sh +3 -3
@@ -11,17 +11,17 @@ cvs CLI client via git-cvsserver server' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git cvsserver tests, perl not available' + skip_all='skipping git cvsserver tests, perl not available' test_done fi cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git-cvsserver tests, cvs not found' + skip_all='skipping git-cvsserver tests, cvs not found' test_done fi "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { - say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' + skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done }
t/t9401-git-cvsserver-crlf.sh +3 -3
@@ -41,16 +41,16 @@ not_present() { cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git-cvsserver tests, cvs not found' + skip_all='skipping git-cvsserver tests, cvs not found' test_done fi if ! test_have_prereq PERL then - say 'skipping git-cvsserver tests, perl not available' + skip_all='skipping git-cvsserver tests, perl not available' test_done fi "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { - say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' + skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done }
t/t9600-cvsimport.sh +1 -1
@@ -4,7 +4,7 @@ test_description='git cvsimport basic tests' . ./lib-cvs.sh if ! test_have_prereq PERL; then - say 'skipping git cvsimport tests, perl not available' + skip_all='skipping git cvsimport tests, perl not available' test_done fi
t/t9700-perl-git.sh +2 -2
@@ -7,12 +7,12 @@ test_description='perl interface (Git.pm)' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping perl interface tests, perl not available' + skip_all='skipping perl interface tests, perl not available' test_done fi "$PERL_PATH" -MTest::More -e 0 2>/dev/null || { - say "Perl Test::More unavailable, skipping test" + skip_all="Perl Test::More unavailable, skipping test" test_done }
Signature · 1 line
1.7.1.251.g92a7
PATCH v4 5/5 tests: Say "pass" rather than "ok" on empty lines for TAP
In reply to Ævar Arnfjörð BjarmasonLines that begin with "ok" confuse the TAP harness because it can't distinguish them from a test counter. Work around the issue by saying "pass" instead, which isn't a reserved TAP word.
--- t/t1020-subdirectory.sh | 12 ++++++------ t/t2102-update-index-symlinks.sh | 2 +- t/t3700-add.sh | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-)
t/t1020-subdirectory.sh +6 -6
@@ -24,18 +24,18 @@ test_expect_success 'update-index and ls-files' ' cd "$HERE" && git update-index --add one && case "`git ls-files`" in - one) echo ok one ;; + one) echo pass one ;; *) echo bad one; exit 1 ;; esac && cd dir && git update-index --add two && case "`git ls-files`" in - two) echo ok two ;; + two) echo pass two ;; *) echo bad two; exit 1 ;; esac && cd .. && case "`git ls-files`" in - dir/two"$LF"one) echo ok both ;; + dir/two"$LF"one) echo pass both ;; *) echo bad; exit 1 ;; esac '
@@ -58,17 +58,17 @@ test_expect_success 'diff-files' ' echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok top ;; + dir/two"$LF"one) echo pass top ;; *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths cd dir && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok subdir ;; + dir/two"$LF"one) echo pass subdir ;; *) echo bad subdir; exit 1 ;; esac && case "`git diff-files --name-only .`" in - dir/two) echo ok subdir limited ;; + dir/two) echo pass subdir limited ;; *) echo bad subdir limited; exit 1 ;; esac '
t/t2102-update-index-symlinks.sh +1 -1
@@ -24,7 +24,7 @@ git update-index symlink' test_expect_success \ 'the index entry must still be a symbolic link' ' case "`git ls-files --stage --cached symlink`" in -120000" "*symlink) echo ok;; +120000" "*symlink) echo pass;; *) echo fail; git ls-files --stage --cached symlink; (exit 1);; esac'
t/t3700-add.sh +6 -6
@@ -26,7 +26,7 @@ test_expect_success \ chmod 755 xfoo1 && git add xfoo1 && case "`git ls-files --stage xfoo1`" in - 100644" "*xfoo1) echo ok;; + 100644" "*xfoo1) echo pass;; *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac'
@@ -35,7 +35,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym ln -s foo xfoo1 && git add xfoo1 && case "`git ls-files --stage xfoo1`" in - 120000" "*xfoo1) echo ok;; + 120000" "*xfoo1) echo pass;; *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac '
@@ -47,7 +47,7 @@ test_expect_success \ chmod 755 xfoo2 && git update-index --add xfoo2 && case "`git ls-files --stage xfoo2`" in - 100644" "*xfoo2) echo ok;; + 100644" "*xfoo2) echo pass;; *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac'
@@ -56,7 +56,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym ln -s foo xfoo2 && git update-index --add xfoo2 && case "`git ls-files --stage xfoo2`" in - 120000" "*xfoo2) echo ok;; + 120000" "*xfoo2) echo pass;; *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac '
@@ -67,7 +67,7 @@ test_expect_success SYMLINKS \ ln -s xfoo2 xfoo3 && git update-index --add xfoo3 && case "`git ls-files --stage xfoo3`" in - 120000" "*xfoo3) echo ok;; + 120000" "*xfoo3) echo pass;; *) echo fail; git ls-files --stage xfoo3; (exit 1);; esac'
@@ -172,7 +172,7 @@ test_expect_success 'git add --refresh' ' test -z "`git diff-index HEAD -- foo`" && git read-tree HEAD && case "`git diff-index HEAD -- foo`" in - :100644" "*"M foo") echo ok;; + :100644" "*"M foo") echo pass;; *) echo fail; (exit 1);; esac && git add --refresh -- foo &&
Signature · 1 line
1.7.1.251.g92a7
PATCH 1/1 t9700: Use Test::More->builder, not $Test::Builder::Test
In reply to Ævar Arnfjörð Bjarmason$Test::Builder::Test was only made into an `our' variable in 0.94 released in September 2009, older distros are more likely to have 0.92 or earlier. Use the singleton Test::More->builder constructor instead, the test now works on 0.92 too.
---
This patch fixes the TAP output in pu for older Test::More libraries. It could be applied as a fixup to "test-lib: Make the test_external_* functions TAP-aware", but it's probably useful to note this in the version history.
t/t9700/test.pl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
t/t9700/test.pl +4 -4
@@ -10,8 +10,8 @@ use Test::More qw(no_plan); BEGIN { # t9700-perl-git.sh kicks off our testing, so we have to go from # there. - $Test::Builder::Test->{Curr_Test} = 1; - $Test::Builder::Test->{No_Ending} = 1; + Test::More->builder->{Curr_Test} = 1; + Test::More->builder->{No_Ending} = 1; } use Cwd;
@@ -113,6 +113,6 @@ like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash'); my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.'); isnt($last_commit, $dir_commit, 'log . does not show last commit'); -printf "1..%d\n", $Test::Builder::Test->{Curr_Test}; +printf "1..%d\n", Test::More->builder->{Curr_Test}; -exit($Test::Builder::Test->{Is_Passing} ? 0 : 1); +exit(Test::More->builder->{Is_Passing} ? 0 : 1);
Signature · 1 line
1.7.1.251.g92a7
PATCH v2 1/1 t9700: Use Test::More->builder, not $Test::Builder::Test
$Test::Builder::Test was only made into an `our' variable in 0.94 released in September 2009, older distros are more likely to have 0.92 or earlier. Use the singleton Test::More->builder constructor instead.
The exit() call was also unportable to <0.94. Just output a meaningful exit code if the ->is_passing method exists. The t9700-perl-git.sh test only cares about stderr output, so this doesn't affect test results when using older Test::More modules.
---
The previous patch didn't take into account that the exit() call was also unportable. Oops.
t/t9700/test.pl | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
t/t9700/test.pl +5 -4
@@ -10,8 +10,8 @@ use Test::More qw(no_plan); BEGIN { # t9700-perl-git.sh kicks off our testing, so we have to go from # there. - $Test::Builder::Test->{Curr_Test} = 1; - $Test::Builder::Test->{No_Ending} = 1; + Test::More->builder->{Curr_Test} = 1; + Test::More->builder->{No_Ending} = 1; } use Cwd;
@@ -113,6 +113,7 @@ like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash'); my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.'); isnt($last_commit, $dir_commit, 'log . does not show last commit'); -printf "1..%d\n", $Test::Builder::Test->{Curr_Test}; +printf "1..%d\n", Test::More->builder->{Curr_Test}; -exit($Test::Builder::Test->{Is_Passing} ? 0 : 1); +my $is_passing = eval { Test::More->is_passing }; +exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;
Signature · 1 line
1.7.1.251.g92a7
Re: [PATCH v2] t9700: Use Test::More->builder, not $Test::Builder::Test
Quoted 3 lines · Ævar Arnfjörð Bjarmason
$Test::Builder::Test was only made into an `our' variable in 0.94 released in September 2009, older distros are more likely to have 0.92 or earlier. Use the singleton
Test::More->builderconstructor instead.
Ah, that is what it was. I was wondering what it was that showed 1..1 and then 1..40.
Thanks; will queue on top of ab/tap.