Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the tests into functional form #532

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
module TestMOIWrapper

using Test

import Convex
import ECOS
import MathOptInterface as MOI
import Convex, ECOS
import SparseArrays

function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$name", "test_")
@testset "$(name)" begin
getfield(@__MODULE__, name)()
end
end
end
return
end

function test_runtests()
T = Float64
Expand All @@ -24,17 +38,8 @@ function test_runtests()
MOI.ObjectiveBound,
],
)
return MOI.Test.runtests(optimizer, config)
end

function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$name", "test_")
@testset "$(name)" begin
getfield(@__MODULE__, name)()
end
end
end
MOI.Test.runtests(optimizer, config)
return
end

end
Expand Down
37 changes: 0 additions & 37 deletions test/SparseTape.jl

This file was deleted.

46 changes: 0 additions & 46 deletions test/definitions.jl

This file was deleted.

38 changes: 0 additions & 38 deletions test/old.jl

This file was deleted.

91 changes: 0 additions & 91 deletions test/oldperf.jl

This file was deleted.

98 changes: 2 additions & 96 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,105 +1,11 @@
using Convex
using Convex.ProblemDepot: run_tests
using Test
using SCS, ECOS, GLPK, Clarabel

import MathOptInterface as MOI

# Seed random number stream to improve test reliability
using Random
import Random
Random.seed!(2)

@testset "Convex" begin
@testset "ProblemDepot" begin
@testset "Problems can run without `solve!`ing if `test==false`; T=$T" for T in
(
Float64,
BigFloat,
)
Convex.ProblemDepot.foreach_problem() do name, func
@testset "$name" begin
# We want to check to make sure this does not throw
func(Val(false), 0.0, 0.0, T) do problem
@test problem isa Convex.Problem{T} # check numeric type
model =
() -> MOI.Utilities.MockOptimizer(
MOI.Utilities.Model{T}(),
)

# make sure it loads without throwing
context = Convex.Context(problem, model)

# Make sure they can print
@test sprint(show, context) isa AbstractString

@test sprint(show, problem) isa AbstractString
return nothing
end
end
end
end
end

# @testset "SCS with warmstarts" begin
# run_tests(
# exclude = [
# r"mip",
# # TODO(odow): investigate
# r"sdp_lieb_ando",
# # Tolerance issue with SCS 3.0
# r"sdp_Real_Variables_with_complex_equality_constraints",
# ],
# ) do p
# return solve!(
# p,
# MOI.OptimizerWithAttributes(
# SCS.Optimizer,
# "verbose" => 0,
# "eps_rel" => 1e-6,
# "eps_abs" => 1e-6,
# );
# warmstart = true,
# )
# end
# end

@testset "Clarabel" begin
# TODO(odow): investigate sdp_lieb_ando
run_tests(; exclude = [r"mip", r"sdp_lieb_ando"]) do p
return solve!(p, Clarabel.Optimizer; silent_solver = true)
end
end

# Slow, and also hits linear algebra issues with BigFloat matrices
# @testset "Clarabel with BigFloat" begin
# # TODO(odow): investigate sdp_lieb_ando
# run_tests(; exclude = [r"mip", r"sdp_lieb_ando"], T = BigFloat) do p
# return solve!(p, Clarabel.Optimizer{BigFloat}; silent_solver = true)
# end
# end

# Disabling ECOS due to this segfault:
# https://github.com/jump-dev/ECOS.jl/issues/144
# @testset "ECOS" begin
# # For `rational_norm` problems:
# # > MathOptInterface.UnsupportedConstraint{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.NormCone}: `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.NormCone` constraint is not supported by the model.
# # Missing a bridge?
# run_tests(; exclude = [r"mip", r"sdp", r"rational_norm"]) do p
# return solve!(p, ECOS.Optimizer; silent_solver = true)
# end
# end

@testset "GLPK" begin
# Note this is an inclusion, not exclusion;
# we only test GLPK with MIPs, since those we can't test elsewhere.
run_tests([r"mip"]) do p
return solve!(p, GLPK.Optimizer; silent_solver = true)
end
end

include("definitions.jl")
include("SparseTape.jl")
include("test_utilities.jl")
include("test_abstract_variable.jl")
include("test_problem_depot.jl")
include("MOI_wrapper.jl")
end
Loading
Loading