@@ -99,6 +99,22 @@ function _validated_nworker_threads(str)
9999 return replace (str, " auto" => string (Sys. CPU_THREADS))
100100end
101101
102+ function _validated_paths (paths, should_throw:: Bool )
103+ return filter (paths) do p
104+ if ! ispath (p)
105+ msg = " No such path $(repr (p)) "
106+ should_throw ? throw (ArgumentError (msg)) : @warn msg
107+ return false
108+ elseif ! (is_test_file (p) || is_testsetup_file (p)) && isfile (p)
109+ msg = " $(repr (p)) is not a test file"
110+ should_throw ? throw (ArgumentError (msg)) : @warn msg
111+ return false
112+ else
113+ return true
114+ end
115+ end
116+ end
117+
102118"""
103119 ReTestItems.runtests()
104120 ReTestItems.runtests(mod::Module)
@@ -168,8 +184,12 @@ will be run.
168184 For interative sessions, `:eager` is the default when running with 0 or 1 worker processes, `:batched` otherwise.
169185 For non-interactive sessions, `:issues` is used by default.
170186- `verbose_results::Bool`: If `true`, the final test report will list each `@testitem`, otherwise
171- the results are aggregated. Default is `false` for non-interactive sessions
172- or when `logs=:issues`, `true` otherwise.
187+ the results are aggregated. Default is `false` for non-interactive sessions
188+ or when `logs=:issues`, `true` otherwise.
189+ - `validate_paths::Bool=false`: If `true`, `runtests` will throw an error if any of the
190+ `paths` passed to it cannot contain test files, either because the path doesn't exist or
191+ the path points to a file which is not a test file. Default is `false`.
192+ Can also be set using the `RETESTITEMS_VALIDATE_PATHS` environment variable.
173193"""
174194function runtests end
175195
@@ -214,19 +234,11 @@ function runtests(
214234 logs:: Symbol = Symbol (get (ENV , " RETESTITEMS_LOGS" , default_log_display_mode (report, nworkers))),
215235 verbose_results:: Bool = (logs != = :issues && isinteractive ()),
216236 test_end_expr:: Expr = Expr (:block ),
237+ validate_paths:: Bool = parse (Bool, get (ENV , " RETESTITEMS_VALIDATE_PATHS" , " false" )),
217238)
218239 nworker_threads = _validated_nworker_threads (nworker_threads)
219- paths′ = filter (paths) do p
220- if ! ispath (p)
221- @warn " No such path $(repr (p)) "
222- return false
223- elseif ! (is_test_file (p) || is_testsetup_file (p)) && isfile (p)
224- @warn " $(repr (p)) is not a test file"
225- return false
226- else
227- return true
228- end
229- end
240+ paths′ = _validated_paths (paths, validate_paths)
241+
230242 logs in LOG_DISPLAY_MODES || throw (ArgumentError (" `logs` must be one of $LOG_DISPLAY_MODES , got $(repr (logs)) " ))
231243 report && logs == :eager && throw (ArgumentError (" `report=true` is not compatible with `logs=:eager`" ))
232244 (0 ≤ memory_threshold ≤ 1 ) || throw (ArgumentError (" `memory_threshold` must be between 0 and 1, got $(repr (memory_threshold)) " ))
0 commit comments