|
4 | 4 | # Use of this source code is governed by an MIT-style license that can be found |
5 | 5 | # in the LICENSE.md file or at https://opensource.org/licenses/MIT. |
6 | 6 |
|
| 7 | +# To try and speed up the tests, MOI uses a `MOI_TEST_MODULES` environment |
| 8 | +# variable. This environment variable may be missing, or it may be a subset of |
| 9 | +# the following, concatenated with `;` as a separator: |
| 10 | +# |
| 11 | +# * General |
| 12 | +# * Benchmarks |
| 13 | +# * Bridges |
| 14 | +# * FileFormats |
| 15 | +# * Nonlinear |
| 16 | +# * Test |
| 17 | +# * Utilities |
| 18 | +# |
| 19 | +# If present, the tests run only those submodules defined above. `General` is |
| 20 | +# not a submodule, but it runs all of the top-level tests in MOI. |
| 21 | + |
7 | 22 | using Test |
8 | 23 |
|
9 | 24 | # This file gets called first. If it doesn't crash, all is well. |
10 | 25 | include("issue980.jl") |
11 | 26 |
|
12 | 27 | import MathOptInterface as MOI |
13 | | -@test isempty(Test.detect_ambiguities(MOI; recursive = true)) |
14 | 28 |
|
15 | | -for file in readdir(@__DIR__) |
16 | | - if file in ["issue980.jl", "dummy.jl", "hygiene.jl", "runtests.jl"] |
17 | | - continue |
18 | | - elseif !endswith(file, ".jl") |
19 | | - continue |
20 | | - end |
21 | | - @testset "$(file)" begin |
22 | | - include(file) |
| 29 | +MODULES_TO_TEST = get( |
| 30 | + ENV, |
| 31 | + "MOI_TEST_MODULES", |
| 32 | + "General;Benchmarks;Bridges;FileFormats;Nonlinear;Test;Utilities", |
| 33 | +) |
| 34 | + |
| 35 | +if occursin("General", MODULES_TO_TEST) |
| 36 | + @test isempty(Test.detect_ambiguities(MOI; recursive = true)) |
| 37 | + for file in readdir(@__DIR__) |
| 38 | + if file in ["issue980.jl", "dummy.jl", "hygiene.jl", "runtests.jl"] |
| 39 | + continue |
| 40 | + elseif !endswith(file, ".jl") |
| 41 | + continue |
| 42 | + end |
| 43 | + @testset "$(file)" begin |
| 44 | + include(file) |
| 45 | + end |
23 | 46 | end |
24 | 47 | end |
25 | 48 |
|
26 | | -for submodule in |
27 | | - ["Nonlinear", "Bridges", "FileFormats", "Test", "Utilities", "Benchmarks"] |
| 49 | +for submodule in split(MODULES_TO_TEST, ";") |
| 50 | + if submodule == "General" |
| 51 | + continue |
| 52 | + end |
28 | 53 | include("$(submodule)/$(submodule).jl") |
29 | 54 | GC.gc() # Force GC run here to reduce memory pressure |
30 | 55 | end |
31 | 56 |
|
32 | | -# Test hygiene of @model macro |
33 | | -include("hygiene.jl") |
| 57 | +if occursin("General", MODULES_TO_TEST) |
| 58 | + # Test hygiene of @model macro |
| 59 | + include("hygiene.jl") |
| 60 | +end |
0 commit comments