@@ -23,13 +23,15 @@ Upon return:
2323 - `seed` is a seed which will be used to initialize the global RNG for each
2424 test to be run.
2525
26- Three options can be passed to `choosetests` by including a special token
26+ Several options can be passed to `choosetests` by including a special token
2727in the `choices` argument:
2828 - "--skip", which makes all tests coming after be skipped,
2929 - "--exit-on-error" which sets the value of `exit_on_error`,
3030 - "--seed=SEED", which sets the value of `seed` to `SEED`
3131 (parsed as an `UInt128`); `seed` is otherwise initialized randomly.
3232 This option can be used to reproduce failed tests.
33+ - "--help", which prints a help message and then skips all tests.
34+ - "--help-list", which prints the options computed without running them.
3335"""
3436function choosetests (choices = [])
3537 testnames = [
@@ -59,26 +61,52 @@ function choosetests(choices = [])
5961 ]
6062
6163 tests = []
62- skip_tests = []
64+ skip_tests = Set ()
6365 exit_on_error = false
6466 use_revise = false
6567 seed = rand (RandomDevice (), UInt128)
68+ dryrun = false
6669
6770 for (i, t) in enumerate (choices)
6871 if t == " --skip"
69- skip_tests = choices[i + 1 : end ]
72+ union! ( skip_tests, choices[i + 1 : end ])
7073 break
7174 elseif t == " --exit-on-error"
7275 exit_on_error = true
7376 elseif t == " --revise"
7477 use_revise = true
7578 elseif startswith (t, " --seed=" )
7679 seed = parse (UInt128, t[8 : end ])
80+ elseif t == " --help-list"
81+ dryrun = true
82+ elseif t == " --help"
83+ println ("""
84+ USAGE: ./julia runtests.jl [options] [tests]
85+ OPTIONS:
86+ --exit-on-error : stop tests immediately when a test group fails
87+ --help : prints this help message
88+ --help-list : prints the options computed without running them
89+ --revise : load Revise
90+ --seed=<SEED> : set the initial seed for all testgroups (parsed as a UInt128)
91+ --skip <NAMES>... : skip test or collection tagged with <NAMES>
92+ TESTS:
93+ Can be special tokens, such as "all", "unicode", "stdlib", the names of stdlib \
94+ modules, or the names of any file in the TESTNAMES array (defaults to "all").
95+
96+ Or prefix a name with `-` (such as `-core`) to skip a particular test.
97+ """ )
98+ return [], false , false , false , UInt128 (0 )
99+ elseif startswith (t, " --" )
100+ error (" unknown option: $t " )
101+ elseif startswith (t, " -" )
102+ push! (skip_tests, t[2 : end ])
77103 else
78104 push! (tests, t)
79105 end
80106 end
81107
108+ unhandled = copy (skip_tests)
109+
82110 if tests == [" all" ] || isempty (tests)
83111 tests = testnames
84112 end
@@ -87,6 +115,7 @@ function choosetests(choices = [])
87115 flt = x -> (x != name && ! (x in files))
88116 if name in skip_tests
89117 filter! (flt, tests)
118+ pop! (unhandled, name)
90119 elseif name in tests
91120 filter! (flt, tests)
92121 prepend! (tests, files)
@@ -134,6 +163,7 @@ function choosetests(choices = [])
134163 filter! (x -> x != " rounding" , tests)
135164 end
136165
166+ filter! (! in (tests), unhandled)
137167 filter! (! in (skip_tests), tests)
138168
139169 new_tests = String[]
@@ -155,7 +185,26 @@ function choosetests(choices = [])
155185 explicit_libgit2 || filter! (x -> x != " LibGit2/online" , tests)
156186
157187 # Filter out tests from the test groups in the stdlibs
188+ filter! (! in (tests), unhandled)
158189 filter! (! in (skip_tests), tests)
159190
191+ if ! isempty (unhandled)
192+ @warn " Not skipping tests: $(join (unhandled, " , " )) "
193+ end
194+
195+ if dryrun
196+ print (" Tests enabled to run:" )
197+ foreach (t -> print (" \n " , t), tests)
198+ if ! isempty (skip_tests)
199+ print (" \n\n Tests skipped:" )
200+ foreach (t -> print (" \n " , t), skip_tests)
201+ end
202+ print (" \n " )
203+ exit_on_error && (print (" \n with option " ); printstyled (" exit_on_error" , bold= true ))
204+ use_revise && (print (" \n with option " ); printstyled (" use_revise" , bold= true ); print (" (Revise.jl)" ))
205+ print (" \n\n " )
206+ empty! (tests)
207+ end
208+
160209 tests, net_on, exit_on_error, use_revise, seed
161210end
0 commit comments