Skip to content

Commit 7e1a538

Browse files
committed
Merge branch 'ib/test-selectively-run'
Allow specifying only certain individual test pieces to be run using a range notation (e.g. "t1234-test.sh --run='1-4 6 8 9-'"). * ib/test-selectively-run: t0000-*.sh: fix the GIT_SKIP_TESTS sub-tests test-lib: '--run' to run only specific tests test-lib: tests skipped by GIT_SKIP_TESTS say so test-lib: document short options in t/README
2 parents c6d3abb + 7e28c16 commit 7e1a538

File tree

3 files changed

+617
-12
lines changed

3 files changed

+617
-12
lines changed

t/README

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ You can pass --verbose (or -v), --debug (or -d), and --immediate
7171
(or -i) command line argument to the test, or by setting GIT_TEST_OPTS
7272
appropriately before running "make".
7373

74+
-v::
7475
--verbose::
7576
This makes the test more verbose. Specifically, the
7677
command being run and their output if any are also
@@ -81,6 +82,7 @@ appropriately before running "make".
8182
numbers matching <pattern>. The number matched against is
8283
simply the running count of the test within the file.
8384

85+
-d::
8486
--debug::
8587
This may help the person who is developing a new test.
8688
It causes the command defined with test_debug to run.
@@ -89,17 +91,25 @@ appropriately before running "make".
8991
failed tests so that you can inspect its contents after
9092
the test finished.
9193

94+
-i::
9295
--immediate::
9396
This causes the test to immediately exit upon the first
9497
failed test. Cleanup commands requested with
9598
test_when_finished are not executed if the test failed,
9699
in order to keep the state for inspection by the tester
97100
to diagnose the bug.
98101

102+
-l::
99103
--long-tests::
100104
This causes additional long-running tests to be run (where
101105
available), for more exhaustive testing.
102106

107+
-r::
108+
--run=<test-selector>::
109+
Run only the subset of tests indicated by
110+
<test-selector>. See section "Skipping Tests" below for
111+
<test-selector> syntax.
112+
103113
--valgrind=<tool>::
104114
Execute all Git binaries under valgrind tool <tool> and exit
105115
with status 126 on errors (just like regular tests, this will
@@ -187,10 +197,77 @@ and either can match the "t[0-9]{4}" part to skip the whole
187197
test, or t[0-9]{4} followed by ".$number" to say which
188198
particular test to skip.
189199

190-
Note that some tests in the existing test suite rely on previous
191-
test item, so you cannot arbitrarily disable one and expect the
192-
remainder of test to check what the test originally was intended
193-
to check.
200+
For an individual test suite --run could be used to specify that
201+
only some tests should be run or that some tests should be
202+
excluded from a run.
203+
204+
The argument for --run is a list of individual test numbers or
205+
ranges with an optional negation prefix that define what tests in
206+
a test suite to include in the run. A range is two numbers
207+
separated with a dash and matches a range of tests with both ends
208+
been included. You may omit the first or the second number to
209+
mean "from the first test" or "up to the very last test"
210+
respectively.
211+
212+
Optional prefix of '!' means that the test or a range of tests
213+
should be excluded from the run.
214+
215+
If --run starts with an unprefixed number or range the initial
216+
set of tests to run is empty. If the first item starts with '!'
217+
all the tests are added to the initial set. After initial set is
218+
determined every test number or range is added or excluded from
219+
the set one by one, from left to right.
220+
221+
Individual numbers or ranges could be separated either by a space
222+
or a comma.
223+
224+
For example, to run only tests up to a specific test (21), one
225+
could do this:
226+
227+
$ sh ./t9200-git-cvsexport-commit.sh --run='1-21'
228+
229+
or this:
230+
231+
$ sh ./t9200-git-cvsexport-commit.sh --run='-21'
232+
233+
Common case is to run several setup tests (1, 2, 3) and then a
234+
specific test (21) that relies on that setup:
235+
236+
$ sh ./t9200-git-cvsexport-commit.sh --run='1 2 3 21'
237+
238+
or:
239+
240+
$ sh ./t9200-git-cvsexport-commit.sh --run=1,2,3,21
241+
242+
or:
243+
244+
$ sh ./t9200-git-cvsexport-commit.sh --run='-3 21'
245+
246+
As noted above, the test set is built going though items left to
247+
right, so this:
248+
249+
$ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3'
250+
251+
will run tests 1, 2, and 4. Items that comes later have higher
252+
precendence. It means that this:
253+
254+
$ sh ./t9200-git-cvsexport-commit.sh --run='!3 1-4'
255+
256+
would just run tests from 1 to 4, including 3.
257+
258+
You may use negation with ranges. The following will run all
259+
test in the test suite except from 7 up to 11:
260+
261+
$ sh ./t9200-git-cvsexport-commit.sh --run='!7-11'
262+
263+
Some tests in a test suite rely on the previous tests performing
264+
certain actions, specifically some tests are designated as
265+
"setup" test, so you cannot _arbitrarily_ disable one test and
266+
expect the rest to function correctly.
267+
268+
--run is mostly useful when you want to focus on a specific test
269+
and know what setup is needed for it. Or when you want to run
270+
everything up to a certain test.
194271

195272

196273
Naming Tests

0 commit comments

Comments
 (0)