t/README: make the 'Skipping tests' section less confusing
PATCH 1/5 t/README: make the 'Skipping tests' section less confusing
I added this section in b5500d16cd ("t/README: Add a section about skipping tests", 2010-07-02), but apparently didn't notice that there was an existing "Skipping Tests" section added in fbd458a3f6 ("t/README: Add 'Skipping Tests' section below 'Running Tests'", 2008-06-20).
Then since 20873f45e7 ("t/README: Document the do's and don'ts of tests", 2010-07-02) and 0445e6f0a1 ("test-lib: '--run' to run only specific tests", 2014-04-30) we've started to refer to "Skipping tests" or "Skipping Tests" sections in prose elsewhere.
Let's clean up this confusion by renaming the section, and while we're at it improve the example. Usually we don't use the PERL prerequisite, and we should accurately describe why you'd want to use prerequisites, as opposed to GIT_SKIP_TESTS. So let's say "Tests that depend[...]" instead of "If you need to skip tests[...]" here.
--- t/README | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
t/README +11 -11
@@ -494,7 +494,7 @@ And here are the "don'ts:" The harness will catch this as a programming error of the test. Use test_done instead if you need to stop the tests early (see - "Skipping tests" below). + "Using test prerequisites" below). - Don't use '! git cmd' when you want to make sure the git command exits with failure in a controlled way by calling "die()". Instead,
@@ -587,28 +587,28 @@ And here are the "don'ts:" it'll complain if anything is amiss. -Skipping tests --------------- +Using test prerequisites +------------------------ -If you need to skip tests you should do so by using the three-arg form -of the test_* functions (see the "Test harness library" section -below), e.g.: +Tests that depend on something which may not be present on the system +should use the three-arg form of the test_* functions (see the "Test +harness library" section below), e.g.: - test_expect_success PERL 'I need Perl' ' - perl -e "hlagh() if unf_unf()" + test_expect_success SYMLINKS 'setup' ' + ln -s target link ' The advantage of skipping tests like this is that platforms that don't -have the PERL and other optional dependencies get an indication of how +have the SYMLINKS and other optional dependencies get an indication of how many tests they're missing. If the test code is too hairy for that (i.e. does a lot of setup work outside test assertions) you can also skip all remaining tests by setting skip_all and immediately call test_done: - if ! test_have_prereq PERL + if ! test_have_prereq SYMLINKS then - skip_all='skipping perl interface tests, perl not available' + skip_all="skipping symlink tests, the filesystem doesn't support it" test_done fi
Signature · 1 line
2.20.0.rc1.379.g1dd7ef354c
PATCH 2/5 t/README: modernize description of GIT_SKIP_TESTS
When the GIT_SKIP_TESTS documentation was added in fbd458a3f6 ("t/README: Add 'Skipping Tests' section below 'Running Tests'", 2008-06-20) there was no way to declare test prerequisites, that came later in a7bb394037 ("test-lib: Infrastructure to test and check for prerequisites", 2009-03-01).
The docs were newer updated, and have been saying that you might want to use GIT_SKIP_TESTS for a use-case which we'd never use them for, skipping tests because 'unzip' isn't there. For that we'd use the UNZIP prerequisite added in 552a26c8c0 ("Use prerequisites to skip tests that need unzip", 2009-03-16). Fix the docs accordingly.
--- t/README | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
t/README +8 -7
@@ -202,20 +202,21 @@ GIT_TEST_EXEC_PATH defaults to `$GIT_TEST_INSTALLED/git --exec-path`. Skipping Tests -------------- -In some environments, certain tests have no way of succeeding -due to platform limitation, such as lack of 'unzip' program, or -filesystem that do not allow arbitrary sequence of non-NUL bytes -as pathnames. +Certain tests may fail intermittently or entirely. These should +ideally be reported as bugs and fixed, or guarded by a prerequisite +(see "Using test prerequisites" below). But until then they can be +skipped. -You should be able to say something like +To skip tests, set the GIT_SKIP_TESTS variable. Individual tests can +be skipped: $ GIT_SKIP_TESTS=t9200.8 sh ./t9200-git-cvsexport-commit.sh -and even: +Or tests matching a glob: $ GIT_SKIP_TESTS='t[0-4]??? t91?? t9200.8' make -to omit such tests. The value of the environment variable is a +The value of the environment variable is a SP separated list of patterns that tells which tests to skip, and either can match the "t[0-9]{4}" part to skip the whole test, or t[0-9]{4} followed by ".$number" to say which
Signature · 1 line
2.20.0.rc1.379.g1dd7ef354c
PATCH 3/5 t/README: re-flow a paragraph
In reply to Ævar Arnfjörð BjarmasonAn earlier change changed this paragraph to make the first line quite short as to produce a more minimal diff. Let's re-flow it. There's no changes here if diffed with --word-diff.
--- t/README | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
t/README +4 -5
@@ -216,11 +216,10 @@ Or tests matching a glob: $ GIT_SKIP_TESTS='t[0-4]??? t91?? t9200.8' make -The value of the environment variable is a -SP separated list of patterns that tells which tests to skip, -and either can match the "t[0-9]{4}" part to skip the whole -test, or t[0-9]{4} followed by ".$number" to say which -particular test to skip. +The value of the environment variable is a SP separated list of +patterns that tells which tests to skip, and either can match the +"t[0-9]{4}" part to skip the whole test, or t[0-9]{4} followed by +".$number" to say which particular test to skip. For an individual test suite --run could be used to specify that only some tests should be run or that some tests should be
Signature · 1 line
2.20.0.rc1.379.g1dd7ef354c
PATCH 4/5 test-lib: add more exhaustive GIT_SKIP_TESTS testing
In reply to Ævar Arnfjörð BjarmasonAdd a test for the when GIT_SKIP_TESTS is used to skip entire test files. Support for this was added back in 04ece59399 ("GIT_SKIP_TESTS:
allow users to omit tests that are known to break", 2006-12-28), but never tested for.
--- t/t0000-basic.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
t/t0000-basic.sh +17 -0
@@ -393,6 +393,23 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' " ) " +test_expect_success 'GIT_SKIP_TESTS entire file' " + ( + GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS && + run_sub_test_lib_test git-skip-tests-entire-file \ + 'GIT_SKIP_TESTS' <<-\\EOF && + for i in 1 2 3 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-entire-file <<-\\EOF + 1..0 # SKIP skip all tests in git + EOF + ) +" + test_expect_success '--run basic' " run_sub_test_lib_test run-basic \ '--run basic' --run='1 3 5' <<-\\EOF &&
Signature · 1 line
2.20.0.rc1.379.g1dd7ef354c
PATCH 5/5 test-lib: add support for GIT_TODO_TESTS
In reply to Ævar Arnfjörð BjarmasonAs noted in the updated t/README documentation being added here setting this new GIT_TODO_TESTS variable is usually better than GIT_SKIP_TESTS.
My use-case for this is to get feedback from the CI infrastructure[1] about which tests are passing due to fixes that have trickled into git.git.
With the GIT_SKIP_TESTS variable this use-case is painful, you need to do an occasional manual run without GIT_SKIP_TESTS set. It's much better to use GIT_TODO_TESTS and get a report of passing TODO tests from prove(1) at the bottom of the test output. Once those passing TODO tests have trickled down to 'master' the relevant glob (set for all of master/next/pu) can be removed.
As seen in the "GIT_TODO_TESTS mixed failure" test the lack of interaction with existing tests marked as TODO by the test suite itself is intentional. There's no need to print out something saying they matched GIT_TODO_TESTS if they're already TODO tests.
1. https://public-inbox.org/git/[email protected]/
--- ci/lib-travisci.sh | 2 +- t/README | 18 +++++++++-- t/t0000-basic.sh | 81 +++++++++++++++++++++++++++++++++++++++------- t/test-lib.sh | 31 +++++++++++++++--- 4 files changed, 112 insertions(+), 20 deletions(-)
ci/lib-travisci.sh +1 -1
@@ -121,7 +121,7 @@ osx-clang|osx-gcc) # t9810 occasionally fails on Travis CI OS X # t9816 occasionally fails with "TAP out of sequence errors" on # Travis CI OS X - export GIT_SKIP_TESTS="t9810 t9816" + export GIT_TODO_TESTS="t9810 t9816" ;; GIT_TEST_GETTEXT_POISON) export GIT_TEST_GETTEXT_POISON=YesPlease
t/README +15 -3
@@ -207,8 +207,19 @@ ideally be reported as bugs and fixed, or guarded by a prerequisite (see "Using test prerequisites" below). But until then they can be skipped. -To skip tests, set the GIT_SKIP_TESTS variable. Individual tests can -be skipped: +To skip tests, set either the GIT_SKIP_TESTS or GIT_TODO_TESTS +variables. The difference is that with SKIP the tests won't be run at +all, whereas they will be run with TODO, but in success or failure +annotated as a TODO test. + +It's usually preferrable to use TODO, since the test suite will report +those tests that unexpectedly succeed, which may indicate that +whatever bug broke the test in the past has been fixed, and the test +should be un-TODO'd. There's no such feedback loop with +GIT_SKIP_TESTS. + +The GIT_SKIP_TESTS and GIT_TODO_TESTS take the same values. Individual +tests can be skipped: $ GIT_SKIP_TESTS=t9200.8 sh ./t9200-git-cvsexport-commit.sh
@@ -223,7 +234,8 @@ patterns that tells which tests to skip, and either can match the 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. +excluded from a run. The --run option is a shorthand for setting +a GIT_SKIP_TESTS pattern. The argument for --run is a list of individual test numbers or ranges with an optional negation prefix that define what tests in
t/t0000-basic.sh +69 -12
131 lines not on this page · raw message
t/test-lib.sh +27 -4
@@ -456,6 +456,8 @@ test_count=0 test_fixed=0 test_broken=0 test_success=0 +test_todo_success=0 +test_todo_failure=0 test_external_has_tap=0
@@ -482,13 +484,29 @@ trap 'exit $?' INT # the test_expect_* functions instead. test_ok_ () { + todo_blurb= + if match_pattern_list $this_test.$test_count $GIT_TODO_TESTS || + match_pattern_list $this_test $GIT_TODO_TESTS + then + todo_blurb=' # TODO (GIT_TODO_TESTS)' + test_todo_success=$(($test_todo_success + 1)) + fi test_success=$(($test_success + 1)) - say_color "" "ok $test_count - $@" + say_color "" "ok $test_count - $@$todo_blurb" } test_failure_ () { - test_failure=$(($test_failure + 1)) - say_color error "not ok $test_count - $1" + todo_blurb= + if match_pattern_list $this_test.$test_count $GIT_TODO_TESTS || + match_pattern_list $this_test $GIT_TODO_TESTS + then + test_success=$(($test_success + 1)) + test_todo_failure=$(($test_todo_failure + 1)) + todo_blurb=' # TODO (GIT_TODO_TESTS)' + else + test_failure=$(($test_failure + 1)) + fi + say_color error "not ok $test_count - $1$todo_blurb" shift printf '%s\n' "$*" | sed -e 's/^/# /' test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
@@ -845,13 +863,18 @@ test_done () { test_remaining=$test_count msg="$test_count test(s)" fi + msg_todo= + if test "$test_todo_success" != 0 || test "$test_todo_failure" != 0 + then + msg_todo=" (including $test_todo_success/$test_todo_failure ok/failing TODO test(s))" + fi case "$test_failure" in 0) if test $test_external_has_tap -eq 0 then if test $test_remaining -gt 0 then - say_color pass "# passed all $msg" + say_color pass "# passed all $msg$msg_todo" fi # Maybe print SKIP message
Signature · 1 line
2.20.0.rc1.379.g1dd7ef354c
Re: [PATCH 5/5] test-lib: add support for GIT_TODO_TESTS
t/README ideally be reported as bugs and fixed, or guarded by a prerequisite · line 213
Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/README +4
-2-To skip tests, set the GIT_SKIP_TESTS variable. Individual tests can -be skipped: +To skip tests, set either the GIT_SKIP_TESTS or GIT_TODO_TESTS +variables. The difference is that with SKIP the tests won't be run at +all, whereas they will be run with TODO, but in success or failure +annotated as a TODO test.
It is entirely unclear what "They will be run with TODO" means.
I know what you want to achieve from the code change; instead of just skipping, you want to cause as much side effect the skipped test piece wants to make until it fails and dies, without taking the remainder of the test down. And I kind of agree that sometimes such a mode would be very useful (i.e. when you do not want to bother separating such a failing test properly into the setup part that would affect later tests and the one-thing-it-wants-to-test part that can now be safely skipped). From the cursory look, the code change in this patch is sensible realization of that idea.
Having said all that, I won't picking this up until next month ;-) I really want to see that everybody is concentrating on making sure that 2.20 is solid before playing with shiny new toys.
Thanks.
Re: [PATCH 5/5] test-lib: add support for GIT_TODO_TESTS
In reply to Ævar Arnfjörð BjarmasonQuoted 3 lines · Ævar Arnfjörð Bjarmason
As noted in the updated t/README documentation being added here setting this new
GIT_TODO_TESTSvariable is usually better thanGIT_SKIP_TESTS.
I don't see why this is "usually better". I get how it can help your particular use-case described below, but that doesn't mean that it's "usually better".
Quoted 10 lines
My use-case for this is to get feedback from the CI infrastructure[1] about which tests are passing due to fixes that have trickled into git.git.
With the
GIT_SKIP_TESTSvariable this use-case is painful, you need to do an occasional manual run withoutGIT_SKIP_TESTSset. It's much better to useGIT_TODO_TESTSand get a report of passing TODO tests from prove(1) at the bottom of the test output. Once those passing TODO tests have trickled down to 'master' the relevant glob (set for all of master/next/pu) can be removed.
Neither from the commit message nor from the documentation is it clear to me what the result of 'make test' will be when a test listed in GIT_TODO_TESTS fails.
Quoted 20 lines
As seen in the "
GIT_TODO_TESTSmixed failure" test the lack of interaction with existing tests marked as TODO by the test suite itself is intentional. There's no need to print out something saying they matchedGIT_TODO_TESTSif they're already TODO tests.1. https://public-inbox.org/git/[email protected]/
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- ci/lib-travisci.sh | 2 +- t/README | 18 +++++++++-- t/t0000-basic.sh | 81 +++++++++++++++++++++++++++++++++++++++------- t/test-lib.sh | 31 +++++++++++++++--- 4 files changed, 112 insertions(+), 20 deletions(-)ci/lib-travisci.sh +0
-0
ci/lib-travisci.sh osx-clang|osx-gcc) · line 124
Quoted 5 lines
ci/lib-travisci.sh +1
-1@@ -121,7 +121,7 @@ osx-clang|osx-gcc) # t9810 occasionally fails on Travis CI OS X # t9816 occasionally fails with "TAP out of sequence errors" on # Travis CI OS X - export GIT_SKIP_TESTS="t9810 t9816" + export GIT_TODO_TESTS="t9810 t9816"
This change is not mentioned in the commit message.
As noted in the hunk's context, these test scripts are not skipped because they don't work on OSX at all, but because they are flaky. Consequently, reporting them as "maybe should be un-TODO'd" when they happen to succeed is pointless and will just lead to confusion, so this seems to be a case when GIT_TODO_TESTS is actually worse than GIT_SKIP_TESTS.
If a failing test in GIT_TODO_TESTS makes the whole 'make test' fail, then this should be most definitely left as GIT_SKIP_TESTS.
Quoted 8 lines
ci/lib-travisci.sh +0
-0;; GIT_TEST_GETTEXT_POISON) export GIT_TEST_GETTEXT_POISON=YesPleaset/README +0
-0
t/README ideally be reported as bugs and fixed, or guarded by a prerequisite · line 213
Quoted 9 lines
t/README +4
-2@@ -207,8 +207,19 @@ ideally be reported as bugs and fixed, or guarded by a prerequisite (see "Using test prerequisites" below). But until then they can be -To skip tests, set the GIT_SKIP_TESTS variable. Individual tests can -be skipped: +To skip tests, set either the GIT_SKIP_TESTS or GIT_TODO_TESTS +variables. The difference is that with SKIP the tests won't be run at +all, whereas they will be run with TODO, but in success or failure +annotated as a TODO test.
This is confusing. "To skip" a test means that the test is not run at all. Now, if GIT_TODO_TESTS were to run the listed tests, then it definitely won't skip them, so this sentence contradicts the previous one.
What does "annotated as a TODO test" mean? Something similar to how 'test_expect_failure' works?
Quoted 21 lines
t/README +10
-1+It's usually preferrable to use TODO, since the test suite will report +those tests that unexpectedly succeed, which may indicate that +whatever bug broke the test in the past has been fixed, and the test +should be un-TODO'd. There's no such feedback loop with +GIT_SKIP_TESTS. + +The GIT_SKIP_TESTS and GIT_TODO_TESTS take the same values. Individual +tests can be skipped: $ GIT_SKIP_TESTS=t9200.8 sh ./t9200-git-cvsexport-commit.sh@@ -223,7 +234,8 @@ patterns that tells which tests to skip, and either can match the 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. +excluded from a run. The --run option is a shorthand for setting +a GIT_SKIP_TESTS pattern. The argument for --run is a list of individual test numbers or ranges with an optional negation prefix that define what tests in