Skip to content

Commit 0445e6f

Browse files
ilya-bobyrgitster
authored andcommitted
test-lib: '--run' to run only specific tests
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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef2ac68 commit 0445e6f

File tree

3 files changed

+537
-8
lines changed

3 files changed

+537
-8
lines changed

t/README

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ appropriately before running "make".
104104
This causes additional long-running tests to be run (where
105105
available), for more exhaustive testing.
106106

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+
107113
--valgrind=<tool>::
108114
Execute all Git binaries under valgrind tool <tool> and exit
109115
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
191197
test, or t[0-9]{4} followed by ".$number" to say which
192198
particular test to skip.
193199

194-
Note that some tests in the existing test suite rely on previous
195-
test item, so you cannot arbitrarily disable one and expect the
196-
remainder of test to check what the test originally was intended
197-
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.
198271

199272

200273
Naming Tests

0 commit comments

Comments
 (0)