diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c27a9a95a5..0892d719fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: matrix: moi_test_modules: - 'General;Benchmarks;FileFormats;Nonlinear' - - 'Bridges' + - 'Bridges/General' - 'Bridges/Constraint;Bridges/Objective;Bridges/Variable' - 'Test' - 'Utilities' diff --git a/Project.toml b/Project.toml index c1da77ff95..76e5cc8aa2 100644 --- a/Project.toml +++ b/Project.toml @@ -36,6 +36,7 @@ LinearAlgebra = "1" MutableArithmetics = "1" NaNMath = "0.3, 1" OrderedCollections = "1" +ParallelTestRunner = "2.1.0" PrecompileTools = "1" Printf = "1" SparseArrays = "1" @@ -46,6 +47,7 @@ julia = "1.10" [extras] LDLFactorizations = "40e66cde-538c-5869-a4ad-c39174c6795b" JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" [targets] -test = ["LDLFactorizations", "JSONSchema"] +test = ["LDLFactorizations", "JSONSchema", "ParallelTestRunner"] diff --git a/test/Benchmarks/runtests.jl b/test/Benchmarks/test_Benchmarks.jl similarity index 100% rename from test/Benchmarks/runtests.jl rename to test/Benchmarks/test_Benchmarks.jl diff --git a/test/Bridges/Constraint/runtests.jl b/test/Bridges/Constraint/runtests.jl deleted file mode 100644 index 7f9712e994..0000000000 --- a/test/Bridges/Constraint/runtests.jl +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -@testset "$(file)" for file in readdir(@__DIR__; join = true) - if !endswith(file, ".jl") || endswith(file, "runtests.jl") - continue - end - include(file) -end diff --git a/test/Bridges/Constraint/AllDifferentToCountDistinctBridge.jl b/test/Bridges/Constraint/test_AllDifferentToCountDistinctBridge.jl similarity index 100% rename from test/Bridges/Constraint/AllDifferentToCountDistinctBridge.jl rename to test/Bridges/Constraint/test_AllDifferentToCountDistinctBridge.jl diff --git a/test/Bridges/Constraint/BinPackingToMILPBridge.jl b/test/Bridges/Constraint/test_BinPackingToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/BinPackingToMILPBridge.jl rename to test/Bridges/Constraint/test_BinPackingToMILPBridge.jl diff --git a/test/Bridges/Constraint/CircuitToMILPBridge.jl b/test/Bridges/Constraint/test_CircuitToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/CircuitToMILPBridge.jl rename to test/Bridges/Constraint/test_CircuitToMILPBridge.jl diff --git a/test/Bridges/Constraint/ComplexNormInfinityToSecondOrderConeBridge.jl b/test/Bridges/Constraint/test_ComplexNormInfinityToSecondOrderConeBridge.jl similarity index 100% rename from test/Bridges/Constraint/ComplexNormInfinityToSecondOrderConeBridge.jl rename to test/Bridges/Constraint/test_ComplexNormInfinityToSecondOrderConeBridge.jl diff --git a/test/Bridges/Constraint/CountAtLeastToCountBelongsBridge.jl b/test/Bridges/Constraint/test_CountAtLeastToCountBelongsBridge.jl similarity index 100% rename from test/Bridges/Constraint/CountAtLeastToCountBelongsBridge.jl rename to test/Bridges/Constraint/test_CountAtLeastToCountBelongsBridge.jl diff --git a/test/Bridges/Constraint/CountBelongsToMILPBridge.jl b/test/Bridges/Constraint/test_CountBelongsToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/CountBelongsToMILPBridge.jl rename to test/Bridges/Constraint/test_CountBelongsToMILPBridge.jl diff --git a/test/Bridges/Constraint/CountDistinctToMILPBridge.jl b/test/Bridges/Constraint/test_CountDistinctToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/CountDistinctToMILPBridge.jl rename to test/Bridges/Constraint/test_CountDistinctToMILPBridge.jl diff --git a/test/Bridges/Constraint/CountGreaterThanToMILPBridge.jl b/test/Bridges/Constraint/test_CountGreaterThanToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/CountGreaterThanToMILPBridge.jl rename to test/Bridges/Constraint/test_CountGreaterThanToMILPBridge.jl diff --git a/test/Bridges/Constraint/ExponentialConeToScalarNonlinearFunctionBridge.jl b/test/Bridges/Constraint/test_ExponentialConeToScalarNonlinearFunctionBridge.jl similarity index 100% rename from test/Bridges/Constraint/ExponentialConeToScalarNonlinearFunctionBridge.jl rename to test/Bridges/Constraint/test_ExponentialConeToScalarNonlinearFunctionBridge.jl diff --git a/test/Bridges/Constraint/GeoMeanBridge.jl b/test/Bridges/Constraint/test_GeoMeanBridge.jl similarity index 100% rename from test/Bridges/Constraint/GeoMeanBridge.jl rename to test/Bridges/Constraint/test_GeoMeanBridge.jl diff --git a/test/Bridges/Constraint/GeoMeanToPowerBridgeBridge.jl b/test/Bridges/Constraint/test_GeoMeanToPowerBridgeBridge.jl similarity index 100% rename from test/Bridges/Constraint/GeoMeanToPowerBridgeBridge.jl rename to test/Bridges/Constraint/test_GeoMeanToPowerBridgeBridge.jl diff --git a/test/Bridges/Constraint/GeoMeantoRelEntrBridge.jl b/test/Bridges/Constraint/test_GeoMeantoRelEntrBridge.jl similarity index 100% rename from test/Bridges/Constraint/GeoMeantoRelEntrBridge.jl rename to test/Bridges/Constraint/test_GeoMeantoRelEntrBridge.jl diff --git a/test/Bridges/Constraint/GreaterToIntervalBridge.jl b/test/Bridges/Constraint/test_GreaterToIntervalBridge.jl similarity index 100% rename from test/Bridges/Constraint/GreaterToIntervalBridge.jl rename to test/Bridges/Constraint/test_GreaterToIntervalBridge.jl diff --git a/test/Bridges/Constraint/GreaterToLessBridge.jl b/test/Bridges/Constraint/test_GreaterToLessBridge.jl similarity index 100% rename from test/Bridges/Constraint/GreaterToLessBridge.jl rename to test/Bridges/Constraint/test_GreaterToLessBridge.jl diff --git a/test/Bridges/Constraint/HermitianToComplexSymmetricBridge.jl b/test/Bridges/Constraint/test_HermitianToComplexSymmetricBridge.jl similarity index 100% rename from test/Bridges/Constraint/HermitianToComplexSymmetricBridge.jl rename to test/Bridges/Constraint/test_HermitianToComplexSymmetricBridge.jl diff --git a/test/Bridges/Constraint/HermitianToSymmetricPSDBridge.jl b/test/Bridges/Constraint/test_HermitianToSymmetricPSDBridge.jl similarity index 100% rename from test/Bridges/Constraint/HermitianToSymmetricPSDBridge.jl rename to test/Bridges/Constraint/test_HermitianToSymmetricPSDBridge.jl diff --git a/test/Bridges/Constraint/IndicatorActiveOnFalseBridge.jl b/test/Bridges/Constraint/test_IndicatorActiveOnFalseBridge.jl similarity index 100% rename from test/Bridges/Constraint/IndicatorActiveOnFalseBridge.jl rename to test/Bridges/Constraint/test_IndicatorActiveOnFalseBridge.jl diff --git a/test/Bridges/Constraint/IndicatorLessToGreaterThanBridge.jl b/test/Bridges/Constraint/test_IndicatorLessToGreaterThanBridge.jl similarity index 100% rename from test/Bridges/Constraint/IndicatorLessToGreaterThanBridge.jl rename to test/Bridges/Constraint/test_IndicatorLessToGreaterThanBridge.jl diff --git a/test/Bridges/Constraint/IndicatorSOS1Bridge.jl b/test/Bridges/Constraint/test_IndicatorSOS1Bridge.jl similarity index 100% rename from test/Bridges/Constraint/IndicatorSOS1Bridge.jl rename to test/Bridges/Constraint/test_IndicatorSOS1Bridge.jl diff --git a/test/Bridges/Constraint/IndicatorToMILPBridge.jl b/test/Bridges/Constraint/test_IndicatorToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/IndicatorToMILPBridge.jl rename to test/Bridges/Constraint/test_IndicatorToMILPBridge.jl diff --git a/test/Bridges/Constraint/InequalityToComplementsBridge.jl b/test/Bridges/Constraint/test_InequalityToComplementsBridge.jl similarity index 100% rename from test/Bridges/Constraint/InequalityToComplementsBridge.jl rename to test/Bridges/Constraint/test_InequalityToComplementsBridge.jl diff --git a/test/Bridges/Constraint/IntegerToZeroOneBridge.jl b/test/Bridges/Constraint/test_IntegerToZeroOneBridge.jl similarity index 100% rename from test/Bridges/Constraint/IntegerToZeroOneBridge.jl rename to test/Bridges/Constraint/test_IntegerToZeroOneBridge.jl diff --git a/test/Bridges/Constraint/IntervalToHyperRectangleBridge.jl b/test/Bridges/Constraint/test_IntervalToHyperRectangleBridge.jl similarity index 100% rename from test/Bridges/Constraint/IntervalToHyperRectangleBridge.jl rename to test/Bridges/Constraint/test_IntervalToHyperRectangleBridge.jl diff --git a/test/Bridges/Constraint/LogDetBridge.jl b/test/Bridges/Constraint/test_LogDetBridge.jl similarity index 100% rename from test/Bridges/Constraint/LogDetBridge.jl rename to test/Bridges/Constraint/test_LogDetBridge.jl diff --git a/test/Bridges/Constraint/NormInfinityBridge.jl b/test/Bridges/Constraint/test_NormInfinityBridge.jl similarity index 100% rename from test/Bridges/Constraint/NormInfinityBridge.jl rename to test/Bridges/Constraint/test_NormInfinityBridge.jl diff --git a/test/Bridges/Constraint/NormOneBridge.jl b/test/Bridges/Constraint/test_NormOneBridge.jl similarity index 100% rename from test/Bridges/Constraint/NormOneBridge.jl rename to test/Bridges/Constraint/test_NormOneBridge.jl diff --git a/test/Bridges/Constraint/NormOneConeToNormConeBridge.jl b/test/Bridges/Constraint/test_NormOneConeToNormConeBridge.jl similarity index 100% rename from test/Bridges/Constraint/NormOneConeToNormConeBridge.jl rename to test/Bridges/Constraint/test_NormOneConeToNormConeBridge.jl diff --git a/test/Bridges/Constraint/NormSpectralBridge.jl b/test/Bridges/Constraint/test_NormSpectralBridge.jl similarity index 100% rename from test/Bridges/Constraint/NormSpectralBridge.jl rename to test/Bridges/Constraint/test_NormSpectralBridge.jl diff --git a/test/Bridges/Constraint/NormToPowerBridge.jl b/test/Bridges/Constraint/test_NormToPowerBridge.jl similarity index 100% rename from test/Bridges/Constraint/NormToPowerBridge.jl rename to test/Bridges/Constraint/test_NormToPowerBridge.jl diff --git a/test/Bridges/Constraint/NumberConversionBridge.jl b/test/Bridges/Constraint/test_NumberConversionBridge.jl similarity index 100% rename from test/Bridges/Constraint/NumberConversionBridge.jl rename to test/Bridges/Constraint/test_NumberConversionBridge.jl diff --git a/test/Bridges/Constraint/QuadtoSOCBridge.jl b/test/Bridges/Constraint/test_QuadtoSOCBridge.jl similarity index 100% rename from test/Bridges/Constraint/QuadtoSOCBridge.jl rename to test/Bridges/Constraint/test_QuadtoSOCBridge.jl diff --git a/test/Bridges/Constraint/RSOCBridge.jl b/test/Bridges/Constraint/test_RSOCBridge.jl similarity index 100% rename from test/Bridges/Constraint/RSOCBridge.jl rename to test/Bridges/Constraint/test_RSOCBridge.jl diff --git a/test/Bridges/Constraint/RSOCtoNonConvexQuadBridge.jl b/test/Bridges/Constraint/test_RSOCtoNonConvexQuadBridge.jl similarity index 100% rename from test/Bridges/Constraint/RSOCtoNonConvexQuadBridge.jl rename to test/Bridges/Constraint/test_RSOCtoNonConvexQuadBridge.jl diff --git a/test/Bridges/Constraint/ReifiedAllDifferentToCountDistinctBridge.jl b/test/Bridges/Constraint/test_ReifiedAllDifferentToCountDistinctBridge.jl similarity index 100% rename from test/Bridges/Constraint/ReifiedAllDifferentToCountDistinctBridge.jl rename to test/Bridges/Constraint/test_ReifiedAllDifferentToCountDistinctBridge.jl diff --git a/test/Bridges/Constraint/ReifiedCountDistinctToMILPBridge.jl b/test/Bridges/Constraint/test_ReifiedCountDistinctToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/ReifiedCountDistinctToMILPBridge.jl rename to test/Bridges/Constraint/test_ReifiedCountDistinctToMILPBridge.jl diff --git a/test/Bridges/Constraint/RelativeEntropyBridge.jl b/test/Bridges/Constraint/test_RelativeEntropyBridge.jl similarity index 100% rename from test/Bridges/Constraint/RelativeEntropyBridge.jl rename to test/Bridges/Constraint/test_RelativeEntropyBridge.jl diff --git a/test/Bridges/Constraint/SOCtoPSDBridge.jl b/test/Bridges/Constraint/test_SOCtoPSDBridge.jl similarity index 100% rename from test/Bridges/Constraint/SOCtoPSDBridge.jl rename to test/Bridges/Constraint/test_SOCtoPSDBridge.jl diff --git a/test/Bridges/Constraint/SOS1ToMILPBridge.jl b/test/Bridges/Constraint/test_SOS1ToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/SOS1ToMILPBridge.jl rename to test/Bridges/Constraint/test_SOS1ToMILPBridge.jl diff --git a/test/Bridges/Constraint/SOS2ToMILPBridge.jl b/test/Bridges/Constraint/test_SOS2ToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/SOS2ToMILPBridge.jl rename to test/Bridges/Constraint/test_SOS2ToMILPBridge.jl diff --git a/test/Bridges/Constraint/ScalarFunctionizeBridge.jl b/test/Bridges/Constraint/test_ScalarFunctionizeBridge.jl similarity index 100% rename from test/Bridges/Constraint/ScalarFunctionizeBridge.jl rename to test/Bridges/Constraint/test_ScalarFunctionizeBridge.jl diff --git a/test/Bridges/Constraint/ScalarSlackBridge.jl b/test/Bridges/Constraint/test_ScalarSlackBridge.jl similarity index 100% rename from test/Bridges/Constraint/ScalarSlackBridge.jl rename to test/Bridges/Constraint/test_ScalarSlackBridge.jl diff --git a/test/Bridges/Constraint/ScalarizeBridge.jl b/test/Bridges/Constraint/test_ScalarizeBridge.jl similarity index 100% rename from test/Bridges/Constraint/ScalarizeBridge.jl rename to test/Bridges/Constraint/test_ScalarizeBridge.jl diff --git a/test/Bridges/Constraint/SemiToBinaryBridge.jl b/test/Bridges/Constraint/test_SemiToBinaryBridge.jl similarity index 100% rename from test/Bridges/Constraint/SemiToBinaryBridge.jl rename to test/Bridges/Constraint/test_SemiToBinaryBridge.jl diff --git a/test/Bridges/Constraint/SetConversionBridge.jl b/test/Bridges/Constraint/test_SetConversionBridge.jl similarity index 100% rename from test/Bridges/Constraint/SetConversionBridge.jl rename to test/Bridges/Constraint/test_SetConversionBridge.jl diff --git a/test/Bridges/Constraint/SetDotScalingBridge.jl b/test/Bridges/Constraint/test_SetDotScalingBridge.jl similarity index 100% rename from test/Bridges/Constraint/SetDotScalingBridge.jl rename to test/Bridges/Constraint/test_SetDotScalingBridge.jl diff --git a/test/Bridges/Constraint/SplitComplexEqualToBridge.jl b/test/Bridges/Constraint/test_SplitComplexEqualToBridge.jl similarity index 100% rename from test/Bridges/Constraint/SplitComplexEqualToBridge.jl rename to test/Bridges/Constraint/test_SplitComplexEqualToBridge.jl diff --git a/test/Bridges/Constraint/SplitComplexIndicatorEqualToBridge.jl b/test/Bridges/Constraint/test_SplitComplexIndicatorEqualToBridge.jl similarity index 100% rename from test/Bridges/Constraint/SplitComplexIndicatorEqualToBridge.jl rename to test/Bridges/Constraint/test_SplitComplexIndicatorEqualToBridge.jl diff --git a/test/Bridges/Constraint/SplitComplexZerosBridge.jl b/test/Bridges/Constraint/test_SplitComplexZerosBridge.jl similarity index 100% rename from test/Bridges/Constraint/SplitComplexZerosBridge.jl rename to test/Bridges/Constraint/test_SplitComplexZerosBridge.jl diff --git a/test/Bridges/Constraint/SplitHyperRectangleBridge.jl b/test/Bridges/Constraint/test_SplitHyperRectangleBridge.jl similarity index 100% rename from test/Bridges/Constraint/SplitHyperRectangleBridge.jl rename to test/Bridges/Constraint/test_SplitHyperRectangleBridge.jl diff --git a/test/Bridges/Constraint/SplitIntervalBridge.jl b/test/Bridges/Constraint/test_SplitIntervalBridge.jl similarity index 100% rename from test/Bridges/Constraint/SplitIntervalBridge.jl rename to test/Bridges/Constraint/test_SplitIntervalBridge.jl diff --git a/test/Bridges/Constraint/SquareBridge.jl b/test/Bridges/Constraint/test_SquareBridge.jl similarity index 100% rename from test/Bridges/Constraint/SquareBridge.jl rename to test/Bridges/Constraint/test_SquareBridge.jl diff --git a/test/Bridges/Constraint/TableToMILPBridge.jl b/test/Bridges/Constraint/test_TableToMILPBridge.jl similarity index 100% rename from test/Bridges/Constraint/TableToMILPBridge.jl rename to test/Bridges/Constraint/test_TableToMILPBridge.jl diff --git a/test/Bridges/Constraint/VectorizeBridge.jl b/test/Bridges/Constraint/test_VectorizeBridge.jl similarity index 100% rename from test/Bridges/Constraint/VectorizeBridge.jl rename to test/Bridges/Constraint/test_VectorizeBridge.jl diff --git a/test/Bridges/Constraint/ZeroOneBridge.jl b/test/Bridges/Constraint/test_ZeroOneBridge.jl similarity index 100% rename from test/Bridges/Constraint/ZeroOneBridge.jl rename to test/Bridges/Constraint/test_ZeroOneBridge.jl diff --git a/test/Bridges/Constraint/bridge.jl b/test/Bridges/Constraint/test_bridge.jl similarity index 100% rename from test/Bridges/Constraint/bridge.jl rename to test/Bridges/Constraint/test_bridge.jl diff --git a/test/Bridges/Constraint/map.jl b/test/Bridges/Constraint/test_map.jl similarity index 100% rename from test/Bridges/Constraint/map.jl rename to test/Bridges/Constraint/test_map.jl diff --git a/test/Bridges/identity_bridge.jl b/test/Bridges/General/identity_bridge.jl similarity index 100% rename from test/Bridges/identity_bridge.jl rename to test/Bridges/General/identity_bridge.jl diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/General/test_bridge_optimizer.jl similarity index 99% rename from test/Bridges/bridge_optimizer.jl rename to test/Bridges/General/test_bridge_optimizer.jl index 3e23366a49..19de4d87c2 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/General/test_bridge_optimizer.jl @@ -21,7 +21,7 @@ function runtests() return end -include("utilities.jl") +include("../utilities.jl") struct DummyModelAttribute <: MOI.AbstractModelAttribute end diff --git a/test/Bridges/debug.jl b/test/Bridges/General/test_debug.jl similarity index 100% rename from test/Bridges/debug.jl rename to test/Bridges/General/test_debug.jl diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/General/test_lazy_bridge_optimizer.jl similarity index 97% rename from test/Bridges/lazy_bridge_optimizer.jl rename to test/Bridges/General/test_lazy_bridge_optimizer.jl index 8da73884b8..2d28d77a45 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/General/test_lazy_bridge_optimizer.jl @@ -21,8 +21,117 @@ function runtests() return end -include("utilities.jl") -include("sdpa_models.jl") +include("../utilities.jl") + +# This block implements models similar to the SDPA format. It gives a good +# example because it does not support a lot of functions, hence the need for +# a lot of bridges. + +MOI.Utilities.@model( + StandardSDPAModel, + (), + (MOI.EqualTo,), + (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), + (), + (), + (MOI.ScalarAffineFunction,), + (MOI.VectorOfVariables,), + () +) + +function MOI.supports_constraint( + ::StandardSDPAModel{T}, + ::Type{MOI.VariableIndex}, + ::Type{ + <:Union{ + MOI.GreaterThan{T}, + MOI.LessThan{T}, + MOI.EqualTo{T}, + MOI.Interval{T}, + MOI.ZeroOne, + MOI.Integer, + }, + }, +) where {T} + return false +end + +function MOI.supports_constraint( + ::StandardSDPAModel{T}, + ::Type{MOI.VectorOfVariables}, + ::Type{MOI.Reals}, +) where {T} + return false +end + +function MOI.supports_add_constrained_variables( + ::StandardSDPAModel, + ::Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}}, +) + return true +end + +function MOI.supports_add_constrained_variables( + ::StandardSDPAModel, + ::Type{MOI.Reals}, +) + return false +end + +function MOI.supports( + ::StandardSDPAModel{T}, + ::MOI.ObjectiveFunction{ + <:Union{ + MOI.VariableIndex, + MOI.ScalarQuadraticFunction{T}, + MOI.ScalarNonlinearFunction, + MOI.VectorOfVariables, + MOI.VectorAffineFunction{T}, + MOI.VectorQuadraticFunction{T}, + MOI.VectorNonlinearFunction, + }, + }, +) where {T} + return false +end + +MOI.Utilities.@model( + GeometricSDPAModel, + (), + (), + (MOI.Zeros, MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), + (), + (), + (), + (), + (MOI.VectorAffineFunction,) +) + +function MOI.supports_constraint( + ::GeometricSDPAModel{T}, + ::Type{MOI.VariableIndex}, + ::Type{ + <:Union{ + MOI.GreaterThan{T}, + MOI.LessThan{T}, + MOI.EqualTo{T}, + MOI.Interval{T}, + MOI.ZeroOne, + MOI.Integer, + }, + }, +) where {T} + return false +end + +function MOI.supports( + ::GeometricSDPAModel{T}, + ::MOI.ObjectiveFunction{ + <:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}}, + }, +) where {T} + return false +end function test_add_remove_has_bridges() T = Int diff --git a/test/Bridges/set_map.jl b/test/Bridges/General/test_set_map.jl similarity index 100% rename from test/Bridges/set_map.jl rename to test/Bridges/General/test_set_map.jl diff --git a/test/Bridges/Objective/runtests.jl b/test/Bridges/Objective/runtests.jl deleted file mode 100644 index 7f9712e994..0000000000 --- a/test/Bridges/Objective/runtests.jl +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -@testset "$(file)" for file in readdir(@__DIR__; join = true) - if !endswith(file, ".jl") || endswith(file, "runtests.jl") - continue - end - include(file) -end diff --git a/test/Bridges/Objective/FunctionConversionBridge.jl b/test/Bridges/Objective/test_FunctionConversionBridge.jl similarity index 100% rename from test/Bridges/Objective/FunctionConversionBridge.jl rename to test/Bridges/Objective/test_FunctionConversionBridge.jl diff --git a/test/Bridges/Objective/FunctionizeBridge.jl b/test/Bridges/Objective/test_FunctionizeBridge.jl similarity index 100% rename from test/Bridges/Objective/FunctionizeBridge.jl rename to test/Bridges/Objective/test_FunctionizeBridge.jl diff --git a/test/Bridges/Objective/QuadratizeBridge.jl b/test/Bridges/Objective/test_QuadratizeBridge.jl similarity index 100% rename from test/Bridges/Objective/QuadratizeBridge.jl rename to test/Bridges/Objective/test_QuadratizeBridge.jl diff --git a/test/Bridges/Objective/SlackBridge.jl b/test/Bridges/Objective/test_SlackBridge.jl similarity index 100% rename from test/Bridges/Objective/SlackBridge.jl rename to test/Bridges/Objective/test_SlackBridge.jl diff --git a/test/Bridges/Objective/ToScalarNonlinearBridge.jl b/test/Bridges/Objective/test_ToScalarNonlinearBridge.jl similarity index 100% rename from test/Bridges/Objective/ToScalarNonlinearBridge.jl rename to test/Bridges/Objective/test_ToScalarNonlinearBridge.jl diff --git a/test/Bridges/Objective/VectorFunctionizeBridge.jl b/test/Bridges/Objective/test_VectorFunctionizeBridge.jl similarity index 100% rename from test/Bridges/Objective/VectorFunctionizeBridge.jl rename to test/Bridges/Objective/test_VectorFunctionizeBridge.jl diff --git a/test/Bridges/Objective/VectorSlackBridge.jl b/test/Bridges/Objective/test_VectorSlackBridge.jl similarity index 100% rename from test/Bridges/Objective/VectorSlackBridge.jl rename to test/Bridges/Objective/test_VectorSlackBridge.jl diff --git a/test/Bridges/Objective/map.jl b/test/Bridges/Objective/test_map.jl similarity index 100% rename from test/Bridges/Objective/map.jl rename to test/Bridges/Objective/test_map.jl diff --git a/test/Bridges/Variable/runtests.jl b/test/Bridges/Variable/runtests.jl deleted file mode 100644 index 7f9712e994..0000000000 --- a/test/Bridges/Variable/runtests.jl +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -@testset "$(file)" for file in readdir(@__DIR__; join = true) - if !endswith(file, ".jl") || endswith(file, "runtests.jl") - continue - end - include(file) -end diff --git a/test/Bridges/Variable/FreeBridge.jl b/test/Bridges/Variable/test_FreeBridge.jl similarity index 100% rename from test/Bridges/Variable/FreeBridge.jl rename to test/Bridges/Variable/test_FreeBridge.jl diff --git a/test/Bridges/Variable/HermitianToSymmetricPSDBridge.jl b/test/Bridges/Variable/test_HermitianToSymmetricPSDBridge.jl similarity index 100% rename from test/Bridges/Variable/HermitianToSymmetricPSDBridge.jl rename to test/Bridges/Variable/test_HermitianToSymmetricPSDBridge.jl diff --git a/test/Bridges/Variable/NonposToNonnegBridge.jl b/test/Bridges/Variable/test_NonposToNonnegBridge.jl similarity index 100% rename from test/Bridges/Variable/NonposToNonnegBridge.jl rename to test/Bridges/Variable/test_NonposToNonnegBridge.jl diff --git a/test/Bridges/Variable/ParameterToEqualToBridge.jl b/test/Bridges/Variable/test_ParameterToEqualToBridge.jl similarity index 100% rename from test/Bridges/Variable/ParameterToEqualToBridge.jl rename to test/Bridges/Variable/test_ParameterToEqualToBridge.jl diff --git a/test/Bridges/Variable/RSOCtoPSDBridge.jl b/test/Bridges/Variable/test_RSOCtoPSDBridge.jl similarity index 100% rename from test/Bridges/Variable/RSOCtoPSDBridge.jl rename to test/Bridges/Variable/test_RSOCtoPSDBridge.jl diff --git a/test/Bridges/Variable/RSOCtoSOCBridge.jl b/test/Bridges/Variable/test_RSOCtoSOCBridge.jl similarity index 100% rename from test/Bridges/Variable/RSOCtoSOCBridge.jl rename to test/Bridges/Variable/test_RSOCtoSOCBridge.jl diff --git a/test/Bridges/Variable/SOCtoRSOCBridge.jl b/test/Bridges/Variable/test_SOCtoRSOCBridge.jl similarity index 100% rename from test/Bridges/Variable/SOCtoRSOCBridge.jl rename to test/Bridges/Variable/test_SOCtoRSOCBridge.jl diff --git a/test/Bridges/Variable/VectorizeBridge.jl b/test/Bridges/Variable/test_VectorizeBridge.jl similarity index 100% rename from test/Bridges/Variable/VectorizeBridge.jl rename to test/Bridges/Variable/test_VectorizeBridge.jl diff --git a/test/Bridges/Variable/bridge.jl b/test/Bridges/Variable/test_bridge.jl similarity index 100% rename from test/Bridges/Variable/bridge.jl rename to test/Bridges/Variable/test_bridge.jl diff --git a/test/Bridges/Variable/map.jl b/test/Bridges/Variable/test_map.jl similarity index 100% rename from test/Bridges/Variable/map.jl rename to test/Bridges/Variable/test_map.jl diff --git a/test/Bridges/Variable/zeros.jl b/test/Bridges/Variable/test_zeros.jl similarity index 100% rename from test/Bridges/Variable/zeros.jl rename to test/Bridges/Variable/test_zeros.jl diff --git a/test/Bridges/runtests.jl b/test/Bridges/runtests.jl deleted file mode 100644 index 04a4c4069f..0000000000 --- a/test/Bridges/runtests.jl +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -files_to_exclude = - ["runtests.jl", "sdpa_models.jl", "utilities.jl", "identity_bridge.jl"] -@testset "$(file)" for file in readdir(@__DIR__; join = true) - if !endswith(file, ".jl") || any(f -> endswith(file, f), files_to_exclude) - continue - end - include(file) -end diff --git a/test/Bridges/sdpa_models.jl b/test/Bridges/sdpa_models.jl deleted file mode 100644 index 2cde6a1618..0000000000 --- a/test/Bridges/sdpa_models.jl +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -# This file implements models similar to the SDPA format. It gives a good -# example because it does not support a lot of functions, hence the need for -# a lot of bridges. - -MOI.Utilities.@model( - StandardSDPAModel, - (), - (MOI.EqualTo,), - (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), - (), - (), - (MOI.ScalarAffineFunction,), - (MOI.VectorOfVariables,), - () -) - -function MOI.supports_constraint( - ::StandardSDPAModel{T}, - ::Type{MOI.VariableIndex}, - ::Type{ - <:Union{ - MOI.GreaterThan{T}, - MOI.LessThan{T}, - MOI.EqualTo{T}, - MOI.Interval{T}, - MOI.ZeroOne, - MOI.Integer, - }, - }, -) where {T} - return false -end - -function MOI.supports_constraint( - ::StandardSDPAModel{T}, - ::Type{MOI.VectorOfVariables}, - ::Type{MOI.Reals}, -) where {T} - return false -end - -function MOI.supports_add_constrained_variables( - ::StandardSDPAModel, - ::Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}}, -) - return true -end - -function MOI.supports_add_constrained_variables( - ::StandardSDPAModel, - ::Type{MOI.Reals}, -) - return false -end - -function MOI.supports( - ::StandardSDPAModel{T}, - ::MOI.ObjectiveFunction{ - <:Union{ - MOI.VariableIndex, - MOI.ScalarQuadraticFunction{T}, - MOI.ScalarNonlinearFunction, - MOI.VectorOfVariables, - MOI.VectorAffineFunction{T}, - MOI.VectorQuadraticFunction{T}, - MOI.VectorNonlinearFunction, - }, - }, -) where {T} - return false -end - -MOI.Utilities.@model( - GeometricSDPAModel, - (), - (), - (MOI.Zeros, MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), - (), - (), - (), - (), - (MOI.VectorAffineFunction,) -) - -function MOI.supports_constraint( - ::GeometricSDPAModel{T}, - ::Type{MOI.VariableIndex}, - ::Type{ - <:Union{ - MOI.GreaterThan{T}, - MOI.LessThan{T}, - MOI.EqualTo{T}, - MOI.Interval{T}, - MOI.ZeroOne, - MOI.Integer, - }, - }, -) where {T} - return false -end - -function MOI.supports( - ::GeometricSDPAModel{T}, - ::MOI.ObjectiveFunction{ - <:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}}, - }, -) where {T} - return false -end diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/test_CBF.jl similarity index 100% rename from test/FileFormats/CBF/CBF.jl rename to test/FileFormats/CBF/test_CBF.jl diff --git a/test/FileFormats/LP/LP.jl b/test/FileFormats/LP/test_LP.jl similarity index 100% rename from test/FileFormats/LP/LP.jl rename to test/FileFormats/LP/test_LP.jl diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/test_MOF.jl similarity index 100% rename from test/FileFormats/MOF/MOF.jl rename to test/FileFormats/MOF/test_MOF.jl diff --git a/test/FileFormats/MPS/MPS.jl b/test/FileFormats/MPS/test_MPS.jl similarity index 100% rename from test/FileFormats/MPS/MPS.jl rename to test/FileFormats/MPS/test_MPS.jl diff --git a/test/FileFormats/NL/NL.jl b/test/FileFormats/NL/test_NL.jl similarity index 99% rename from test/FileFormats/NL/NL.jl rename to test/FileFormats/NL/test_NL.jl index 7bf70522b2..1532ab999d 100644 --- a/test/FileFormats/NL/NL.jl +++ b/test/FileFormats/NL/test_NL.jl @@ -1535,6 +1535,3 @@ end end TestNLModel.runtests() - -include("read.jl") -include("sol.jl") diff --git a/test/FileFormats/NL/read.jl b/test/FileFormats/NL/test_read.jl similarity index 100% rename from test/FileFormats/NL/read.jl rename to test/FileFormats/NL/test_read.jl diff --git a/test/FileFormats/NL/sol.jl b/test/FileFormats/NL/test_sol.jl similarity index 100% rename from test/FileFormats/NL/sol.jl rename to test/FileFormats/NL/test_sol.jl diff --git a/test/FileFormats/SDPA/SDPA.jl b/test/FileFormats/SDPA/test_SDPA.jl similarity index 100% rename from test/FileFormats/SDPA/SDPA.jl rename to test/FileFormats/SDPA/test_SDPA.jl diff --git a/test/FileFormats/runtests.jl b/test/FileFormats/test_FileFormats.jl similarity index 92% rename from test/FileFormats/runtests.jl rename to test/FileFormats/test_FileFormats.jl index 66d6849029..19fa144af9 100644 --- a/test/FileFormats/runtests.jl +++ b/test/FileFormats/test_FileFormats.jl @@ -36,30 +36,6 @@ function test_default_fallbacks() return end -function test_CBF() - return include(joinpath(@__DIR__, "CBF", "CBF.jl")) -end - -function test_LP() - return include(joinpath(@__DIR__, "LP", "LP.jl")) -end - -function test_MOF() - return include(joinpath(@__DIR__, "MOF", "MOF.jl")) -end - -function test_MPS() - return include(joinpath(@__DIR__, "MPS", "MPS.jl")) -end - -function test_NL() - return include(joinpath(@__DIR__, "NL", "NL.jl")) -end - -function test_SDPA() - return include(joinpath(@__DIR__, "SDPA", "SDPA.jl")) -end - function test_copying() models = [ MOI.FileFormats.CBF.Model, diff --git a/test/General/runtests.jl b/test/General/runtests.jl deleted file mode 100644 index aafbb6d557..0000000000 --- a/test/General/runtests.jl +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -import MathOptInterface as MOI - -@test isempty(Test.detect_ambiguities(MOI; recursive = true)) - -for file in readdir(@__DIR__) - if file in ["issue980.jl", "dummy.jl", "hygiene.jl", "runtests.jl"] - continue - elseif !endswith(file, ".jl") - continue - end - @testset "$(file)" begin - include(file) - end -end diff --git a/test/General/attributes.jl b/test/General/test_attributes.jl similarity index 100% rename from test/General/attributes.jl rename to test/General/test_attributes.jl diff --git a/test/General/constraints.jl b/test/General/test_constraints.jl similarity index 100% rename from test/General/constraints.jl rename to test/General/test_constraints.jl diff --git a/test/General/errors.jl b/test/General/test_errors.jl similarity index 99% rename from test/General/errors.jl rename to test/General/test_errors.jl index 7dadbba14f..0c1b85b5c8 100644 --- a/test/General/errors.jl +++ b/test/General/test_errors.jl @@ -21,6 +21,11 @@ function runtests() end end +function test_method_ambiguities() + @test isempty(Test.detect_ambiguities(MOI; recursive = true)) + return +end + function test_errors_fallback_AddVariableNotAllowed() model = DummyModel() @test_throws MOI.AddVariableNotAllowed MOI.add_variable(model) diff --git a/test/General/functions.jl b/test/General/test_functions.jl similarity index 100% rename from test/General/functions.jl rename to test/General/test_functions.jl diff --git a/test/hygiene.jl b/test/General/test_hygiene.jl similarity index 100% rename from test/hygiene.jl rename to test/General/test_hygiene.jl diff --git a/test/General/instantiate.jl b/test/General/test_instantiate.jl similarity index 100% rename from test/General/instantiate.jl rename to test/General/test_instantiate.jl diff --git a/test/General/sets.jl b/test/General/test_sets.jl similarity index 100% rename from test/General/sets.jl rename to test/General/test_sets.jl diff --git a/test/Nonlinear/runtests.jl b/test/Nonlinear/runtests.jl deleted file mode 100644 index 5a5f69aff7..0000000000 --- a/test/Nonlinear/runtests.jl +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -include("Nonlinear.jl") -include("ReverseAD.jl") -include("SymbolicAD.jl") diff --git a/test/Nonlinear/Nonlinear.jl b/test/Nonlinear/test_Nonlinear.jl similarity index 100% rename from test/Nonlinear/Nonlinear.jl rename to test/Nonlinear/test_Nonlinear.jl diff --git a/test/Nonlinear/ReverseAD.jl b/test/Nonlinear/test_ReverseAD.jl similarity index 100% rename from test/Nonlinear/ReverseAD.jl rename to test/Nonlinear/test_ReverseAD.jl diff --git a/test/Nonlinear/SymbolicAD.jl b/test/Nonlinear/test_SymbolicAD.jl similarity index 100% rename from test/Nonlinear/SymbolicAD.jl rename to test/Nonlinear/test_SymbolicAD.jl diff --git a/test/Test/runtests.jl b/test/Test/test_Test.jl similarity index 100% rename from test/Test/runtests.jl rename to test/Test/test_Test.jl diff --git a/test/Utilities/runtests.jl b/test/Utilities/runtests.jl deleted file mode 100644 index 8c78fb81d1..0000000000 --- a/test/Utilities/runtests.jl +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -using Test - -for file in readdir(@__DIR__) - if file == "runtests.jl" - continue - end - @testset "$(file)" begin - include(file) - end -end diff --git a/test/Utilities/CleverDicts.jl b/test/Utilities/test_CleverDicts.jl similarity index 100% rename from test/Utilities/CleverDicts.jl rename to test/Utilities/test_CleverDicts.jl diff --git a/test/Utilities/DoubleDicts.jl b/test/Utilities/test_DoubleDicts.jl similarity index 100% rename from test/Utilities/DoubleDicts.jl rename to test/Utilities/test_DoubleDicts.jl diff --git a/test/Utilities/cachingoptimizer.jl b/test/Utilities/test_cachingoptimizer.jl similarity index 100% rename from test/Utilities/cachingoptimizer.jl rename to test/Utilities/test_cachingoptimizer.jl diff --git a/test/Utilities/constraints.jl b/test/Utilities/test_constraints.jl similarity index 100% rename from test/Utilities/constraints.jl rename to test/Utilities/test_constraints.jl diff --git a/test/Utilities/copy.jl b/test/Utilities/test_copy.jl similarity index 100% rename from test/Utilities/copy.jl rename to test/Utilities/test_copy.jl diff --git a/test/Utilities/distance_to_set.jl b/test/Utilities/test_distance_to_set.jl similarity index 100% rename from test/Utilities/distance_to_set.jl rename to test/Utilities/test_distance_to_set.jl diff --git a/test/Utilities/functions.jl b/test/Utilities/test_functions.jl similarity index 100% rename from test/Utilities/functions.jl rename to test/Utilities/test_functions.jl diff --git a/test/Utilities/lazy_iterators.jl b/test/Utilities/test_lazy_iterators.jl similarity index 100% rename from test/Utilities/lazy_iterators.jl rename to test/Utilities/test_lazy_iterators.jl diff --git a/test/Utilities/matrix_of_constraints.jl b/test/Utilities/test_matrix_of_constraints.jl similarity index 100% rename from test/Utilities/matrix_of_constraints.jl rename to test/Utilities/test_matrix_of_constraints.jl diff --git a/test/Utilities/mockoptimizer.jl b/test/Utilities/test_mockoptimizer.jl similarity index 100% rename from test/Utilities/mockoptimizer.jl rename to test/Utilities/test_mockoptimizer.jl diff --git a/test/Utilities/model.jl b/test/Utilities/test_model.jl similarity index 100% rename from test/Utilities/model.jl rename to test/Utilities/test_model.jl diff --git a/test/Utilities/mutable_arithmetics.jl b/test/Utilities/test_mutable_arithmetics.jl similarity index 100% rename from test/Utilities/mutable_arithmetics.jl rename to test/Utilities/test_mutable_arithmetics.jl diff --git a/test/Utilities/objective_container.jl b/test/Utilities/test_objective_container.jl similarity index 100% rename from test/Utilities/objective_container.jl rename to test/Utilities/test_objective_container.jl diff --git a/test/Utilities/parser.jl b/test/Utilities/test_parser.jl similarity index 98% rename from test/Utilities/parser.jl rename to test/Utilities/test_parser.jl index b2f09cdbba..4f4c4dacdf 100644 --- a/test/Utilities/parser.jl +++ b/test/Utilities/test_parser.jl @@ -403,21 +403,24 @@ end struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() + if Sys.iswindows() + return # See #2932 + end model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) - MOI.Utilities.loadfromstring!( - model, - "variables: x\nx in $(@__MODULE__).Set2175()", - ) + MOI.Utilities.loadfromstring!(model, "variables: x\nx in $(Set2175())") constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test (MOI.VariableIndex, Set2175) in constraints return end function test_parse_external_set_constrained_variable() + if Sys.iswindows() + return # See #2932 + end model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) MOI.Utilities.loadfromstring!( model, - "constrainedvariable: x in $(@__MODULE__).Set2175()", + "constrainedvariable: x in $(Set2175())", ) constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @test (MOI.VariableIndex, Set2175) in constraints diff --git a/test/Utilities/penalty_relaxation.jl b/test/Utilities/test_penalty_relaxation.jl similarity index 100% rename from test/Utilities/penalty_relaxation.jl rename to test/Utilities/test_penalty_relaxation.jl diff --git a/test/Utilities/print.jl b/test/Utilities/test_print.jl similarity index 100% rename from test/Utilities/print.jl rename to test/Utilities/test_print.jl diff --git a/test/Utilities/product_of_sets.jl b/test/Utilities/test_product_of_sets.jl similarity index 100% rename from test/Utilities/product_of_sets.jl rename to test/Utilities/test_product_of_sets.jl diff --git a/test/Utilities/results.jl b/test/Utilities/test_results.jl similarity index 100% rename from test/Utilities/results.jl rename to test/Utilities/test_results.jl diff --git a/test/Utilities/set_dot.jl b/test/Utilities/test_set_dot.jl similarity index 100% rename from test/Utilities/set_dot.jl rename to test/Utilities/test_set_dot.jl diff --git a/test/Utilities/sets.jl b/test/Utilities/test_sets.jl similarity index 100% rename from test/Utilities/sets.jl rename to test/Utilities/test_sets.jl diff --git a/test/Utilities/sparse_matrix.jl b/test/Utilities/test_sparse_matrix.jl similarity index 100% rename from test/Utilities/sparse_matrix.jl rename to test/Utilities/test_sparse_matrix.jl diff --git a/test/Utilities/test_operate!.jl b/test/Utilities/test_test_operate!.jl similarity index 100% rename from test/Utilities/test_operate!.jl rename to test/Utilities/test_test_operate!.jl diff --git a/test/Utilities/test_promote_operation.jl b/test/Utilities/test_test_promote_operation.jl similarity index 100% rename from test/Utilities/test_promote_operation.jl rename to test/Utilities/test_test_promote_operation.jl diff --git a/test/Utilities/universalfallback.jl b/test/Utilities/test_universalfallback.jl similarity index 100% rename from test/Utilities/universalfallback.jl rename to test/Utilities/test_universalfallback.jl diff --git a/test/Utilities/variable_container.jl b/test/Utilities/test_variable_container.jl similarity index 100% rename from test/Utilities/variable_container.jl rename to test/Utilities/test_variable_container.jl diff --git a/test/Utilities/variables.jl b/test/Utilities/test_variables.jl similarity index 100% rename from test/Utilities/variables.jl rename to test/Utilities/test_variables.jl diff --git a/test/runtests.jl b/test/runtests.jl index 4c7b8f0683..5070eeb658 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,7 +10,7 @@ # # * General # * Benchmarks -# * Bridges +# * Bridges/General # * Bridges/Constraint # * Bridges/Objective # * Bridges/Variable @@ -28,7 +28,7 @@ include("issue980.jl") MODULES_TO_TEST = get( ENV, "MOI_TEST_MODULES", - "General;Benchmarks;Bridges;Bridges/Constraint;Bridges/Objective;Bridges/Variable;FileFormats;Nonlinear;Test;Utilities", + "General;Benchmarks;Bridges/General;Bridges/Constraint;Bridges/Objective;Bridges/Variable;FileFormats;Nonlinear;Test;Utilities", ) """ @@ -44,27 +44,33 @@ function. Thus, some warnings may appear in the wrong place. This function requires Julia to be started with `--warn-overwrite=true`. """ -function include_with_method_redefinition_check(jl_filename) - stderr_filename = tempname() - open(stderr_filename, "w") do io - return redirect_stderr(() -> include(jl_filename), io) +const init_code = quote + function include_with_method_redefinition_check(jl_filename) + stderr_filename = tempname() + open(stderr_filename, "w") do io + return redirect_stderr(() -> include(jl_filename), io) + end + contents = read(stderr_filename, String) + print(stderr, contents) + regex = + r"WARNING: Method definition (.+?) in module (.+?) at (.+?) overwritten at (.+?)\n" + if match(regex, contents) !== nothing + error("Found overwritten method in $jl_filename") + end + return end - contents = read(stderr_filename, String) - print(stderr, contents) - regex = - r"WARNING: Method definition (.+?) in module (.+?) at (.+?) overwritten at (.+?)\n" - if match(regex, contents) !== nothing - error("Found overwritten method") - end - return end -for submodule in split(MODULES_TO_TEST, ";") - include_with_method_redefinition_check("$(submodule)/runtests.jl") - GC.gc() # Force GC run here to reduce memory pressure -end +import MathOptInterface +import ParallelTestRunner -if occursin("General", MODULES_TO_TEST) - # Test hygiene of @model macro - include("hygiene.jl") -end +is_test_file(f) = startswith(f, "test_") && endswith(f, ".jl") + +testsuite = Dict{String,Expr}( + file => :(include_with_method_redefinition_check($file)) for + submodule in split(MODULES_TO_TEST, ";") for + (root, dirs, files) in walkdir(submodule) for + file in joinpath.(root, filter(is_test_file, files)) +) + +ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code)