@@ -173,9 +173,10 @@ version_added(::F) where {F} = v"0.10.5" # The default for any unlabeled tests.
173
173
warn_unsupported::Bool = false,
174
174
exclude_tests_after::VersionNumber = v"999.0.0",
175
175
verbose::Bool = false,
176
+ test_module = MathOptInterface.Test,
176
177
)
177
178
178
- Run all tests in `MathOptInterface.Test` on `model`.
179
+ Run all tests in `test_module`, which defaults to ` MathOptInterface.Test`, on `model`.
179
180
180
181
## Configuration arguments
181
182
@@ -201,6 +202,8 @@ Run all tests in `MathOptInterface.Test` on `model`.
201
202
is released with a new test.
202
203
* `verbose` is a `Bool` that controls whether the name of the test is printed
203
204
before executing it. This can be helpful when debugging.
205
+ * `test_module` is a `Module` where all the functions starting with `test_`
206
+ are considered as tests.
204
207
205
208
See also: [`setup_test`](@ref).
206
209
@@ -227,13 +230,14 @@ function runtests(
227
230
warn_unsupported:: Bool = false ,
228
231
verbose:: Bool = false ,
229
232
exclude_tests_after:: VersionNumber = v " 999.0.0" ,
233
+ test_module = @__MODULE__ ,
230
234
)
231
- tests = filter (names (@__MODULE__ ; all = true )) do name
235
+ tests = filter (names (test_module ; all = true )) do name
232
236
return startswith (" $name " , " test_" )
233
237
end
234
- tests = string .(tests)
238
+ test_names = string .(tests)
235
239
for ex in exclude
236
- if ex in tests && any (t -> ex != t && occursin (ex, t), tests )
240
+ if ex in test_names && any (t -> ex != t && occursin (ex, t), test_names )
237
241
@warn (
238
242
" The exclude string \" $ex \" is ambiguous because it exactly " *
239
243
" matches a test, but it also partially matches another. Use " *
@@ -242,19 +246,17 @@ function runtests(
242
246
)
243
247
end
244
248
end
245
- for name_sym in names ( @__MODULE__ ; all = true )
249
+ for name_sym in tests
246
250
name = string (name_sym)
247
- if ! startswith (name, " test_" )
248
- continue # All test functions start with test_
249
- elseif ! isempty (include) && ! any (s -> occursin (s, name), include)
251
+ if ! isempty (include) && ! any (s -> occursin (s, name), include)
250
252
continue
251
253
elseif ! isempty (exclude) && any (s -> occursin (s, name), exclude)
252
254
continue
253
255
end
254
256
if verbose
255
257
@info " Running $name "
256
258
end
257
- test_function = getfield (@__MODULE__ , name_sym)
259
+ test_function = getfield (test_module , name_sym)
258
260
if version_added (test_function) > exclude_tests_after
259
261
if verbose
260
262
println (" Skipping test because of `exclude_tests_after`" )
0 commit comments