Skip to content

Commit eb641bf

Browse files
committed
Split some large files into smaller files for better parallelism
1 parent 9e0d741 commit eb641bf

7 files changed

Lines changed: 207 additions & 61 deletions

File tree

test/Test/test_BigFloat.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2017: Miles Lubin and contributors
2+
# Copyright (c) 2017: Google Inc.
3+
#
4+
# Use of this source code is governed by an MIT-style license that can be found
5+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
6+
7+
module TestTestBigFloat
8+
9+
using Test
10+
import MathOptInterface as MOI
11+
12+
function runtests()
13+
for name in names(@__MODULE__; all = true)
14+
if startswith("$name", "test_")
15+
@testset "$(name)" begin
16+
getfield(@__MODULE__, name)()
17+
end
18+
end
19+
end
20+
return
21+
end
22+
23+
function test_bigfloat_tests()
24+
MOI.Test.runtests(
25+
MOI.Utilities.MockOptimizer(
26+
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{BigFloat}()),
27+
BigFloat,
28+
),
29+
MOI.Test.Config(BigFloat),
30+
exclude = [
31+
# ========================= Expected failures ======================
32+
# UniversalFallback supports these tests.
33+
"test_model_copy_to_UnsupportedAttribute",
34+
"test_model_copy_to_UnsupportedConstraint",
35+
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
36+
"test_model_supports_constraint_VariableIndex_EqualTo",
37+
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
38+
],
39+
)
40+
return
41+
end
42+
43+
end # module
44+
45+
TestTestBigFloat.runtests()

test/Test/test_Float64.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (c) 2017: Miles Lubin and contributors
2+
# Copyright (c) 2017: Google Inc.
3+
#
4+
# Use of this source code is governed by an MIT-style license that can be found
5+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
6+
7+
module TestTestFloat64
8+
9+
using Test
10+
import MathOptInterface as MOI
11+
12+
function runtests()
13+
for name in names(@__MODULE__; all = true)
14+
if startswith("$name", "test_")
15+
@testset "$(name)" begin
16+
getfield(@__MODULE__, name)()
17+
end
18+
end
19+
end
20+
return
21+
end
22+
23+
function test_runtests()
24+
# Some tests are excluded because UniversalFallback accepts absolutely
25+
# everything.
26+
MOI.Test.runtests(
27+
MOI.Utilities.MockOptimizer(
28+
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
29+
),
30+
MOI.Test.Config(),
31+
exclude = [
32+
r"^test_model_ScalarFunctionConstantNotZero$",
33+
"test_model_copy_to_UnsupportedAttribute",
34+
"test_model_copy_to_UnsupportedConstraint",
35+
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
36+
"test_model_supports_constraint_VariableIndex_EqualTo",
37+
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
38+
],
39+
warn_unsupported = true,
40+
verbose = true,
41+
)
42+
# Run the previously excluded tests, this time without UniversalFallback.
43+
MOI.Test.runtests(
44+
MOI.Utilities.MockOptimizer(
45+
MOI.Utilities.Model{Float64}(),
46+
scalar_function_constant_non_zero = true,
47+
),
48+
MOI.Test.Config();
49+
include = [
50+
r"^test_model_ScalarFunctionConstantNotZero$",
51+
"test_model_copy_to_UnsupportedAttribute",
52+
"test_model_copy_to_UnsupportedConstraint",
53+
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
54+
"test_model_supports_constraint_VariableIndex_EqualTo",
55+
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
56+
],
57+
verbose = true,
58+
)
59+
return
60+
end
61+
62+
end # module
63+
64+
TestTestFloat64.runtests()

test/Test/test_Test.jl

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,6 @@ function runtests()
2020
return
2121
end
2222

23-
function test_runtests()
24-
# Some tests are excluded because UniversalFallback accepts absolutely
25-
# everything.
26-
MOI.Test.runtests(
27-
MOI.Utilities.MockOptimizer(
28-
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
29-
),
30-
MOI.Test.Config(),
31-
exclude = [
32-
r"^test_model_ScalarFunctionConstantNotZero$",
33-
"test_model_copy_to_UnsupportedAttribute",
34-
"test_model_copy_to_UnsupportedConstraint",
35-
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
36-
"test_model_supports_constraint_VariableIndex_EqualTo",
37-
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
38-
],
39-
warn_unsupported = true,
40-
verbose = true,
41-
)
42-
# Run the previously excluded tests, this time without UniversalFallback.
43-
MOI.Test.runtests(
44-
MOI.Utilities.MockOptimizer(
45-
MOI.Utilities.Model{Float64}(),
46-
scalar_function_constant_non_zero = true,
47-
),
48-
MOI.Test.Config();
49-
include = [
50-
r"^test_model_ScalarFunctionConstantNotZero$",
51-
"test_model_copy_to_UnsupportedAttribute",
52-
"test_model_copy_to_UnsupportedConstraint",
53-
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
54-
"test_model_supports_constraint_VariableIndex_EqualTo",
55-
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
56-
],
57-
verbose = true,
58-
)
59-
return
60-
end
61-
6223
function test_issue_1757()
6324
MOI.Test.test_model_ScalarFunctionConstantNotZero(
6425
MOI.Utilities.MockOptimizer(
@@ -84,28 +45,6 @@ function test_exclude_tests_after()
8445
return
8546
end
8647

87-
# Non-Float64 tests
88-
89-
function test_bigfloat_tests()
90-
MOI.Test.runtests(
91-
MOI.Utilities.MockOptimizer(
92-
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{BigFloat}()),
93-
BigFloat,
94-
),
95-
MOI.Test.Config(BigFloat),
96-
exclude = [
97-
# ========================= Expected failures ======================
98-
# UniversalFallback supports these tests.
99-
"test_model_copy_to_UnsupportedAttribute",
100-
"test_model_copy_to_UnsupportedConstraint",
101-
"test_model_supports_constraint_ScalarAffineFunction_EqualTo",
102-
"test_model_supports_constraint_VariableIndex_EqualTo",
103-
"test_model_supports_constraint_VectorOfVariables_Nonnegatives",
104-
],
105-
)
106-
return
107-
end
108-
10948
# Special test for issue #2010
11049

11150
struct _UnsupportedModel <: MOI.ModelLike end
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (c) 2017: Miles Lubin and contributors
2+
# Copyright (c) 2017: Google Inc.
3+
#
4+
# Use of this source code is governed by an MIT-style license that can be found
5+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
6+
7+
module TestCachingOptimizerRuntests
8+
9+
using Test
10+
11+
import MathOptInterface as MOI
12+
import MathOptInterface.Utilities as MOIU
13+
14+
function runtests()
15+
for name in names(@__MODULE__; all = true)
16+
if startswith("$(name)", "test_")
17+
@testset "$(name)" begin
18+
getfield(@__MODULE__, name)()
19+
end
20+
end
21+
end
22+
return
23+
end
24+
25+
function test_MOI_Test()
26+
# It seems like these loops might take a while. But the first one takes
27+
# _forever_, and then the rest are really quick (like 140s vs 0.4s).
28+
for state in
29+
(MOIU.NO_OPTIMIZER, MOIU.EMPTY_OPTIMIZER, MOIU.ATTACHED_OPTIMIZER)
30+
for mode in (MOIU.MANUAL, MOIU.AUTOMATIC)
31+
_test_caching_optimizer(state, mode)
32+
end
33+
end
34+
return
35+
end
36+
37+
function _test_caching_optimizer(state, mode)
38+
model = MOIU.CachingOptimizer(MOIU.Model{Float64}(), mode)
39+
if state != MOIU.NO_OPTIMIZER
40+
optimizer = MOIU.MockOptimizer(
41+
MOIU.Model{Float64}(),
42+
supports_names = false,
43+
)
44+
MOIU.reset_optimizer(model, optimizer)
45+
if state == MOIU.ATTACHED_OPTIMIZER
46+
MOIU.attach_optimizer(model)
47+
end
48+
end
49+
@test MOIU.state(model) == state
50+
@test MOIU.mode(model) == mode
51+
MOI.Test.runtests(
52+
model,
53+
MOI.Test.Config(exclude = Any[MOI.optimize!]),
54+
exclude = [
55+
"test_attribute_SolverName",
56+
"test_attribute_SolverVersion",
57+
],
58+
)
59+
return
60+
end
61+
62+
end # module
63+
64+
TestCachingOptimizerRuntests.runtests()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2017: Miles Lubin and contributors
2+
# Copyright (c) 2017: Google Inc.
3+
#
4+
# Use of this source code is governed by an MIT-style license that can be found
5+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
6+
7+
module TestModelRuntests
8+
9+
using Test
10+
11+
import MathOptInterface as MOI
12+
13+
function runtests()
14+
for name in names(@__MODULE__; all = true)
15+
if startswith("$(name)", "test_")
16+
@testset "$(name)" begin
17+
getfield(@__MODULE__, name)()
18+
end
19+
end
20+
end
21+
return
22+
end
23+
24+
function test_MOI_Test()
25+
MOI.Test.runtests(
26+
MOI.Utilities.Model{Float64}(),
27+
MOI.Test.Config(exclude = Any[MOI.optimize!,]),
28+
)
29+
return
30+
end
31+
32+
end # module
33+
34+
TestModelRuntests.runtests()
File renamed without changes.

0 commit comments

Comments
 (0)