Skip to content

Commit bece3e7

Browse files
authored
[Test] support Regex in the include and exclude arguments to Test.runtests (#2129)
1 parent 9c9a097 commit bece3e7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Test/Test.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ version_added(::F) where {F} = v"0.10.5" # The default for any unlabeled tests.
146146
runtests(
147147
model::MOI.ModelLike,
148148
config::Config;
149-
include::Vector{String} = String[],
150-
exclude::Vector{String} = String[],
149+
include::Vector{Union{String,Regex}} = String[],
150+
exclude::Vector{Union{String,Regex}} = String[],
151151
warn_unsupported::Bool = false,
152152
exclude_tests_after::VersionNumber = v"999.0.0",
153153
)
@@ -158,10 +158,10 @@ Run all tests in `MathOptInterface.Test` on `model`.
158158
159159
* `config` is a [`Test.Config`](@ref) object that can be used to modify the
160160
behavior of tests.
161-
* If `include` is not empty, only run tests that contain an element from
162-
`include` in their name.
163-
* If `exclude` is not empty, skip tests that contain an element from `exclude`
164-
in their name.
161+
* If `include` is not empty, only run tests if an element from `include`
162+
`occursin` the name of the test.
163+
* If `exclude` is not empty, skip tests if an element from `exclude` `occursin`
164+
the name of the test.
165165
* `exclude` takes priority over `include`.
166166
* If `warn_unsupported` is `false`, `runtests` will silently skip tests that
167167
fail with a `MOI.NotAllowedError`, `MOI.UnsupportedError`, or
@@ -186,7 +186,7 @@ config = MathOptInterface.Test.Config()
186186
MathOptInterface.Test.runtests(
187187
model,
188188
config;
189-
include = ["test_linear_"],
189+
include = ["test_linear_", r"^test_model_Name\$"],
190190
exclude = ["VariablePrimalStart"],
191191
warn_unsupported = true,
192192
exclude_tests_after = v"0.10.5",
@@ -196,8 +196,8 @@ MathOptInterface.Test.runtests(
196196
function runtests(
197197
model::MOI.ModelLike,
198198
config::Config;
199-
include::Vector{String} = String[],
200-
exclude::Vector{String} = String[],
199+
include::Vector = String[],
200+
exclude::Vector = String[],
201201
warn_unsupported::Bool = false,
202202
exclude_tests_after::VersionNumber = v"999.0.0",
203203
)

test/Test/Test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MOI.Test.runtests(
1717
),
1818
MOI.Test.Config(),
1919
exclude = [
20-
"test_model_ScalarFunctionConstantNotZero",
20+
r"^test_model_ScalarFunctionConstantNotZero$",
2121
"test_model_copy_to_UnsupportedAttribute",
2222
"test_model_copy_to_UnsupportedConstraint",
2323
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
@@ -36,7 +36,7 @@ MOI.Test.runtests(
3636
),
3737
MOI.Test.Config(),
3838
include = [
39-
"test_model_ScalarFunctionConstantNotZero",
39+
r"^test_model_ScalarFunctionConstantNotZero$",
4040
"test_model_copy_to_UnsupportedAttribute",
4141
"test_model_copy_to_UnsupportedConstraint",
4242
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",

0 commit comments

Comments
 (0)