Better control of the tests run by a test suite
PATCH v3 1/1 Better control of the tests run by a test suite
This patches add --run option to the test suites to allow one to run individual tests out of the test suite. Like this:
./t0000-basic.sh --run='-4,7,9-12,15-'
Both spaces and commas are accepted as separators for the ranges (In previous versions only spaces were accepted).
Two previous versions are here:
[RFC/PATCH] Better control of the tests run by a test suite
http://www.mail-archive.com/[email protected]/msg46419.html
[RFC/PATCH v2] Better control of the tests run by a test suite
http://www.mail-archive.com/[email protected]/msg46877.html
In this version I have removed mathematical operators and used ranges as suggested by Junio[1] and Eric Sunshine[2].
[1] http://www.mail-archive.com/[email protected]/msg47098.html
[2] http://www.mail-archive.com/[email protected]/msg46960.html
This version also includes changes according to the comments from Eric Sunshine in the documentation. But as this version has slightly different documentation, it would be nice if someone would read it once again :)
Shell patterns are not allowed any more. I think they are not that useful and ranges cover almost the same functionality. Also with patterns like '[8-9]', it is harder to produce good error messages for invalid range ends.
This conversion is a bit unfinished:
Quoted 8 lines · Junio C Hamano
I would have to say that there is already an established pattern to pick ranges that normal people understand well and it would be silly to invent another more verbose way to express the same thing. You tell your Print Dialog which page to print with e.g. "-4,7,9-12,15-", not ">=4 7 ...".
Would the same notation be insufficient for our purpose? You do not even have to worry about negation that way.
http://www.mail-archive.com/[email protected]/msg47098.html
Negation was not necessary for my use cases even in the first version. I've added it more because it seemed to be very close to the functionality I was adding and not that complicated.
So, I've left the negation in the new version as well.
I am actually thinking now that --verbose-only= and --valgrind= could be switched to use the same syntax as in --run.
I also noticed that I am doing the following quite often:
./t0000-basic.sh --run=1-4,27 --verbose-only=27
Maybe it would be better to support 'v' suffix as a flag to indicate what a test needs to be run in verbose mode:
./t0000-basic.sh --run=1-4,27v
Ilya Bobyr (3):
test-lib: Document short options in t/README
test-lib: tests skipped by GIT_SKIP_TESTS say so
test-lib: '--run' to run only specific tests
t/README | 81 ++++++++++- t/t0000-basic.sh | 419 +++++++++++++++++++++++++++++++++++++++++++++++++++++- t/test-lib.sh | 120 +++++++++++++++- 3 files changed, 604 insertions(+), 16 deletions(-)
PATCH 1/3 test-lib: Document short options in t/README
Most arguments that could be provided to a test have short forms. Unless documented, the only way to learn them is to read the code.
--- t/README | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
t/README +4 -4
@@ -71,7 +71,7 @@ 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 appropriately before running "make". ---verbose:: +-v,--verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also output.
@@ -81,7 +81,7 @@ appropriately before running "make". numbers matching <pattern>. The number matched against is simply the running count of the test within the file. ---debug:: +-d,--debug:: This may help the person who is developing a new test. It causes the command defined with test_debug to run. The "trash" directory (used to store all temporary data
@@ -89,14 +89,14 @@ appropriately before running "make". failed tests so that you can inspect its contents after the test finished. ---immediate:: +-i,--immediate:: This causes the test to immediately exit upon the first failed test. Cleanup commands requested with test_when_finished are not executed if the test failed, in order to keep the state for inspection by the tester to diagnose the bug. ---long-tests:: +-l,--long-tests:: This causes additional long-running tests to be run (where available), for more exhaustive testing.
Signature · 1 line
1.7.9
Re: [PATCH 1/3] test-lib: Document short options in t/README
Quoted 13 lines · Ilya Bobyr
Most arguments that could be provided to a test have short forms. Unless documented, the only way to learn them is to read the code.
Signed-off-by Ilya Bobyr <[email protected]>--- t/README | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)t/README +0
-0
t/README You can pass --verbose (or -v), --debug (or -d), and --immediate · line 77
Quoted 8 lines
t/README +1
-1@@ -71,7 +71,7 @@ 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 appropriately before running "make". ---verbose:: +-v,--verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also output.
I was debating myself if the result should look more like this:
-v:: --verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also output.
As a straight text file, your version is certainly a lot easier to read, but at the same time, the entire file is written in more or less AsciiDoc format (the list of prerequisites and the list of harness library functions need to be converted to the "item::" form for the text to format well, though) and I've seen some efforts by others to run text files in Documentation/ that were originally meant to be consumed as straight text thru AsciiDoc, so the latter form might be a small step for futureproofing.
My conclusion at this point is that the original is good for the current need of the project; if somebody wants to include this file from somewhere in Documentation/technical, a conversion to use multiple "item1::<newline>item2::<newline>description" headers can be done by that person as part of the "make it fully AsciiDoc" effort.
Thanks.
Re: [PATCH 1/3] test-lib: Document short options in t/README
Quoted 39 lines · Junio C Hamano
Quoted 13 lines · Ilya Bobyr
Most arguments that could be provided to a test have short forms. Unless documented, the only way to learn them is to read the code.
Signed-off-by Ilya Bobyr <[email protected]>--- t/README | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)t/README +0
-0t/README You can pass --verbose (or -v), --debug (or -d), and --immediate · line 77
Quoted 8 lines
t/README +1
-1@@ -71,7 +71,7 @@ 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 appropriately before running "make". ---verbose:: +-v,--verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also output.I was debating myself if the result should look more like this:
-v:: --verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also output.As a straight text file, your version is certainly a lot easier to read, but at the same time, the entire file is written in more or less AsciiDoc format (the list of prerequisites and the list of harness library functions need to be converted to the "item::" form for the text to format well, though) and I've seen some efforts by others to run text files in
Documentation/that were originally meant to be consumed as straight text thru AsciiDoc, so the latter form might be a small step for futureproofing.
Quoted 8 lines
My conclusion at this point is that the original is good for the current need of the project; if somebody wants to include this file from somewhere in
Documentation/technical, a conversion to use multiple "item1::<newline>item2::<newline>description" headers can be done by that person as part of the "make it fully AsciiDoc" effort.Thanks.
I've changed it.
It is a trivial change and it does not seem to be that bad in plain text form either.
I do not know the AsciiDoc conventions as have not read its spec. If there are any other conventions I am breaking - let me know. I will read the spec if I will be contributing more to the documentation.
P.S. Sorry it takes me this long to reply %)
PATCH 2/3 test-lib: tests skipped by GIT_SKIP_TESTS say so
In reply to Ilya BobyrWe used to show "(missing )" next to tests skipped because they are specified in GIT_SKIP_TESTS. Use "(GIT_SKIP_TESTS)" instead.
Plus tests that check basic GIT_SKIP_TESTS functions.
--- t/t0000-basic.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ t/test-lib.sh | 13 ++++++---- 2 files changed, 71 insertions(+), 5 deletions(-)
t/t0000-basic.sh +63 -0
@@ -270,6 +270,69 @@ test_expect_success 'test --verbose-only' ' EOF ' +test_expect_success 'GIT_SKIP_TESTS' " + GIT_SKIP_TESTS='git.2' \ + run_sub_test_lib_test git-skip-tests-basic \ + '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-basic <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 - passing test #3 + > # passed all 3 test(s) + > 1..3 + EOF +" + +test_expect_success 'GIT_SKIP_TESTS several tests' " + GIT_SKIP_TESTS='git.2 git.5' \ + run_sub_test_lib_test git-skip-tests-several \ + 'GIT_SKIP_TESTS several tests' <<-\\EOF && + for i in 1 2 3 4 5 6 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-several <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 - passing test #3 + > ok 4 - passing test #4 + > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) + > ok 6 - passing test #6 + > # passed all 6 test(s) + > 1..6 + EOF +" + +test_expect_success 'GIT_SKIP_TESTS sh pattern' " + GIT_SKIP_TESTS='git.[2-5]' \ + run_sub_test_lib_test git-skip-tests-sh-pattern \ + 'GIT_SKIP_TESTS sh pattern' <<-\\EOF && + for i in 1 2 3 4 5 6 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 # skip passing test #3 (GIT_SKIP_TESTS) + > ok 4 # skip passing test #4 (GIT_SKIP_TESTS) + > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) + > ok 6 - passing test #6 + > # passed all 6 test(s) + > 1..6 + EOF +" + test_set_prereq HAVEIT haveit=no test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
t/test-lib.sh +8 -5
@@ -452,25 +452,28 @@ test_finish_ () { test_skip () { to_skip= + skipped_reason= if match_pattern_list $this_test.$test_count $GIT_SKIP_TESTS then to_skip=t + skipped_reason="GIT_SKIP_TESTS" fi if test -z "$to_skip" && test -n "$test_prereq" && ! test_have_prereq "$test_prereq" then to_skip=t - fi - case "$to_skip" in - t) + of_prereq= if test "$missing_prereq" != "$test_prereq" then of_prereq=" of $test_prereq" fi - + skipped_reason="missing $missing_prereq${of_prereq}" + fi + case "$to_skip" in + t) say_color skip >&3 "skipping test: $@" - say_color skip "ok $test_count # skip $1 (missing $missing_prereq${of_prereq})" + say_color skip "ok $test_count # skip $1 ($skipped_reason)" : true ;; *)
Signature · 1 line
1.7.9
PATCH 3/3 test-lib: '--run' to run only specific tests
In reply to Ilya BobyrAllow better control of the set of tests that will be executed for a single test suite. Mostly useful while debugging or developing as it allows to focus on a specific test.
--- t/README | 73 +++++++++++- t/t0000-basic.sh | 356 +++++++++++++++++++++++++++++++++++++++++++++++++++++- t/test-lib.sh | 109 +++++++++++++++++ 3 files changed, 530 insertions(+), 8 deletions(-)
t/README +69 -4
@@ -100,6 +100,11 @@ appropriately before running "make". This causes additional long-running tests to be run (where available), for more exhaustive testing. +-r,--run=<test-selector>:: + Run only the subset of tests indicated by + <test-selector>. See section "Skipping Tests" below for + <test-selector> syntax. + --valgrind=<tool>:: Execute all Git binaries under valgrind tool <tool> and exit with status 126 on errors (just like regular tests, this will
@@ -187,10 +192,70 @@ 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. -Note that some tests in the existing test suite rely on previous -test item, so you cannot arbitrarily disable one and expect the -remainder of test to check what the test originally was intended -to check. +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. + +If --run starts with an unprefixed number or range the initial +set of tests to run is empty. If the first item starts with '!' +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, 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' + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run=1,2,3,21 + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21' + +To run only tests up to a specific test (21), one could do this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-21' + +or this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-21' + +As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + +will run tests 1, 2, and 4. + +You may use negation with ranges. The following will run all +test as a test suite except from 7 upto 11: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11' + +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 +expect the rest to function correctly. +--run is mostly useful when you want to focus on a specific test +and know what you are doing. Or when you want to run up to a +certain test. Naming Tests
t/t0000-basic.sh +352 -4
383 lines not on this page · raw message
t/test-lib.sh +109 -0
127 lines not on this page · raw message
Signature · 1 line
1.7.9
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 10 lines · Ilya Bobyr
Allow better control of the set of tests that will be executed for a single test suite. Mostly useful while debugging or developing as it allows to focus on a specific test.
Signed-off-by Ilya Bobyr <[email protected]>---
t/README +0
-0
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 248
Quoted 9 lines
t/README +9
-0+As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + +will run tests 1, 2, and 4. + +You may use negation with ranges. The following will run all +test as a test suite except from 7 upto 11:
s/upto/up to/
...or...
s/upto/through/
Quoted 17 lines
t/README +9
-0+ $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11' + +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 +expect the rest to function correctly. +--run is mostly useful when you want to focus on a specific test +and know what you are doing. Or when you want to run up to a +certain test. Naming Testst/t0000-basic.sh +0
-0
t/t0000-basic.sh check_sub_test_lib_test () { · line 102
Quoted 6 lines
t/t0000-basic.sh +3
-0@@ -84,6 +97,18 @@ check_sub_test_lib_test () { ) } +check_sub_test_lib_test_err () { + name="$1" # stdin is the expected output output from the test + # expecte error output is in descriptor 3
s/expecte/expected/
Quoted 15 lines
t/t0000-basic.sh +11
-0+ ( + cd "$name" && + sed -e 's/^> //' -e 's/Z$//' >expect.out && + test_cmp expect.out out && + sed -e 's/^> //' -e 's/Z$//' <&3 >expect.err && + test_cmp expect.err err + ) +} + test_expect_success 'pretend we have a fully passing test suite' " run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF && for i in 1 2 3@@ -333,6 +358,329 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' " +test_expect_success '--run invalid range start' " + run_sub_test_lib_test_err run-inv-range-start \
t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 369
Quoted 10 lines
t/t0000-basic.sh +10
-0+ '--run invalid range start' \ + --run='a-5' <<-\\EOF && + test_expect_success \"passing test #1\" 'true' + test_done + EOF + check_sub_test_lib_test_err run-inv-range-start \ + <<-\\EOF_OUT 3<<-\\EOF_ERR + > FATAL: Unexpected exit with code 1 + EOF_OUT + > error: --run: range start should contain only digits: 'a-5'
This reads rather strangely, as if it's attempting to give an example (after the colon) of a valid digit range, but then shows something that is not valid. Rewording it slightly can eliminate the ambiguity:
error: --run: invalid non-numeric range start: 'a-5'
Quoted 5 lines
t/t0000-basic.sh +5
-0+ EOF_ERR +" + +test_expect_success '--run invalid range end' " + run_sub_test_lib_test_err run-inv-range-end \
t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 664
Quoted 10 lines
t/t0000-basic.sh +10
-0+ '--run invalid range end' \ + --run='1-z' <<-\\EOF && + test_expect_success \"passing test #1\" 'true' + test_done + EOF + check_sub_test_lib_test_err run-inv-range-end \ + <<-\\EOF_OUT 3<<-\\EOF_ERR + > FATAL: Unexpected exit with code 1 + EOF_OUT + > error: --run: range end should contain only digits: '1-z'
Ditto.
Quoted 5 lines
t/t0000-basic.sh +5
-0+ EOF_ERR +" + +test_expect_success '--run invalid selector' " + run_sub_test_lib_test_err run-inv-selector \
t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 679
Quoted 10 lines
t/t0000-basic.sh +10
-0+ '--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: test selector should contain only digits: '1?'
And here:
error: --run: invalid non-digit in range selector: '1?'
or something.
Quoted 15 lines
t/t0000-basic.sh +4
-0+ EOF_ERR +" + + test_set_prereq HAVEIT haveit=no test_expect_success HAVEIT 'test runs if prerequisite is satisfied' 't/test-lib.sh +0
-0@@ -366,6 +374,100 @@ match_pattern_list () { return 1 }
t/test-lib.sh match_pattern_list () { · line 386
Quoted 10 lines
t/test-lib.sh +10
-0+match_test_selector_list () { + title="$1" + shift + arg="$1" + shift + test -z "$1" && return 0 + + # Both commas and spaces are accepted as separators + OLDIFS=$IFS + IFS=' ,'
The comment mentions only space and comma, but the actual assigned IFS value also treats tabs as separators. Perhaps update the comment to say "commas and whitespace".
Quoted 4 lines
t/test-lib.sh +4
-0+ set -- $1 + IFS=$OLDIFS + + # If the first selector is negative we include by default.
t/test-lib.sh match_pattern_list () { · line 400
Quoted 10 lines
t/test-lib.sh +10
-0+ include= + case "$1" in + !*) include=t ;; + esac + + for selector + do + orig_selector=$selector + +
Unnecessary extra blank line.
Quoted 14 lines
t/test-lib.sh +14
-0+ positive=t + case "$selector" in + !*) + positive= + selector=${selector##?} + ;; + esac + + test -z "$selector" && continue + + case "$selector" in + *-*) + if expr "z${selector%%-*}" : "z[0-9]*[^0-9]" >/dev/null + then
t/test-lib.sh match_pattern_list () { · line 424
Quoted 10 lines
t/test-lib.sh +10
-0+ echo "error: $title: range start should contain only" \ + "digits: '$orig_selector'" >&2 + exit 1 + fi + if expr "z${selector#*-}" : "z[0-9]*[^0-9]" >/dev/null + then + echo "error: $title: range end should contain only" \ + "digits: '$orig_selector'" >&2 + exit 1 + fi
Weird ranges like "1-4-6" and "1-!5" will be caught by the "error:
range end" clause. Okay.
Quoted 20 lines
t/test-lib.sh +20
-0+ ;; + *) + if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null + then + echo "error: $title: test selector should contain" \ + "only digits: '$orig_selector'" >&2 + exit 1 + fi + esac + + # Short cut for "obvious" cases + test -z "$include" && test -z "$positive" && continue + test -n "$include" && test -n "$positive" && continue + + case "$selector" in + -*) + if test $arg -le ${selector#-} + then + include=$positive + fi
t/test-lib.sh match_pattern_list () { · line 454
Quoted 10 lines
t/test-lib.sh +10
-0+ ;; + *-) + if test $arg -ge ${selector%-} + then + include=$positive + fi + ;; + *-*) + if test ${selector%%-*} -le $arg \ + -a $arg -le ${selector#*-}
The -a option to 'test' is not portable [1] and is considered obsolete by POSIX [2]. Use "test foo && test bar" instead.
[1]: http://www.gnu.org/software/autoconf/manual/autoconf.html#index-g_t_0040command_007btest_007d-1793
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
Quoted 36 lines
t/test-lib.sh +23
-1+ then + include=$positive + fi + ;; + *) + if test $arg -eq $selector + then + include=$positive + fi + ;; + esac + done + + test -n "$include" +} + maybe_teardown_verbose () { test -z "$verbose_only" && return exec 4>/dev/null 3>/dev/null@@ -470,6 +572,13 @@ test_skip () { fi skipped_reason="missing $missing_prereq${of_prereq}" fi + if test -z "$to_skip" && test -n "$run_list" && + ! match_test_selector_list '--run' $test_count "$run_list" + then + to_skip=t + skipped_reason="--run" + fi + case "$to_skip" in t) say_color skip >&3 "skipping test: $@" --1.7.9
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 15 lines · Eric Sunshine
Quoted 14 lines · Ilya Bobyr
Allow better control of the set of tests that will be executed for a single test suite. Mostly useful while debugging or developing as it allows to focus on a specific test.
Signed-off-by Ilya Bobyr <[email protected]>---
t/README +4
-0+As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3'
Quoted 8 lines
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 248
Quoted 5 lines
t/README +5
-0+ +will run tests 1, 2, and 4. + +You may use negation with ranges. The following will run all +test as a test suite except from 7 upto 11:s/upto/up to/
...or...
s/upto/through/
Fixed. Thanks.
Quoted 20 lines
Quoted 20 lines
t/README +9
-0+ $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11' + +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 +expect the rest to function correctly. +--run is mostly useful when you want to focus on a specific test +and know what you are doing. Or when you want to run up to a +certain test. Naming Testst/t0000-basic.sh +0
-0@@ -84,6 +97,18 @@ check_sub_test_lib_test () { ) }
Quoted 4 lines
t/t0000-basic.sh check_sub_test_lib_test () {
Quoted 3 lines
t/t0000-basic.sh +3
-0+check_sub_test_lib_test_err () { + name="$1" # stdin is the expected output output from the test + # expecte error output is in descriptor 3s/expecte/expected/
Fixed.
Quoted 29 lines
Quoted 15 lines
t/t0000-basic.sh +11
-0+ ( + cd "$name" && + sed -e 's/^> //' -e 's/Z$//' >expect.out && + test_cmp expect.out out && + sed -e 's/^> //' -e 's/Z$//' <&3 >expect.err && + test_cmp expect.err err + ) +} + test_expect_success 'pretend we have a fully passing test suite' " run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF && for i in 1 2 3@@ -333,6 +358,329 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' " +test_expect_success '--run invalid range start' " + run_sub_test_lib_test_err run-inv-range-start \t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 369
Quoted 10 lines
t/t0000-basic.sh +10
-0+ '--run invalid range start' \ + --run='a-5' <<-\\EOF && + test_expect_success \"passing test #1\" 'true' + test_done + EOF + check_sub_test_lib_test_err run-inv-range-start \ + <<-\\EOF_OUT 3<<-\\EOF_ERR + > FATAL: Unexpected exit with code 1 + EOF_OUT + > error: --run: range start should contain only digits: 'a-5'This reads rather strangely, as if it's attempting to give an example (after the colon) of a valid digit range, but then shows something that is not valid. Rewording it slightly can eliminate the ambiguity:
Quoted 1 line
error: --run: invalid non-numeric range start: 'a-5'
Changed.
Quoted 8 lines
Quoted 8 lines
t/t0000-basic.sh +8
-0+ EOF_ERR +" + +test_expect_success '--run invalid range end' " + run_sub_test_lib_test_err run-inv-range-end \ + '--run invalid range end' \ + --run='1-z' <<-\\EOF && + test_expect_success \"passing test #1\" 'true'
Quoted 8 lines
t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 664
Quoted 7 lines
t/t0000-basic.sh +7
-0+ test_done + EOF + check_sub_test_lib_test_err run-inv-range-end \ + <<-\\EOF_OUT 3<<-\\EOF_ERR + > FATAL: Unexpected exit with code 1 + EOF_OUT + > error: --run: range end should contain only digits: '1-z'Ditto.
Fixed.
Quoted 17 lines
Quoted 5 lines
t/t0000-basic.sh +5
-0+ EOF_ERR +" + +test_expect_success '--run invalid selector' " + run_sub_test_lib_test_err run-inv-selector \t/t0000-basic.sh test_expect_success 'GIT_SKIP_TESTS sh pattern' " · line 679
Quoted 10 lines
t/t0000-basic.sh +10
-0+ '--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: test selector should contain only digits: '1?'And here:
Quoted 3 lines
error: --run: invalid non-digit in range selector: '1?'
or something.
Changed to "invalid non-digit in test selector". This one is only shown if it does not have a "-", so it is probably not a range.
Quoted 15 lines
Quoted 15 lines
t/t0000-basic.sh +4
-0+ EOF_ERR +" + + test_set_prereq HAVEIT haveit=no test_expect_success HAVEIT 'test runs if prerequisite is satisfied' 't/test-lib.sh +0
-0@@ -366,6 +374,100 @@ match_pattern_list () { return 1 }
Quoted 13 lines
t/test-lib.sh match_pattern_list () { · line 386
Quoted 10 lines
t/test-lib.sh +10
-0+match_test_selector_list () { + title="$1" + shift + arg="$1" + shift + test -z "$1" && return 0 + + # Both commas and spaces are accepted as separators + OLDIFS=$IFS + IFS=' ,'The comment mentions only space and comma, but the actual assigned IFS value also treats tabs as separators. Perhaps update the comment to say "commas and whitespace".
I thought that tab is a space character =) Changed it.
Quoted 7 lines
Quoted 7 lines
t/test-lib.sh +7
-0+ set -- $1 + IFS=$OLDIFS + + # If the first selector is negative we include by default. + include= + case "$1" in + !*) include=t ;;
Quoted 8 lines
t/test-lib.sh match_pattern_list () { · line 400
Quoted 7 lines
t/test-lib.sh +7
-0+ esac + + for selector + do + orig_selector=$selector + +Unnecessary extra blank line.
Thanks.
Quoted 34 lines
[...]
Quoted 20 lines
t/test-lib.sh +20
-0+ ;; + *) + if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null + then + echo "error: $title: test selector should contain" \ + "only digits: '$orig_selector'" >&2 + exit 1 + fi + esac + + # Short cut for "obvious" cases + test -z "$include" && test -z "$positive" && continue + test -n "$include" && test -n "$positive" && continue + + case "$selector" in + -*) + if test $arg -le ${selector#-} + then + include=$positive + fit/test-lib.sh match_pattern_list () { · line 454
Quoted 10 lines
t/test-lib.sh +10
-0+ ;; + *-) + if test $arg -ge ${selector%-} + then + include=$positive + fi + ;; + *-*) + if test ${selector%%-*} -le $arg \ + -a $arg -le ${selector#*-}The -a option to 'test' is not portable [1] and is considered obsolete by POSIX [2]. Use "test foo && test bar" instead.
Quoted 2 lines
[1]: http://www.gnu.org/software/autoconf/manual/autoconf.html#index-g_t_0040command_007btest_007d-1793
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
Did not know that. Thanks. Changed it.
It is used a number of times thought:
$ git grep '\<test\>.*-a\>' | wc -l 72
About 10 matches are accidental, but the rest are '-a' uses in 'test'.
Quoted 1 line
Quoted 1 line
[...]
Thanks a lot for looking into it :)
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
In reply to Ilya BobyrQuoted 34 lines · Ilya Bobyr
t/README +26
-4@@ -187,10 +192,70 @@ 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. -Note that some tests in the existing test suite rely on previous -test item, so you cannot arbitrarily disable one and expect the -remainder of test to check what the test originally was intended -to check. +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. + +If --run starts with an unprefixed number or range the initial +set of tests to run is empty. If the first item starts with '!' +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, common case is to run several setup tests (1, 2, 3) +and then a specific test (21) that relies on that setup:
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 230
Quoted 10 lines
t/README +10
-0+ + $ sh ./t9200-git-cvsexport-commit.sh --run='1 2 3 21' + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run=1,2,3,21 + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21'
Good and easily understandable examples.
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 238
Quoted 7 lines
t/README +7
-0+To run only tests up to a specific test (21), one could do this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-21' + +or this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-21'
These may be redundant, given that the reader would have to have grokked the earlier "-3 21" already at this point.
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 245
Quoted 6 lines
t/README +6
-0+As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + +will run tests 1, 2, and 4.
I do not quite understand what you mean by "left to right"; is that implementation detail necessary for the user of the feature, or is it talking about some limitation coming from the implementation? e.g. perhaps "!3 1-4" would not work as people would expect "do not run 3, but run tests from 1 thru 4 otherwise", and warning against having such an expectation that cannot be fulfilled?
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 250
Quoted 4 lines
t/README +4
-0+You may use negation with ranges. The following will run all +test as a test suite except from 7 upto 11: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11'
Hmm, that is somewhat counter-intuitive or at least ambiguous. I first thought you would be running everything but skipping 7 thru 11, but your explanation is that it is equivalent to "-6,8-11" (that is, to intersect set "-11" and set "!7").
The above two illustrate the reason rather well why I said it would be better to avoid negation because it would complicate the mental model the user needs to form when using the feature.
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 255
Quoted 4 lines
t/README +4
-0+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 +expect the rest to function correctly.
What this text (moved from the top of this hunk) tells the reader applies to both the traditional t0123.4 and the new "--run=1-3,5-" syntaxes, but the new placement of it make it sound as if it is only for skipping with "--run", especially because the text before this paragraph and also after this paragraph both apply only to "--run".
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 258
Quoted 3 lines
t/README +3
-0+--run is mostly useful when you want to focus on a specific test +and know what you are doing. Or when you want to run up to a +certain test.
Likewise for "and know what you are doing" part. I'd suggest dropping that phrase from here, and/or make it part of the "you cannot randomly omit and expect later ones to work" that covers both ways to skip tests.
Thanks.
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 48 lines · Junio C Hamano
Quoted 34 lines · Ilya Bobyr
t/README +26
-4@@ -187,10 +192,70 @@ 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. -Note that some tests in the existing test suite rely on previous -test item, so you cannot arbitrarily disable one and expect the -remainder of test to check what the test originally was intended -to check. +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. + +If --run starts with an unprefixed number or range the initial +set of tests to run is empty. If the first item starts with '!' +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, common case is to run several setup tests (1, 2, 3) +and then a specific test (21) that relies on that setup:t/README and either can match the "t[0-9]{4}" part to skip the whole · line 230
Quoted 10 lines
t/README +10
-0+ + $ sh ./t9200-git-cvsexport-commit.sh --run='1 2 3 21' + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run=1,2,3,21 + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21'Good and easily understandable examples.
Quoted 9 lines
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 238
Quoted 7 lines
t/README +7
-0+To run only tests up to a specific test (21), one could do this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-21' + +or this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-21'These may be redundant, given that the reader would have to have grokked the earlier "-3 21" already at this point.
The original idea was to show two most common use cases in the examples, so that one could just copy/paste it.
I guess you are right that the second is a bit redundant now from the standpoint of a person who is reading all of it.
I have reordered the examples. Single range is simpler, it comes first and then a more complicated example.
Quoted 4 lines
Quoted 4 lines
t/README +4
-0+As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3'
Quoted 8 lines
Review and either can match the "t[0-9]{4}" part to skip the whole · line 243
Quoted 2 lines
(quoted diff) +2
-0+ +will run tests 1, 2, and 4.I do not quite understand what you mean by "left to right"; is that implementation detail necessary for the user of the feature, or is it talking about some limitation coming from the implementation? e.g. perhaps "!3 1-4" would not work as people would expect "do not run 3, but run tests from 1 thru 4 otherwise", and warning against having such an expectation that cannot be fulfilled?
I thought that it is something that you may want to understand if you are going to build something complicated. As I do not have a specific use case, this is kind of a made up example.
The idea is that what is on the right overwrites what is on the left. I've added that sentence as an additional clarification, and your example.
Quoted 8 lines
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 250
Quoted 4 lines
t/README +4
-0+You may use negation with ranges. The following will run all +test as a test suite except from 7 upto 11: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11'Hmm, that is somewhat counter-intuitive or at least ambiguous. I first thought you would be running everything but skipping 7 thru 11, but your explanation is that it is equivalent to "-6,8-11" (that is, to intersect set "-11" and set "!7").
Your expectation is correct.
A space or a comma is needed in order for "!7" and "-11" to be treated separately.
I am not sure why did you read the description as "-6,8-11". There is a typo in the sentence: s/as a/in the/.
I've changed that, but I would not object a better explanation of cause :)
Quoted 3 lines
The above two illustrate the reason rather well why I said it would be better to avoid negation because it would complicate the mental model the user needs to form when using the feature.
I think that you do not have to use it if you do not need it. It adds some expressiveness, is rather easy to implement and is already there :)
I can remove it, of cause, but is it really necessary?
Quoted 9 lines
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 255
Quoted 4 lines
t/README +4
-0+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 +expect the rest to function correctly.What this text (moved from the top of this hunk) tells the reader applies to both the traditional t0123.4 and the new "--run=1-3,5-" syntaxes, but the new placement of it make it sound as if it is only for skipping with "--run", especially because the text before this paragraph and also after this paragraph both apply only to "--run".
True, but there is another paragraph at the beginning of the section that talks why would you want to use GIT_SKIP_TESTS:
Quoted 4 lines
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.
I was thinking that if you would be working with individual test suits you would use '--run'.
And this is where you more likely to think about setup tests. I could move that paragraph just after the GIT_SKIP_TESTS description. Then it would apply more to both.
I am not sure it is needed. Let me know if you think otherwise.
Quoted 7 lines
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 258
Quoted 3 lines
t/README +3
-0+--run is mostly useful when you want to focus on a specific test +and know what you are doing. Or when you want to run up to a +certain test.Likewise for "and know what you are doing" part. I'd suggest dropping that phrase from here, and/or make it part of the "you cannot randomly omit and expect later ones to work" that covers both ways to skip tests.
I've made this part a bit less wage.
Thank you for reviewing it :)
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 8 lines · Ilya Bobyr
Quoted 3 lines
The above two illustrate the reason rather well why I said it would be better to avoid negation because it would complicate the mental model the user needs to form when using the feature.
I think that you do not have to use it if you do not need it. It adds some expressiveness, is rather easy to implement and is already there :)
I can remove it, of cause, but is it really necessary?
An extra "expressiveness" that needs explanation and careful thinking on the part of the user to pick the same world model you picked among multiple valid world models is not necessarily a good addition, so none of "you do not have to use it", "it's already there", "it is easy to implement" is a valid argument.
If it weren't there, I wouldn't have had to wonder what the notation meant, you wouldn't have had to explain it to me, and the most importantly, nobody has to learn there is a subtle distinction between "!7 -11", "!7-11" and "!7- 11".
PATCH v4 1/1 Better control of the tests run by a test suite
In reply to Ilya BobyrThis patches add --run option to the test suites to allow one to run individual tests out of the test suite. Like this:
./t0000-basic.sh --run='-4,7,9-12,15-'
Previous version:
[RFC/PATCH v3] Better control of the tests run by a test suite
http://www.mail-archive.com/[email protected]/msg48304.html
This version addresses comments by Junio[1] and Eric Sunshine[2]. I think that they are mostly minor changes.
[1] http://www.mail-archive.com/[email protected]/msg48454.html
http://www.mail-archive.com/[email protected]/msg48455.html
[2] http://www.mail-archive.com/[email protected]/msg48463.html
I've replied to those messages. There are two comments from Junio that did not result in changed. All the others have been addressed I hope.
Ilya Bobyr (3):
test-lib: Document short options in t/README
test-lib: tests skipped by GIT_SKIP_TESTS say so
test-lib: '--run' to run only specific tests
t/README | 85 +++++++++++- t/t0000-basic.sh | 419 +++++++++++++++++++++++++++++++++++++++++++++++++++++- t/test-lib.sh | 119 +++++++++++++++- 3 files changed, 611 insertions(+), 12 deletions(-)
PATCH 1/3 test-lib: Document short options in t/README
Most arguments that could be provided to a test have short forms. Unless documented, the only way to learn them is to read the code.
---
Changed to use AsciiDoc format.
t/README | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
t/README +4 -0
@@ -71,6 +71,7 @@ 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 appropriately before running "make". +-v:: --verbose:: This makes the test more verbose. Specifically, the command being run and their output if any are also
@@ -81,6 +82,7 @@ appropriately before running "make". numbers matching <pattern>. The number matched against is simply the running count of the test within the file. +-d:: --debug:: This may help the person who is developing a new test. It causes the command defined with test_debug to run.
@@ -89,6 +91,7 @@ appropriately before running "make". failed tests so that you can inspect its contents after the test finished. +-i:: --immediate:: This causes the test to immediately exit upon the first failed test. Cleanup commands requested with
@@ -96,6 +99,7 @@ appropriately before running "make". in order to keep the state for inspection by the tester to diagnose the bug. +-l:: --long-tests:: This causes additional long-running tests to be run (where available), for more exhaustive testing.
Signature · 1 line
1.7.9
PATCH 2/3 test-lib: tests skipped by GIT_SKIP_TESTS say so
In reply to Ilya BobyrWe used to show "(missing )" next to tests skipped because they are specified in GIT_SKIP_TESTS. Use "(GIT_SKIP_TESTS)" instead.
Plus tests that check basic GIT_SKIP_TESTS functions.
---
No changes.
t/t0000-basic.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ t/test-lib.sh | 13 ++++++---- 2 files changed, 71 insertions(+), 5 deletions(-)
t/t0000-basic.sh +63 -0
@@ -270,6 +270,69 @@ test_expect_success 'test --verbose-only' ' EOF ' +test_expect_success 'GIT_SKIP_TESTS' " + GIT_SKIP_TESTS='git.2' \ + run_sub_test_lib_test git-skip-tests-basic \ + '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-basic <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 - passing test #3 + > # passed all 3 test(s) + > 1..3 + EOF +" + +test_expect_success 'GIT_SKIP_TESTS several tests' " + GIT_SKIP_TESTS='git.2 git.5' \ + run_sub_test_lib_test git-skip-tests-several \ + 'GIT_SKIP_TESTS several tests' <<-\\EOF && + for i in 1 2 3 4 5 6 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-several <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 - passing test #3 + > ok 4 - passing test #4 + > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) + > ok 6 - passing test #6 + > # passed all 6 test(s) + > 1..6 + EOF +" + +test_expect_success 'GIT_SKIP_TESTS sh pattern' " + GIT_SKIP_TESTS='git.[2-5]' \ + run_sub_test_lib_test git-skip-tests-sh-pattern \ + 'GIT_SKIP_TESTS sh pattern' <<-\\EOF && + for i in 1 2 3 4 5 6 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF + > ok 1 - passing test #1 + > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) + > ok 3 # skip passing test #3 (GIT_SKIP_TESTS) + > ok 4 # skip passing test #4 (GIT_SKIP_TESTS) + > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) + > ok 6 - passing test #6 + > # passed all 6 test(s) + > 1..6 + EOF +" + test_set_prereq HAVEIT haveit=no test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
t/test-lib.sh +8 -5
@@ -452,25 +452,28 @@ test_finish_ () { test_skip () { to_skip= + skipped_reason= if match_pattern_list $this_test.$test_count $GIT_SKIP_TESTS then to_skip=t + skipped_reason="GIT_SKIP_TESTS" fi if test -z "$to_skip" && test -n "$test_prereq" && ! test_have_prereq "$test_prereq" then to_skip=t - fi - case "$to_skip" in - t) + of_prereq= if test "$missing_prereq" != "$test_prereq" then of_prereq=" of $test_prereq" fi - + skipped_reason="missing $missing_prereq${of_prereq}" + fi + case "$to_skip" in + t) say_color skip >&3 "skipping test: $@" - say_color skip "ok $test_count # skip $1 (missing $missing_prereq${of_prereq})" + say_color skip "ok $test_count # skip $1 ($skipped_reason)" : true ;; *)
Signature · 1 line
1.7.9
PATCH 3/3 test-lib: '--run' to run only specific tests
In reply to Ilya BobyrAllow better control of the set of tests that will be executed for a single test suite. Mostly useful while debugging or developing as it allows to focus on a specific test.
---
A number of minor changes according to the review comments.
t/README | 81 ++++++++++++- t/t0000-basic.sh | 356 +++++++++++++++++++++++++++++++++++++++++++++++++++++- t/test-lib.sh | 108 ++++++++++++++++ 3 files changed, 537 insertions(+), 8 deletions(-)
t/README +77 -4
@@ -104,6 +104,12 @@ appropriately before running "make". This causes additional long-running tests to be run (where available), for more exhaustive testing. +-r:: +--run=<test-selector>:: + Run only the subset of tests indicated by + <test-selector>. See section "Skipping Tests" below for + <test-selector> syntax. + --valgrind=<tool>:: Execute all Git binaries under valgrind tool <tool> and exit with status 126 on errors (just like regular tests, this will
@@ -191,10 +197,77 @@ 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. -Note that some tests in the existing test suite rely on previous -test item, so you cannot arbitrarily disable one and expect the -remainder of test to check what the test originally was intended -to check. +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. + +If --run starts with an unprefixed number or range the initial +set of tests to run is empty. If the first item starts with '!' +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: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-21' + +or this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-21' + +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' + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run=1,2,3,21 + +or: + + $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21' + +As noted above, the test set is built going though items left to +right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + +will run tests 1, 2, and 4. Items that comes later have higher +precendence. It means that this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!3 1-4' + +would just run tests from 1 to 4, including 3. + +You may use negation with ranges. The following will run all +test in the test suite except from 7 up to 11: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11' + +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 +expect the rest to function correctly. + +--run is mostly useful when you want to focus on a specific test +and know what setup is needed for it. Or when you want to run +everything up to a certain test. Naming Tests
t/t0000-basic.sh +352 -4
383 lines not on this page · raw message
t/test-lib.sh +108 -0
126 lines not on this page · raw message
Signature · 1 line
1.7.9
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 7 lines · Ilya Bobyr
Allow better control of the set of tests that will be executed for a single test suite. Mostly useful while debugging or developing as it allows to focus on a specific test.
Signed-off-by Ilya Bobyr <[email protected]>---
A number of minor changes according to the review comments.
I think the interaction between multiple selectors, especially when some of them are negated, are much better explained in this version, compared to the previous round in the README.
But I still think that the negation a feature that is unnecessary and having it makes it harder to understand for users, especially after reading this part:
Quoted 7 lines
t/README +6
-0+If --run starts with an unprefixed number or range the initial +set of tests to run is empty. If the first item starts with '!' +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. +As noted above, the test set is built going though items left to
t/README and either can match the "t[0-9]{4}" part to skip the whole · line 256
Quoted 10 lines
t/README +10
-0+right, so this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + +will run tests 1, 2, and 4. Items that comes later have higher +precendence. It means that this: + + $ sh ./t9200-git-cvsexport-commit.sh --run='!3 1-4' + +would just run tests from 1 to 4, including 3.
The initial !3 means the same thing as "1-2,4-", and then 1-4 will do what to that set? The answer is "It is added"... wouldn't the reader expect then that the result should be "1-", not "1-4"? I myself wondered what would happen to the fifth test from your description. Has the text told the reader that t9200 test has only four tests?
The need to explain better with longer description will reduce the likelyhood that the feature is understood and correctly used. When you can write "1-2,4-", why accept "1-4 !3" and force yourself to explain to people why that is different from "!3 1-4"?
Re: [PATCH 3/3] test-lib: '--run' to run only specific tests
Quoted 4 lines · Junio C Hamano
The need to explain better with longer description will reduce the likelyhood that the feature is understood and correctly used. When you can write "1-2,4-", why accept "1-4 !3" and force yourself to explain to people why that is different from "!3 1-4"?
By the way, having said all that, I would understand if the result is made not depend on the order of selectors given to the option.
That is:
- Find all the positive ones and form the "positive" set; if there is no positive ones, then make the "positive" set include everything.
- Find all the negative ones and form a "negative" set. The "negative" set can be an empty set if there is no negative selector.
- Subtract the "negative" set from the "positive" set, and run only the tests in the resulting set.
Then "1-4 !3" and "!3 1-4" would mean the same thing. Explanation of the semantics would be far simpler than "we do it from left to right".
One reason why the orders shouldn't matter is, unlike the "print dialog" case, we won't run tests out of order when given "1 4 3 2". We will still run "1-4". So it would be natural for the readers to expect that the orders they give selectors would not matter.