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/git@vger.kernel.org/msg46419.html
[RFC/PATCH v2] Better control of the tests run by a test suite
http://www.mail-archive.com/git@vger.kernel.org/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/git@vger.kernel.org/msg47098.html
[2] http://www.mail-archive.com/git@vger.kernel.org/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:
On 3/31/2014 10:09 AM, Junio C Hamano wrote:
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/git@vger.kernel.org/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(-)
We 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.
Signed-off-by: Ilya Bobyr <redacted>
---
t/t0000-basic.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh | 13 ++++++----
2 files changed, 71 insertions(+), 5 deletions(-)
@@ -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_testgit-skip-tests-basic\+'GIT_SKIP_TESTS'<<-\\EOF&&+foriin123+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-basic<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3-passingtest#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_testgit-skip-tests-several\+'GIT_SKIP_TESTS several tests'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-several<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3-passingtest#3+>ok4-passingtest#4+>ok5# skip passing test #5 (GIT_SKIP_TESTS)+>ok6-passingtest#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_testgit-skip-tests-sh-pattern\+'GIT_SKIP_TESTS sh pattern'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-sh-pattern<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3# skip passing test #3 (GIT_SKIP_TESTS)+>ok4# skip passing test #4 (GIT_SKIP_TESTS)+>ok5# skip passing test #5 (GIT_SKIP_TESTS)+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"+ test_set_prereqHAVEIThaveit=no test_expect_successHAVEIT'test runs if prerequisite is satisfied''
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 <redacted>
---
t/README | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
@@ -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.
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 <redacted>
---
t/README | 73 +++++++++++-
t/t0000-basic.sh | 356 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
t/test-lib.sh | 109 +++++++++++++++++
3 files changed, 530 insertions(+), 8 deletions(-)
@@ -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
@@ -42,9 +42,9 @@ test_expect_success 'success is reported like this' ':'-run_sub_test_lib_test(){-name="$1"descr="$2"# stdin is the body of the test code-shift2+_run_sub_test_lib_test_common(){+neg="$1"name="$2"descr="$3"# stdin is the body of the test code+shift3mkdir"$name"&&(# Pretend we're not running under a test harness, whether we
@@ -70,10 +70,23 @@ run_sub_test_lib_test () {exportTEST_DIRECTORY&&TEST_OUTPUT_DIRECTORY=$(pwd)&&exportTEST_OUTPUT_DIRECTORY&&-./"$name.sh""$@">out2>err+iftest-z"$neg"+then+./"$name.sh""$@">out2>err+else+!./"$name.sh""$@">out2>err+fi)}+run_sub_test_lib_test(){+_run_sub_test_lib_test_common''"$@"+}++run_sub_test_lib_test_err(){+_run_sub_test_lib_test_common'!'"$@"+}+ check_sub_test_lib_test(){name="$1"# stdin is the expected output from the test(
@@ -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 descriptior 3+(+cd"$name"&&+sed-e's/^> //'-e's/Z$//'>expect.out&&+test_cmpexpect.outout&&+sed-e's/^> //'-e's/Z$//'<&3>expect.err&&+test_cmpexpect.errerr+)+}+ test_expect_success'pretend we have a fully passing test suite'"run_sub_test_lib_testfull-pass'3 passing tests'<<-\\EOF&&foriin123
@@ -333,6 +358,329 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "EOF"+test_expect_success'--run basic'"+run_sub_test_lib_testrun-basic\+'--run basic'--run='1 3 5'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-basic<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a range'"+run_sub_test_lib_testrun-range\+'--run with a range'--run='1-3'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with two ranges'"+run_sub_test_lib_testrun-two-ranges\+'--run with two ranges'--run='1-2 5-6'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-two-ranges<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a left open range'"+run_sub_test_lib_testrun-left-open-range\+'--run with a left open range'--run='-3'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-left-open-range<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a right open range'"+run_sub_test_lib_testrun-right-open-range\+'--run with a right open range'--run='4-'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-right-open-range<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2# skip passing test #2 (--run)+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with basic negation'"+run_sub_test_lib_testrun-basic-neg\+'--run with basic negation'--run='"'!3'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-basic-neg<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with two negations'"+run_sub_test_lib_testrun-two-neg\+'--run with two negations'--run='"'!3!6'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-two-neg<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run a range and negation'"+run_sub_test_lib_testrun-range-and-neg\+'--run a range and negation'--run='"'-4!2'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range-and-neg<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4-passingtest#4+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run range negation'"+run_sub_test_lib_testrun-range-neg\+'--run range negation'--run='"'!1-3'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range-neg<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2# skip passing test #2 (--run)+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run include, exclude and include'"+run_sub_test_lib_testrun-inc-neg-inc\+'--run include, exclude and include'\+--run='"'1-5!1-32'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-inc-neg-inc<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run include, exclude and include, comma separated'"+run_sub_test_lib_testrun-inc-neg-inc-comma\+'--run include, exclude and include, comma separated'\+--run=1-5,\!1-3,2<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-inc-neg-inc-comma<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run exclude and include'"+run_sub_test_lib_testrun-neg-inc\+'--run exclude and include'\+--run='"'!3-5'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-neg-inc<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run empty selectors'"+run_sub_test_lib_testrun-empty-sel\+'--run empty selectors'\+--run='1,,3,,,5'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-empty-sel<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run invalid range start'"+run_sub_test_lib_test_errrun-inv-range-start\+'--run invalid range start'\+--run='a-5'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-range-start\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:rangestartshouldcontainonlydigits:'a-5'+EOF_ERR+"++test_expect_success'--run invalid range end'"+run_sub_test_lib_test_errrun-inv-range-end\+'--run invalid range end'\+--run='1-z'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-range-end\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:rangeendshouldcontainonlydigits:'1-z'+EOF_ERR+"++test_expect_success'--run invalid selector'"+run_sub_test_lib_test_errrun-inv-selector\+'--run invalid selector'\+--run='1?'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-selector\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:testselectorshouldcontainonlydigits:'1?'+EOF_ERR+"++ test_set_prereqHAVEIThaveit=no test_expect_successHAVEIT'test runs if prerequisite is satisfied''
@@ -191,6 +191,14 @@ doimmediate=t;shift;;-l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)GIT_TEST_LONG=t;exportGIT_TEST_LONG;shift;;+-r)+shift;test"$#"-ne0||{+echo'error: -r requires an argument'>&2;+exit1;+}+run_list=$1;shift;;+--run=*)+run_list=$(expr"z$1":'z[^=]*=\(.*\)');shift;;-h|--h|--he|--hel|--help)help=t;shift;;-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
@@ -366,6 +374,100 @@ match_pattern_list () {return1}+match_test_selector_list(){+title="$1"+shift+arg="$1"+shift+test-z"$1"&&return0++# Both commas and spaces are accepted as separators+OLDIFS=$IFS+IFS=' ,'+set--$1+IFS=$OLDIFS++# If the first selector is negative we include by default.+include=+case"$1"in+!*)include=t;;+esac++forselector+do+orig_selector=$selector+++positive=t+case"$selector"in+!*)+positive=+selector=${selector##?}+;;+esac++test-z"$selector"&&continue++case"$selector"in+*-*)+ifexpr"z${selector%%-*}":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: range start should contain only"\+"digits: '$orig_selector'">&2+exit1+fi+ifexpr"z${selector#*-}":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: range end should contain only"\+"digits: '$orig_selector'">&2+exit1+fi+;;+*)+ifexpr"z$selector":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: test selector should contain"\+"only digits: '$orig_selector'">&2+exit1+fi+esac++# Short cut for "obvious" cases+test-z"$include"&&test-z"$positive"&&continue+test-n"$include"&&test-n"$positive"&&continue++case"$selector"in+-*)+iftest$arg-le${selector#-}+then+include=$positive+fi+;;+*-)+iftest$arg-ge${selector%-}+then+include=$positive+fi+;;+*-*)+iftest${selector%%-*}-le$arg\+-a$arg-le${selector#*-}+then+include=$positive+fi+;;+*)+iftest$arg-eq$selector+then+include=$positive+fi+;;+esac+done++test-n"$include"+}+ maybe_teardown_verbose(){test-z"$verbose_only"&&returnexec4>/dev/null3>/dev/null
From: Eric Sunshine <hidden> Date: 2016-06-15 23:00:48
On Tue, Apr 22, 2014 at 4:19 AM, Ilya Bobyr [off-list ref] wrote:
quoted hunk
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 <redacted>
---
diff --git a/t/README b/t/READMEindex 6b93aca..2dac619 100644--- a/t/README+++ b/t/README
+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 hunk
+ $ 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
@@ -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 hunk
+ (
+ 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 \+ '--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'
+ 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'
+ 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'
@@ -366,6 +374,100 @@ match_pattern_list () {return1}+match_test_selector_list(){+title="$1"+shift+arg="$1"+shift+test-z"$1"&&return0++# 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".
+ set -- $1
+ IFS=$OLDIFS
+
+ # If the first selector is negative we include by default.
+ include=
+ case "$1" in
+ !*) include=t ;;
+ esac
+
+ for selector
+ do
+ orig_selector=$selector
+
+
Unnecessary extra blank line.
+ 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
+ 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.
+ ;;
+ *)
+ 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
+ ;;
+ *-)
+ if test $arg -ge ${selector%-}
+ then
+ include=$positive
+ fi
+ ;;
+ *-*)
+ if test ${selector%%-*} -le $arg \
+ -a $arg -le ${selector#*-}
On Tue, Apr 22, 2014 at 4:19 AM, Ilya Bobyr [off-list ref] wrote:
quoted
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 <redacted>
---
diff --git a/t/README b/t/READMEindex 6b93aca..2dac619 100644--- a/t/README+++ b/t/README
+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/
Fixed. Thanks.
quoted
+ $ 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
@@ -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/
Fixed.
quoted
+ (
+ 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 \+ '--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'
Changed.
quoted
+ 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'
+ 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'
@@ -366,6 +374,100 @@ match_pattern_list () {return1}+match_test_selector_list(){+title="$1"+shift+arg="$1"+shift+test-z"$1"&&return0++# 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
+ set -- $1
+ IFS=$OLDIFS
+
+ # If the first selector is negative we include by default.
+ include=
+ case "$1" in
+ !*) include=t ;;
+ esac
+
+ for selector
+ do
+ orig_selector=$selector
+
+
Unnecessary extra blank line.
Thanks.
[...]
quoted
+ ;;
+ *)
+ 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
+ ;;
+ *-)
+ if test $arg -ge ${selector%-}
+ then
+ include=$positive
+ fi
+ ;;
+ *-*)
+ if test ${selector%%-*} -le $arg \
+ -a $arg -le ${selector#*-}
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'.
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 <redacted>
---
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(-)
@@ -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
@@ -42,9 +42,9 @@ test_expect_success 'success is reported like this' ':'-run_sub_test_lib_test(){-name="$1"descr="$2"# stdin is the body of the test code-shift2+_run_sub_test_lib_test_common(){+neg="$1"name="$2"descr="$3"# stdin is the body of the test code+shift3mkdir"$name"&&(# Pretend we're not running under a test harness, whether we
@@ -70,10 +70,23 @@ run_sub_test_lib_test () {exportTEST_DIRECTORY&&TEST_OUTPUT_DIRECTORY=$(pwd)&&exportTEST_OUTPUT_DIRECTORY&&-./"$name.sh""$@">out2>err+iftest-z"$neg"+then+./"$name.sh""$@">out2>err+else+!./"$name.sh""$@">out2>err+fi)}+run_sub_test_lib_test(){+_run_sub_test_lib_test_common''"$@"+}++run_sub_test_lib_test_err(){+_run_sub_test_lib_test_common'!'"$@"+}+ check_sub_test_lib_test(){name="$1"# stdin is the expected output from the test(
@@ -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+# expected error output is in descriptior 3+(+cd"$name"&&+sed-e's/^> //'-e's/Z$//'>expect.out&&+test_cmpexpect.outout&&+sed-e's/^> //'-e's/Z$//'<&3>expect.err&&+test_cmpexpect.errerr+)+}+ test_expect_success'pretend we have a fully passing test suite'"run_sub_test_lib_testfull-pass'3 passing tests'<<-\\EOF&&foriin123
@@ -333,6 +358,329 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "EOF"+test_expect_success'--run basic'"+run_sub_test_lib_testrun-basic\+'--run basic'--run='1 3 5'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-basic<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a range'"+run_sub_test_lib_testrun-range\+'--run with a range'--run='1-3'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with two ranges'"+run_sub_test_lib_testrun-two-ranges\+'--run with two ranges'--run='1-2 5-6'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-two-ranges<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a left open range'"+run_sub_test_lib_testrun-left-open-range\+'--run with a left open range'--run='-3'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-left-open-range<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with a right open range'"+run_sub_test_lib_testrun-right-open-range\+'--run with a right open range'--run='4-'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-right-open-range<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2# skip passing test #2 (--run)+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with basic negation'"+run_sub_test_lib_testrun-basic-neg\+'--run with basic negation'--run='"'!3'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-basic-neg<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run with two negations'"+run_sub_test_lib_testrun-two-neg\+'--run with two negations'--run='"'!3!6'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-two-neg<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run a range and negation'"+run_sub_test_lib_testrun-range-and-neg\+'--run a range and negation'--run='"'-4!2'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range-and-neg<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4-passingtest#4+>ok5# skip passing test #5 (--run)+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run range negation'"+run_sub_test_lib_testrun-range-neg\+'--run range negation'--run='"'!1-3'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-range-neg<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2# skip passing test #2 (--run)+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run include, exclude and include'"+run_sub_test_lib_testrun-inc-neg-inc\+'--run include, exclude and include'\+--run='"'1-5!1-32'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-inc-neg-inc<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run include, exclude and include, comma separated'"+run_sub_test_lib_testrun-inc-neg-inc-comma\+'--run include, exclude and include, comma separated'\+--run=1-5,\!1-3,2<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-inc-neg-inc-comma<<-\\EOF+>ok1# skip passing test #1 (--run)+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4-passingtest#4+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run exclude and include'"+run_sub_test_lib_testrun-neg-inc\+'--run exclude and include'\+--run='"'!3-5'"'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-neg-inc<<-\\EOF+>ok1-passingtest#1+>ok2-passingtest#2+>ok3# skip passing test #3 (--run)+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run empty selectors'"+run_sub_test_lib_testrun-empty-sel\+'--run empty selectors'\+--run='1,,3,,,5'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testrun-empty-sel<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (--run)+>ok3-passingtest#3+>ok4# skip passing test #4 (--run)+>ok5-passingtest#5+>ok6# skip passing test #6 (--run)+># passed all 6 test(s)+>1..6+EOF+"++test_expect_success'--run invalid range start'"+run_sub_test_lib_test_errrun-inv-range-start\+'--run invalid range start'\+--run='a-5'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-range-start\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:invalidnon-numericinrangestart:'a-5'+EOF_ERR+"++test_expect_success'--run invalid range end'"+run_sub_test_lib_test_errrun-inv-range-end\+'--run invalid range end'\+--run='1-z'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-range-end\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:invalidnon-numericinrangeend:'1-z'+EOF_ERR+"++test_expect_success'--run invalid selector'"+run_sub_test_lib_test_errrun-inv-selector\+'--run invalid selector'\+--run='1?'<<-\\EOF&&+test_expect_success\"passingtest#1\" 'true'+test_done+EOF+check_sub_test_lib_test_errrun-inv-selector\+<<-\\EOF_OUT3<<-\\EOF_ERR+>FATAL:Unexpectedexitwithcode1+EOF_OUT+>error:--run:invalidnon-numericintestselector:'1?'+EOF_ERR+"++ test_set_prereqHAVEIThaveit=no test_expect_successHAVEIT'test runs if prerequisite is satisfied''
@@ -191,6 +191,14 @@ doimmediate=t;shift;;-l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)GIT_TEST_LONG=t;exportGIT_TEST_LONG;shift;;+-r)+shift;test"$#"-ne0||{+echo'error: -r requires an argument'>&2;+exit1;+}+run_list=$1;shift;;+--run=*)+run_list=$(expr"z$1":'z[^=]*=\(.*\)');shift;;-h|--h|--he|--hel|--help)help=t;shift;;-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
@@ -366,6 +374,99 @@ match_pattern_list () {return1}+match_test_selector_list(){+title="$1"+shift+arg="$1"+shift+test-z"$1"&&return0++# Both commas and whitespace are accepted as separators.+OLDIFS=$IFS+IFS=' ,'+set--$1+IFS=$OLDIFS++# If the first selector is negative we include by default.+include=+case"$1"in+!*)include=t;;+esac++forselector+do+orig_selector=$selector++positive=t+case"$selector"in+!*)+positive=+selector=${selector##?}+;;+esac++test-z"$selector"&&continue++case"$selector"in+*-*)+ifexpr"z${selector%%-*}":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: invalid non-numeric in range"\+"start: '$orig_selector'">&2+exit1+fi+ifexpr"z${selector#*-}":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: invalid non-numeric in range"\+"end: '$orig_selector'">&2+exit1+fi+;;+*)+ifexpr"z$selector":"z[0-9]*[^0-9]">/dev/null+then+echo"error: $title: invalid non-numeric in test"\+"selector: '$orig_selector'">&2+exit1+fi+esac++# Short cut for "obvious" cases+test-z"$include"&&test-z"$positive"&&continue+test-n"$include"&&test-n"$positive"&&continue++case"$selector"in+-*)+iftest$arg-le${selector#-}+then+include=$positive+fi+;;+*-)+iftest$arg-ge${selector%-}+then+include=$positive+fi+;;+*-*)+iftest${selector%%-*}-le$arg\+&&test$arg-le${selector#*-}+then+include=$positive+fi+;;+*)+iftest$arg-eq$selector+then+include=$positive+fi+;;+esac+done++test-n"$include"+}+ maybe_teardown_verbose(){test-z"$verbose_only"&&returnexec4>/dev/null3>/dev/null
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 <redacted>
---
Changed to use AsciiDoc format.
t/README | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
@@ -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.
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-'
Previous version:
[RFC/PATCH v3] Better control of the tests run by a test suite
http://www.mail-archive.com/git@vger.kernel.org/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/git@vger.kernel.org/msg48454.htmlhttp://www.mail-archive.com/git@vger.kernel.org/msg48455.html
[2] http://www.mail-archive.com/git@vger.kernel.org/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(-)
We 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.
Signed-off-by: Ilya Bobyr <redacted>
---
No changes.
t/t0000-basic.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh | 13 ++++++----
2 files changed, 71 insertions(+), 5 deletions(-)
@@ -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_testgit-skip-tests-basic\+'GIT_SKIP_TESTS'<<-\\EOF&&+foriin123+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-basic<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3-passingtest#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_testgit-skip-tests-several\+'GIT_SKIP_TESTS several tests'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-several<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3-passingtest#3+>ok4-passingtest#4+>ok5# skip passing test #5 (GIT_SKIP_TESTS)+>ok6-passingtest#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_testgit-skip-tests-sh-pattern\+'GIT_SKIP_TESTS sh pattern'<<-\\EOF&&+foriin123456+do+test_expect_success\"passingtest#\$i\" 'true'+done+test_done+EOF+check_sub_test_lib_testgit-skip-tests-sh-pattern<<-\\EOF+>ok1-passingtest#1+>ok2# skip passing test #2 (GIT_SKIP_TESTS)+>ok3# skip passing test #3 (GIT_SKIP_TESTS)+>ok4# skip passing test #4 (GIT_SKIP_TESTS)+>ok5# skip passing test #5 (GIT_SKIP_TESTS)+>ok6-passingtest#6+># passed all 6 test(s)+>1..6+EOF+"+ test_set_prereqHAVEIThaveit=no test_expect_successHAVEIT'test runs if prerequisite is satisfied''