From bdf372252c89a2fb2cd5790012926e2bd9346840 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 30 Jan 2026 15:43:28 +1300 Subject: [PATCH 01/13] Use ParallelTestRunner.jl to parallelize the tests update Update Update Update --- .github/workflows/ci.yml | 2 +- Project.toml | 4 +- .../{runtests.jl => test_Benchmarks.jl} | 0 test/Bridges/Constraint/runtests.jl | 14 - ...test_AllDifferentToCountDistinctBridge.jl} | 0 ...idge.jl => test_BinPackingToMILPBridge.jl} | 0 ...PBridge.jl => test_CircuitToMILPBridge.jl} | 0 ...lexNormInfinityToSecondOrderConeBridge.jl} | 0 ... test_CountAtLeastToCountBelongsBridge.jl} | 0 ...ge.jl => test_CountBelongsToMILPBridge.jl} | 0 ...e.jl => test_CountDistinctToMILPBridge.jl} | 0 ...l => test_CountGreaterThanToMILPBridge.jl} | 0 ...ialConeToScalarNonlinearFunctionBridge.jl} | 0 ...GeoMeanBridge.jl => test_GeoMeanBridge.jl} | 0 ....jl => test_GeoMeanToPowerBridgeBridge.jl} | 0 ...idge.jl => test_GeoMeantoRelEntrBridge.jl} | 0 ...dge.jl => test_GreaterToIntervalBridge.jl} | 0 ...sBridge.jl => test_GreaterToLessBridge.jl} | 0 ...test_HermitianToComplexSymmetricBridge.jl} | 0 ... => test_HermitianToSymmetricPSDBridge.jl} | 0 ...l => test_IndicatorActiveOnFalseBridge.jl} | 0 ... test_IndicatorLessToGreaterThanBridge.jl} | 0 ...1Bridge.jl => test_IndicatorSOS1Bridge.jl} | 0 ...ridge.jl => test_IndicatorToMILPBridge.jl} | 0 ... => test_InequalityToComplementsBridge.jl} | 0 ...idge.jl => test_IntegerToZeroOneBridge.jl} | 0 ...=> test_IntervalToHyperRectangleBridge.jl} | 0 .../{LogDetBridge.jl => test_LogDetBridge.jl} | 0 ...tyBridge.jl => test_NormInfinityBridge.jl} | 0 ...NormOneBridge.jl => test_NormOneBridge.jl} | 0 ...jl => test_NormOneConeToNormConeBridge.jl} | 0 ...alBridge.jl => test_NormSpectralBridge.jl} | 0 ...werBridge.jl => test_NormToPowerBridge.jl} | 0 ...idge.jl => test_NumberConversionBridge.jl} | 0 ...toSOCBridge.jl => test_QuadtoSOCBridge.jl} | 0 .../{RSOCBridge.jl => test_RSOCBridge.jl} | 0 ...e.jl => test_RSOCtoNonConvexQuadBridge.jl} | 0 ...ifiedAllDifferentToCountDistinctBridge.jl} | 0 ... test_ReifiedCountDistinctToMILPBridge.jl} | 0 ...ridge.jl => test_RelativeEntropyBridge.jl} | 0 ...CtoPSDBridge.jl => test_SOCtoPSDBridge.jl} | 0 ...MILPBridge.jl => test_SOS1ToMILPBridge.jl} | 0 ...MILPBridge.jl => test_SOS2ToMILPBridge.jl} | 0 ...dge.jl => test_ScalarFunctionizeBridge.jl} | 0 ...ackBridge.jl => test_ScalarSlackBridge.jl} | 0 ...arizeBridge.jl => test_ScalarizeBridge.jl} | 0 ...ryBridge.jl => test_SemiToBinaryBridge.jl} | 0 ...nBridge.jl => test_SetConversionBridge.jl} | 0 ...gBridge.jl => test_SetDotScalingBridge.jl} | 0 ...e.jl => test_SplitComplexEqualToBridge.jl} | 0 ...est_SplitComplexIndicatorEqualToBridge.jl} | 0 ...dge.jl => test_SplitComplexZerosBridge.jl} | 0 ...e.jl => test_SplitHyperRectangleBridge.jl} | 0 ...lBridge.jl => test_SplitIntervalBridge.jl} | 0 .../{SquareBridge.jl => test_SquareBridge.jl} | 0 ...ILPBridge.jl => test_TableToMILPBridge.jl} | 0 ...orizeBridge.jl => test_VectorizeBridge.jl} | 0 ...ZeroOneBridge.jl => test_ZeroOneBridge.jl} | 0 .../Constraint/{bridge.jl => test_bridge.jl} | 0 .../Constraint/{map.jl => test_map.jl} | 0 test/Bridges/{ => General}/identity_bridge.jl | 0 .../test_bridge_optimizer.jl} | 2 +- .../{debug.jl => General/test_debug.jl} | 0 .../test_lazy_bridge_optimizer.jl} | 113 ++++- .../{set_map.jl => General/test_set_map.jl} | 0 test/Bridges/Objective/runtests.jl | 14 - ...ge.jl => test_FunctionConversionBridge.jl} | 0 ...izeBridge.jl => test_FunctionizeBridge.jl} | 0 ...tizeBridge.jl => test_QuadratizeBridge.jl} | 0 .../{SlackBridge.jl => test_SlackBridge.jl} | 0 ...dge.jl => test_ToScalarNonlinearBridge.jl} | 0 ...dge.jl => test_VectorFunctionizeBridge.jl} | 0 ...ackBridge.jl => test_VectorSlackBridge.jl} | 0 .../Bridges/Objective/{map.jl => test_map.jl} | 0 test/Bridges/Variable/runtests.jl | 14 - .../{FreeBridge.jl => test_FreeBridge.jl} | 0 ... => test_HermitianToSymmetricPSDBridge.jl} | 0 ...Bridge.jl => test_NonposToNonnegBridge.jl} | 0 ...ge.jl => test_ParameterToEqualToBridge.jl} | 0 ...toPSDBridge.jl => test_RSOCtoPSDBridge.jl} | 0 ...toSOCBridge.jl => test_RSOCtoSOCBridge.jl} | 0 ...oRSOCBridge.jl => test_SOCtoRSOCBridge.jl} | 0 ...orizeBridge.jl => test_VectorizeBridge.jl} | 0 .../Variable/{bridge.jl => test_bridge.jl} | 0 test/Bridges/Variable/{map.jl => test_map.jl} | 0 .../Variable/{zeros.jl => test_zeros.jl} | 0 test/Bridges/runtests.jl | 16 - test/Bridges/sdpa_models.jl | 115 ----- test/FileFormats/CBF/{CBF.jl => test_CBF.jl} | 0 test/FileFormats/LP/{LP.jl => test_LP.jl} | 0 test/FileFormats/MOF/{MOF.jl => test_MOF.jl} | 0 test/FileFormats/MPS/{MPS.jl => test_MPS.jl} | 0 test/FileFormats/NL/{NL.jl => test_NL.jl} | 3 - test/FileFormats/NL/{read.jl => test_read.jl} | 0 test/FileFormats/NL/{sol.jl => test_sol.jl} | 0 .../SDPA/{SDPA.jl => test_SDPA.jl} | 0 .../{runtests.jl => test_FileFormats.jl} | 24 - test/General/runtests.jl | 22 - .../{attributes.jl => test_attributes.jl} | 0 .../{constraints.jl => test_constraints.jl} | 0 test/General/{errors.jl => test_errors.jl} | 5 + .../{functions.jl => test_functions.jl} | 0 test/{hygiene.jl => General/test_hygiene.jl} | 0 .../{instantiate.jl => test_instantiate.jl} | 0 test/General/{sets.jl => test_sets.jl} | 0 test/Nonlinear/runtests.jl | 9 - .../{Nonlinear.jl => test_Nonlinear.jl} | 0 .../{ReverseAD.jl => test_ReverseAD.jl} | 0 .../{SymbolicAD.jl => test_SymbolicAD.jl} | 0 test/Test/{runtests.jl => test_Test.jl} | 0 test/Utilities/parser.jl | 7 +- test/Utilities/runtests.jl | 16 - .../{CleverDicts.jl => test_CleverDicts.jl} | 0 .../{DoubleDicts.jl => test_DoubleDicts.jl} | 0 ...goptimizer.jl => test_cachingoptimizer.jl} | 0 .../{constraints.jl => test_constraints.jl} | 0 test/Utilities/{copy.jl => test_copy.jl} | 0 ...ance_to_set.jl => test_distance_to_set.jl} | 0 .../{functions.jl => test_functions.jl} | 0 ...zy_iterators.jl => test_lazy_iterators.jl} | 0 ...aints.jl => test_matrix_of_constraints.jl} | 0 ...mockoptimizer.jl => test_mockoptimizer.jl} | 0 test/Utilities/{model.jl => test_model.jl} | 0 ...hmetics.jl => test_mutable_arithmetics.jl} | 0 ...ntainer.jl => test_objective_container.jl} | 0 test/Utilities/test_parser.jl | 454 ++++++++++++++++++ ...laxation.jl => test_penalty_relaxation.jl} | 0 test/Utilities/{print.jl => test_print.jl} | 0 ...uct_of_sets.jl => test_product_of_sets.jl} | 0 .../Utilities/{results.jl => test_results.jl} | 0 .../Utilities/{set_dot.jl => test_set_dot.jl} | 0 test/Utilities/{sets.jl => test_sets.jl} | 0 ...sparse_matrix.jl => test_sparse_matrix.jl} | 0 ...test_operate!.jl => test_test_operate!.jl} | 0 ...tion.jl => test_test_promote_operation.jl} | 0 ...lfallback.jl => test_universalfallback.jl} | 0 ...ontainer.jl => test_variable_container.jl} | 0 .../{variables.jl => test_variables.jl} | 0 test/runtests.jl | 50 +- 139 files changed, 605 insertions(+), 279 deletions(-) rename test/Benchmarks/{runtests.jl => test_Benchmarks.jl} (100%) delete mode 100644 test/Bridges/Constraint/runtests.jl rename test/Bridges/Constraint/{AllDifferentToCountDistinctBridge.jl => test_AllDifferentToCountDistinctBridge.jl} (100%) rename test/Bridges/Constraint/{BinPackingToMILPBridge.jl => test_BinPackingToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{CircuitToMILPBridge.jl => test_CircuitToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{ComplexNormInfinityToSecondOrderConeBridge.jl => test_ComplexNormInfinityToSecondOrderConeBridge.jl} (100%) rename test/Bridges/Constraint/{CountAtLeastToCountBelongsBridge.jl => test_CountAtLeastToCountBelongsBridge.jl} (100%) rename test/Bridges/Constraint/{CountBelongsToMILPBridge.jl => test_CountBelongsToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{CountDistinctToMILPBridge.jl => test_CountDistinctToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{CountGreaterThanToMILPBridge.jl => test_CountGreaterThanToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{ExponentialConeToScalarNonlinearFunctionBridge.jl => test_ExponentialConeToScalarNonlinearFunctionBridge.jl} (100%) rename test/Bridges/Constraint/{GeoMeanBridge.jl => test_GeoMeanBridge.jl} (100%) rename test/Bridges/Constraint/{GeoMeanToPowerBridgeBridge.jl => test_GeoMeanToPowerBridgeBridge.jl} (100%) rename test/Bridges/Constraint/{GeoMeantoRelEntrBridge.jl => test_GeoMeantoRelEntrBridge.jl} (100%) rename test/Bridges/Constraint/{GreaterToIntervalBridge.jl => test_GreaterToIntervalBridge.jl} (100%) rename test/Bridges/Constraint/{GreaterToLessBridge.jl => test_GreaterToLessBridge.jl} (100%) rename test/Bridges/Constraint/{HermitianToComplexSymmetricBridge.jl => test_HermitianToComplexSymmetricBridge.jl} (100%) rename test/Bridges/Constraint/{HermitianToSymmetricPSDBridge.jl => test_HermitianToSymmetricPSDBridge.jl} (100%) rename test/Bridges/Constraint/{IndicatorActiveOnFalseBridge.jl => test_IndicatorActiveOnFalseBridge.jl} (100%) rename test/Bridges/Constraint/{IndicatorLessToGreaterThanBridge.jl => test_IndicatorLessToGreaterThanBridge.jl} (100%) rename test/Bridges/Constraint/{IndicatorSOS1Bridge.jl => test_IndicatorSOS1Bridge.jl} (100%) rename test/Bridges/Constraint/{IndicatorToMILPBridge.jl => test_IndicatorToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{InequalityToComplementsBridge.jl => test_InequalityToComplementsBridge.jl} (100%) rename test/Bridges/Constraint/{IntegerToZeroOneBridge.jl => test_IntegerToZeroOneBridge.jl} (100%) rename test/Bridges/Constraint/{IntervalToHyperRectangleBridge.jl => test_IntervalToHyperRectangleBridge.jl} (100%) rename test/Bridges/Constraint/{LogDetBridge.jl => test_LogDetBridge.jl} (100%) rename test/Bridges/Constraint/{NormInfinityBridge.jl => test_NormInfinityBridge.jl} (100%) rename test/Bridges/Constraint/{NormOneBridge.jl => test_NormOneBridge.jl} (100%) rename test/Bridges/Constraint/{NormOneConeToNormConeBridge.jl => test_NormOneConeToNormConeBridge.jl} (100%) rename test/Bridges/Constraint/{NormSpectralBridge.jl => test_NormSpectralBridge.jl} (100%) rename test/Bridges/Constraint/{NormToPowerBridge.jl => test_NormToPowerBridge.jl} (100%) rename test/Bridges/Constraint/{NumberConversionBridge.jl => test_NumberConversionBridge.jl} (100%) rename test/Bridges/Constraint/{QuadtoSOCBridge.jl => test_QuadtoSOCBridge.jl} (100%) rename test/Bridges/Constraint/{RSOCBridge.jl => test_RSOCBridge.jl} (100%) rename test/Bridges/Constraint/{RSOCtoNonConvexQuadBridge.jl => test_RSOCtoNonConvexQuadBridge.jl} (100%) rename test/Bridges/Constraint/{ReifiedAllDifferentToCountDistinctBridge.jl => test_ReifiedAllDifferentToCountDistinctBridge.jl} (100%) rename test/Bridges/Constraint/{ReifiedCountDistinctToMILPBridge.jl => test_ReifiedCountDistinctToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{RelativeEntropyBridge.jl => test_RelativeEntropyBridge.jl} (100%) rename test/Bridges/Constraint/{SOCtoPSDBridge.jl => test_SOCtoPSDBridge.jl} (100%) rename test/Bridges/Constraint/{SOS1ToMILPBridge.jl => test_SOS1ToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{SOS2ToMILPBridge.jl => test_SOS2ToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{ScalarFunctionizeBridge.jl => test_ScalarFunctionizeBridge.jl} (100%) rename test/Bridges/Constraint/{ScalarSlackBridge.jl => test_ScalarSlackBridge.jl} (100%) rename test/Bridges/Constraint/{ScalarizeBridge.jl => test_ScalarizeBridge.jl} (100%) rename test/Bridges/Constraint/{SemiToBinaryBridge.jl => test_SemiToBinaryBridge.jl} (100%) rename test/Bridges/Constraint/{SetConversionBridge.jl => test_SetConversionBridge.jl} (100%) rename test/Bridges/Constraint/{SetDotScalingBridge.jl => test_SetDotScalingBridge.jl} (100%) rename test/Bridges/Constraint/{SplitComplexEqualToBridge.jl => test_SplitComplexEqualToBridge.jl} (100%) rename test/Bridges/Constraint/{SplitComplexIndicatorEqualToBridge.jl => test_SplitComplexIndicatorEqualToBridge.jl} (100%) rename test/Bridges/Constraint/{SplitComplexZerosBridge.jl => test_SplitComplexZerosBridge.jl} (100%) rename test/Bridges/Constraint/{SplitHyperRectangleBridge.jl => test_SplitHyperRectangleBridge.jl} (100%) rename test/Bridges/Constraint/{SplitIntervalBridge.jl => test_SplitIntervalBridge.jl} (100%) rename test/Bridges/Constraint/{SquareBridge.jl => test_SquareBridge.jl} (100%) rename test/Bridges/Constraint/{TableToMILPBridge.jl => test_TableToMILPBridge.jl} (100%) rename test/Bridges/Constraint/{VectorizeBridge.jl => test_VectorizeBridge.jl} (100%) rename test/Bridges/Constraint/{ZeroOneBridge.jl => test_ZeroOneBridge.jl} (100%) rename test/Bridges/Constraint/{bridge.jl => test_bridge.jl} (100%) rename test/Bridges/Constraint/{map.jl => test_map.jl} (100%) rename test/Bridges/{ => General}/identity_bridge.jl (100%) rename test/Bridges/{bridge_optimizer.jl => General/test_bridge_optimizer.jl} (99%) rename test/Bridges/{debug.jl => General/test_debug.jl} (100%) rename test/Bridges/{lazy_bridge_optimizer.jl => General/test_lazy_bridge_optimizer.jl} (97%) rename test/Bridges/{set_map.jl => General/test_set_map.jl} (100%) delete mode 100644 test/Bridges/Objective/runtests.jl rename test/Bridges/Objective/{FunctionConversionBridge.jl => test_FunctionConversionBridge.jl} (100%) rename test/Bridges/Objective/{FunctionizeBridge.jl => test_FunctionizeBridge.jl} (100%) rename test/Bridges/Objective/{QuadratizeBridge.jl => test_QuadratizeBridge.jl} (100%) rename test/Bridges/Objective/{SlackBridge.jl => test_SlackBridge.jl} (100%) rename test/Bridges/Objective/{ToScalarNonlinearBridge.jl => test_ToScalarNonlinearBridge.jl} (100%) rename test/Bridges/Objective/{VectorFunctionizeBridge.jl => test_VectorFunctionizeBridge.jl} (100%) rename test/Bridges/Objective/{VectorSlackBridge.jl => test_VectorSlackBridge.jl} (100%) rename test/Bridges/Objective/{map.jl => test_map.jl} (100%) delete mode 100644 test/Bridges/Variable/runtests.jl rename test/Bridges/Variable/{FreeBridge.jl => test_FreeBridge.jl} (100%) rename test/Bridges/Variable/{HermitianToSymmetricPSDBridge.jl => test_HermitianToSymmetricPSDBridge.jl} (100%) rename test/Bridges/Variable/{NonposToNonnegBridge.jl => test_NonposToNonnegBridge.jl} (100%) rename test/Bridges/Variable/{ParameterToEqualToBridge.jl => test_ParameterToEqualToBridge.jl} (100%) rename test/Bridges/Variable/{RSOCtoPSDBridge.jl => test_RSOCtoPSDBridge.jl} (100%) rename test/Bridges/Variable/{RSOCtoSOCBridge.jl => test_RSOCtoSOCBridge.jl} (100%) rename test/Bridges/Variable/{SOCtoRSOCBridge.jl => test_SOCtoRSOCBridge.jl} (100%) rename test/Bridges/Variable/{VectorizeBridge.jl => test_VectorizeBridge.jl} (100%) rename test/Bridges/Variable/{bridge.jl => test_bridge.jl} (100%) rename test/Bridges/Variable/{map.jl => test_map.jl} (100%) rename test/Bridges/Variable/{zeros.jl => test_zeros.jl} (100%) delete mode 100644 test/Bridges/runtests.jl delete mode 100644 test/Bridges/sdpa_models.jl rename test/FileFormats/CBF/{CBF.jl => test_CBF.jl} (100%) rename test/FileFormats/LP/{LP.jl => test_LP.jl} (100%) rename test/FileFormats/MOF/{MOF.jl => test_MOF.jl} (100%) rename test/FileFormats/MPS/{MPS.jl => test_MPS.jl} (100%) rename test/FileFormats/NL/{NL.jl => test_NL.jl} (99%) rename test/FileFormats/NL/{read.jl => test_read.jl} (100%) rename test/FileFormats/NL/{sol.jl => test_sol.jl} (100%) rename test/FileFormats/SDPA/{SDPA.jl => test_SDPA.jl} (100%) rename test/FileFormats/{runtests.jl => test_FileFormats.jl} (92%) delete mode 100644 test/General/runtests.jl rename test/General/{attributes.jl => test_attributes.jl} (100%) rename test/General/{constraints.jl => test_constraints.jl} (100%) rename test/General/{errors.jl => test_errors.jl} (99%) rename test/General/{functions.jl => test_functions.jl} (100%) rename test/{hygiene.jl => General/test_hygiene.jl} (100%) rename test/General/{instantiate.jl => test_instantiate.jl} (100%) rename test/General/{sets.jl => test_sets.jl} (100%) delete mode 100644 test/Nonlinear/runtests.jl rename test/Nonlinear/{Nonlinear.jl => test_Nonlinear.jl} (100%) rename test/Nonlinear/{ReverseAD.jl => test_ReverseAD.jl} (100%) rename test/Nonlinear/{SymbolicAD.jl => test_SymbolicAD.jl} (100%) rename test/Test/{runtests.jl => test_Test.jl} (100%) delete mode 100644 test/Utilities/runtests.jl rename test/Utilities/{CleverDicts.jl => test_CleverDicts.jl} (100%) rename test/Utilities/{DoubleDicts.jl => test_DoubleDicts.jl} (100%) rename test/Utilities/{cachingoptimizer.jl => test_cachingoptimizer.jl} (100%) rename test/Utilities/{constraints.jl => test_constraints.jl} (100%) rename test/Utilities/{copy.jl => test_copy.jl} (100%) rename test/Utilities/{distance_to_set.jl => test_distance_to_set.jl} (100%) rename test/Utilities/{functions.jl => test_functions.jl} (100%) rename test/Utilities/{lazy_iterators.jl => test_lazy_iterators.jl} (100%) rename test/Utilities/{matrix_of_constraints.jl => test_matrix_of_constraints.jl} (100%) rename test/Utilities/{mockoptimizer.jl => test_mockoptimizer.jl} (100%) rename test/Utilities/{model.jl => test_model.jl} (100%) rename test/Utilities/{mutable_arithmetics.jl => test_mutable_arithmetics.jl} (100%) rename test/Utilities/{objective_container.jl => test_objective_container.jl} (100%) create mode 100644 test/Utilities/test_parser.jl rename test/Utilities/{penalty_relaxation.jl => test_penalty_relaxation.jl} (100%) rename test/Utilities/{print.jl => test_print.jl} (100%) rename test/Utilities/{product_of_sets.jl => test_product_of_sets.jl} (100%) rename test/Utilities/{results.jl => test_results.jl} (100%) rename test/Utilities/{set_dot.jl => test_set_dot.jl} (100%) rename test/Utilities/{sets.jl => test_sets.jl} (100%) rename test/Utilities/{sparse_matrix.jl => test_sparse_matrix.jl} (100%) rename test/Utilities/{test_operate!.jl => test_test_operate!.jl} (100%) rename test/Utilities/{test_promote_operation.jl => test_test_promote_operation.jl} (100%) rename test/Utilities/{universalfallback.jl => test_universalfallback.jl} (100%) rename test/Utilities/{variable_container.jl => test_variable_container.jl} (100%) rename test/Utilities/{variables.jl => test_variables.jl} (100%) 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/parser.jl b/test/Utilities/parser.jl index b2f09cdbba..d3c0101946 100644 --- a/test/Utilities/parser.jl +++ b/test/Utilities/parser.jl @@ -404,10 +404,7 @@ struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() 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 @@ -417,7 +414,7 @@ function test_parse_external_set_constrained_variable() 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/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/test_parser.jl b/test/Utilities/test_parser.jl new file mode 100644 index 0000000000..b2f09cdbba --- /dev/null +++ b/test/Utilities/test_parser.jl @@ -0,0 +1,454 @@ +# 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. + +module TestParser + +using Test + +import MathOptInterface as MOI +import MathOptInterface.Utilities as MOIU + +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 _struct_isequal(a::T, b::T) where {T} + return all(f -> getfield(a, f) == getfield(b, f), fieldnames(T)) +end + +function test__parse_function() + @test _struct_isequal( + MOIU._parse_function(:x), + MOIU._ParsedVariableIndex(:x), + ) + @test _struct_isequal( + MOIU._parse_function(:([x, y, z])), + MOIU._ParsedVectorOfVariables([:x, :y, :z]), + ) + + @test _struct_isequal( + MOIU._parse_function(:(x + y + 2.0)), + MOIU._ParsedScalarAffineFunction( + MOIU._ParsedScalarAffineTerm.([1.0, 1.0], [:x, :y]), + 2.0, + ), + ) + @test _struct_isequal( + MOIU._parse_function(:(x + -3y + 2.0)), + MOIU._ParsedScalarAffineFunction( + MOIU._ParsedScalarAffineTerm.([1.0, -3.0], [:x, :y]), + 2.0, + ), + ) + @test _struct_isequal( + MOIU._parse_function(:(2 * x * y + y + 1.0)), + MOIU._ParsedScalarQuadraticFunction( + MOIU._ParsedScalarQuadraticTerm.([2.0], [:x], [:y]), + MOIU._ParsedScalarAffineTerm.([1.0], [:y]), + 1.0, + ), + ) + + err = ErrorException( + "Unsupported operator in `loadfromstring!`: `-`. " * + "The parser is deliberately limited in the syntax it " * + "accepts. Write `x - y` as `x + -1 * y`, and `x^2` as " * + "`x * x`.", + ) + @test_throws err MOIU._parse_function(:(x - y)) + + @test _struct_isequal( + MOIU._parse_function(:([x, 2x + y + 5.0])), + MOIU._ParsedVectorAffineFunction( + MOIU._ParsedVectorAffineTerm.( + Int64[1, 2, 2], + MOIU._ParsedScalarAffineTerm.([1.0, 2.0, 1.0], [:x, :x, :y]), + ), + [0.0, 5.0], + ), + ) + @test _struct_isequal( + MOIU._parse_function(:([x, 2x + y + 5.0, 1 * x * x])), + MOIU._ParsedVectorQuadraticFunction( + MOIU._ParsedVectorQuadraticTerm.( + Int64[3], + MOIU._ParsedScalarQuadraticTerm.([2.0], [:x], [:x]), + ), + MOIU._ParsedVectorAffineTerm.( + Int64[1, 2, 2], + MOIU._ParsedScalarAffineTerm.([1.0, 2.0, 1.0], [:x, :x, :y]), + ), + [0.0, 5.0, 0.0], + ), + ) + return +end + +function test__separate_label() + @test MOIU._separate_label(:(variables:x)) == (:variables, :x) + @test MOIU._separate_label(:(variables:x, y)) == (:variables, :((x, y))) + @test MOIU._separate_label(:(minobjective:(x+y))) == + (:minobjective, :(x + y)) + @test MOIU._separate_label(:(con1:2x <= 1)) == (:con1, :(2x <= 1)) + @test MOIU._separate_label(:(con1:[x, y] in S)) == (:con1, :([x, y] in S)) + return +end + +function test_one_variable() + s = """ + variables: x + x >= 1.0 + """ + model = MOIU.Model{Float64}() + x = MOI.add_variable(model) + MOI.set(model, MOI.VariableName(), x, "x") + bound = MOI.add_constraint(model, x, MOI.GreaterThan(1.0)) + + model2 = MOIU.Model{Float64}() + MOIU.loadfromstring!(model2, s) + MOI.Test.util_test_models_equal( + model, + model2, + ["x"], + String[], + [("x", MOI.GreaterThan{Float64}(1.0))], + ) + return +end + +function test_linear_constraints() + s = """ + variables: x, y + linear1: x + y >= 1.0 + linear2: x + y <= 1.0 + linear3: x + y == 1.0 + """ + model = MOIU.Model{Float64}() + x = MOI.add_variable(model) + y = MOI.add_variable(model) + MOI.set(model, MOI.VariableName(), x, "x") + MOI.set(model, MOI.VariableName(), y, "y") + linear1 = MOI.add_constraint( + model, + MOI.ScalarAffineFunction( + MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), + 0.0, + ), + MOI.GreaterThan(1.0), + ) + linear2 = MOI.add_constraint( + model, + MOI.ScalarAffineFunction( + MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), + 0.0, + ), + MOI.LessThan(1.0), + ) + linear3 = MOI.add_constraint( + model, + MOI.ScalarAffineFunction( + MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), + 0.0, + ), + MOI.EqualTo(1.0), + ) + MOI.set(model, MOI.ConstraintName(), linear1, "linear1") + MOI.set(model, MOI.ConstraintName(), linear2, "linear2") + MOI.set(model, MOI.ConstraintName(), linear3, "linear3") + + model2 = MOIU.Model{Float64}() + MOIU.loadfromstring!(model2, s) + MOI.Test.util_test_models_equal( + model, + model2, + ["x", "y"], + ["linear1", "linear2", "linear3"], + ) + return +end + +function test_minimization_linear_objective() + s = """ + variables: x, y + minobjective: x + -2y + 1.0 + """ + model = MOIU.Model{Float64}() + x = MOI.add_variable(model) + y = MOI.add_variable(model) + MOI.set(model, MOI.VariableName(), x, "x") + MOI.set(model, MOI.VariableName(), y, "y") + MOI.set( + model, + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), + MOI.ScalarAffineFunction( + MOI.ScalarAffineTerm.([1.0, -2.0], [x, y]), + 1.0, + ), + ) + MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) + + model2 = MOIU.Model{Float64}() + MOIU.loadfromstring!(model2, s) + MOI.Test.util_test_models_equal(model, model2, ["x", "y"], String[]) + return +end + +function test_maximization_linear_objective() + s = """ + variables: x, y + maxobjective: x + -2y + 1.0 + """ + model = MOIU.Model{Float64}() + x = MOI.add_variable(model) + y = MOI.add_variable(model) + MOI.set(model, MOI.VariableName(), x, "x") + MOI.set(model, MOI.VariableName(), y, "y") + MOI.set( + model, + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), + MOI.ScalarAffineFunction( + MOI.ScalarAffineTerm.([1.0, -2.0], [x, y]), + 1.0, + ), + ) + MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) + + model2 = MOIU.Model{Float64}() + MOIU.loadfromstring!(model2, s) + MOI.Test.util_test_models_equal(model, model2, ["x", "y"], String[]) + return +end + +function test_SecondOrderCone_constraints() + s = """ + variables: x, y, z + varsoc: [x,y,z] in SecondOrderCone(3) + affsoc: [2x,y+1,-1*z] in SecondOrderCone(3) + affsoc2: [1.0,2.0,3.0] in SecondOrderCone(3) + """ + model = MOIU.Model{Float64}() + x = MOI.add_variable(model) + y = MOI.add_variable(model) + z = MOI.add_variable(model) + MOI.set(model, MOI.VariableName(), x, "x") + MOI.set(model, MOI.VariableName(), y, "y") + MOI.set(model, MOI.VariableName(), z, "z") + varsoc = MOI.add_constraint( + model, + MOI.VectorOfVariables([x, y, z]), + MOI.SecondOrderCone(3), + ) + affsoc = MOI.add_constraint( + model, + MOI.VectorAffineFunction( + MOI.VectorAffineTerm.( + [1, 2, 3], + MOI.ScalarAffineTerm.([2.0, 1.0, -1.0], [x, y, z]), + ), + [0.0, 1.0, 0.0], + ), + MOI.SecondOrderCone(3), + ) + affsoc2 = MOI.add_constraint( + model, + MOI.VectorAffineFunction( + MOI.VectorAffineTerm{Float64}[], + [1.0, 2.0, 3.0], + ), + MOI.SecondOrderCone(3), + ) + MOI.set(model, MOI.ConstraintName(), varsoc, "varsoc") + MOI.set(model, MOI.ConstraintName(), affsoc, "affsoc") + MOI.set(model, MOI.ConstraintName(), affsoc2, "affsoc2") + + model2 = MOIU.Model{Float64}() + MOIU.loadfromstring!(model2, s) + MOI.Test.util_test_models_equal( + model, + model2, + ["x", "y", "z"], + ["varsoc", "affsoc", "affsoc2"], + ) + return +end + +function test_Invalid_variable_name() + s = """ + variables: x + y >= 1.0 + """ + model = MOIU.Model{Float64}() + err = ErrorException("Invalid variable name y.") + @test_throws err MOIU.loadfromstring!(model, s) + return +end + +function test_constrained_variables() + model = MOI.Utilities.Model{Float64}() + text = """ + constrainedvariable: [a, b, c] in Nonnegatives(3) + constrainedvariable: d in LessThan(2.0) + """ + MOI.Utilities.loadfromstring!(model, text) + MOI.set( + model, + MOI.ConstraintName(), + MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives}(1), + "con1", + ) + model2 = MOI.Utilities.Model{Float64}() + text2 = """ + variables: a, b, c, d + con1: [a, b, c] in Nonnegatives(3) + d <= 2.0 + """ + MOI.Utilities.loadfromstring!(model2, text2) + MOI.Test.util_test_models_equal( + model, + model2, + ["a", "b", "c", "d"], + ["con1"], + [("d", MOI.LessThan{Float64}(2.0))], + ) + return +end + +function test_eltypes_int() + model = MOI.Utilities.Model{Int}() + text = """ + variables: x, y + ::Int: x >= 1 + c::Int: 2 * x <= 3 + d::Int: [x, 4 * y] in Zeros(2) + e::Int: [2 * x * x] in Nonnegatives(1) + """ + MOI.Utilities.loadfromstring!(model, text) + c = MOI.get(model, MOI.ConstraintIndex, "c") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), c), + MOI.ScalarAffineFunction{Int}, + ) + d = MOI.get(model, MOI.ConstraintIndex, "d") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), d), + MOI.VectorAffineFunction{Int}, + ) + e = MOI.get(model, MOI.ConstraintIndex, "e") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), e), + MOI.VectorQuadraticFunction{Int}, + ) + return +end + +function test_eltypes_rational_int() + model = MOI.Utilities.Model{Rational{Int}}() + text = """ + variables: x, y + c::Rational{Int}: 2 // 1 * x <= 1 // 3 + d::Rational{Int}: [x, 4 // 2 * y] in Zeros(2) + e::Rational{Int}: [2 // 2 * x * x] in Nonnegatives(1) + """ + MOI.Utilities.loadfromstring!(model, text) + c = MOI.get(model, MOI.ConstraintIndex, "c") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), c), + MOI.ScalarAffineFunction{Rational{Int}}, + ) + d = MOI.get(model, MOI.ConstraintIndex, "d") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), d), + MOI.VectorAffineFunction{Rational{Int}}, + ) + e = MOI.get(model, MOI.ConstraintIndex, "e") + @test isa( + MOI.get(model, MOI.ConstraintFunction(), e), + MOI.VectorQuadraticFunction{Rational{Int}}, + ) + return +end + +function test_eltypes_complex_float64() + # Work-around for https://github.com/jump-dev/MathOptInterface.jl/issues/1947 + model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) + text = """ + variables: x + c::Complex{Float64}: (2.0 + 1im) * x == 0.0 + 0.0im + """ + MOI.Utilities.loadfromstring!(model, text) + x = MOI.get(model, MOI.VariableIndex, "x") + c = MOI.get(model, MOI.ConstraintIndex, "c") + f = MOI.get(model, MOI.ConstraintFunction(), c) + @test f isa MOI.ScalarAffineFunction{Complex{Float64}} + @test isapprox( + MOI.ScalarAffineFunction( + [MOI.ScalarAffineTerm(2.0 + 1.0im, x)], + 0.0 + 0.0im, + ), + f, + ) + return +end + +struct Set2175 <: MOI.AbstractScalarSet end + +function test_parse_external_set_constraint() + model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) + MOI.Utilities.loadfromstring!( + model, + "variables: x\nx in $(@__MODULE__).Set2175()", + ) + constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test (MOI.VariableIndex, Set2175) in constraints + return +end + +function test_parse_external_set_constrained_variable() + model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) + MOI.Utilities.loadfromstring!( + model, + "constrainedvariable: x in $(@__MODULE__).Set2175()", + ) + constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test (MOI.VariableIndex, Set2175) in constraints + return +end + +function test_parse_scope() + @test !isdefined(@__MODULE__, :MathOptInterface) + model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) + MOI.Utilities.loadfromstring!( + model, + "variables: x\nx in MathOptInterface.ZeroOne()", + ) + attr = MOI.NumberOfConstraints{MOI.VariableIndex,MOI.ZeroOne}() + @test MOI.get(model, attr) == 1 + return +end + +function test_parse_unrecognized_expression() + model = MOI.Utilities.Model{Float64}() + @test_throws( + ErrorException("Unrecognized expression []"), + MOI.Utilities.loadfromstring!(model, "[]"), + ) + @test_throws( + ErrorException("Unrecognized expression foo(x)"), + MOI.Utilities.loadfromstring!(model, "variables: x\nfoo(x)"), + ) + return +end + +end # module + +TestParser.runtests() 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) From cd6320687d7f2e97af04cf5b4eb43d90cffd28b2 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 10:21:44 +1300 Subject: [PATCH 02/13] Update --- test/Utilities/parser.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Utilities/parser.jl b/test/Utilities/parser.jl index d3c0101946..d7380e6be8 100644 --- a/test/Utilities/parser.jl +++ b/test/Utilities/parser.jl @@ -403,6 +403,7 @@ end struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() + error(join(println.(propertynames(Main)), " ")) model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) MOI.Utilities.loadfromstring!(model, "variables: x\nx in $(Set2175())") constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) From 1bd320ce1e80a6001bdbb5aae2b0a8a2e3199bd5 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 10:35:42 +1300 Subject: [PATCH 03/13] Update --- test/Utilities/parser.jl | 452 ---------------------------------- test/Utilities/test_parser.jl | 7 +- 2 files changed, 2 insertions(+), 457 deletions(-) delete mode 100644 test/Utilities/parser.jl diff --git a/test/Utilities/parser.jl b/test/Utilities/parser.jl deleted file mode 100644 index d7380e6be8..0000000000 --- a/test/Utilities/parser.jl +++ /dev/null @@ -1,452 +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. - -module TestParser - -using Test - -import MathOptInterface as MOI -import MathOptInterface.Utilities as MOIU - -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 _struct_isequal(a::T, b::T) where {T} - return all(f -> getfield(a, f) == getfield(b, f), fieldnames(T)) -end - -function test__parse_function() - @test _struct_isequal( - MOIU._parse_function(:x), - MOIU._ParsedVariableIndex(:x), - ) - @test _struct_isequal( - MOIU._parse_function(:([x, y, z])), - MOIU._ParsedVectorOfVariables([:x, :y, :z]), - ) - - @test _struct_isequal( - MOIU._parse_function(:(x + y + 2.0)), - MOIU._ParsedScalarAffineFunction( - MOIU._ParsedScalarAffineTerm.([1.0, 1.0], [:x, :y]), - 2.0, - ), - ) - @test _struct_isequal( - MOIU._parse_function(:(x + -3y + 2.0)), - MOIU._ParsedScalarAffineFunction( - MOIU._ParsedScalarAffineTerm.([1.0, -3.0], [:x, :y]), - 2.0, - ), - ) - @test _struct_isequal( - MOIU._parse_function(:(2 * x * y + y + 1.0)), - MOIU._ParsedScalarQuadraticFunction( - MOIU._ParsedScalarQuadraticTerm.([2.0], [:x], [:y]), - MOIU._ParsedScalarAffineTerm.([1.0], [:y]), - 1.0, - ), - ) - - err = ErrorException( - "Unsupported operator in `loadfromstring!`: `-`. " * - "The parser is deliberately limited in the syntax it " * - "accepts. Write `x - y` as `x + -1 * y`, and `x^2` as " * - "`x * x`.", - ) - @test_throws err MOIU._parse_function(:(x - y)) - - @test _struct_isequal( - MOIU._parse_function(:([x, 2x + y + 5.0])), - MOIU._ParsedVectorAffineFunction( - MOIU._ParsedVectorAffineTerm.( - Int64[1, 2, 2], - MOIU._ParsedScalarAffineTerm.([1.0, 2.0, 1.0], [:x, :x, :y]), - ), - [0.0, 5.0], - ), - ) - @test _struct_isequal( - MOIU._parse_function(:([x, 2x + y + 5.0, 1 * x * x])), - MOIU._ParsedVectorQuadraticFunction( - MOIU._ParsedVectorQuadraticTerm.( - Int64[3], - MOIU._ParsedScalarQuadraticTerm.([2.0], [:x], [:x]), - ), - MOIU._ParsedVectorAffineTerm.( - Int64[1, 2, 2], - MOIU._ParsedScalarAffineTerm.([1.0, 2.0, 1.0], [:x, :x, :y]), - ), - [0.0, 5.0, 0.0], - ), - ) - return -end - -function test__separate_label() - @test MOIU._separate_label(:(variables:x)) == (:variables, :x) - @test MOIU._separate_label(:(variables:x, y)) == (:variables, :((x, y))) - @test MOIU._separate_label(:(minobjective:(x+y))) == - (:minobjective, :(x + y)) - @test MOIU._separate_label(:(con1:2x <= 1)) == (:con1, :(2x <= 1)) - @test MOIU._separate_label(:(con1:[x, y] in S)) == (:con1, :([x, y] in S)) - return -end - -function test_one_variable() - s = """ - variables: x - x >= 1.0 - """ - model = MOIU.Model{Float64}() - x = MOI.add_variable(model) - MOI.set(model, MOI.VariableName(), x, "x") - bound = MOI.add_constraint(model, x, MOI.GreaterThan(1.0)) - - model2 = MOIU.Model{Float64}() - MOIU.loadfromstring!(model2, s) - MOI.Test.util_test_models_equal( - model, - model2, - ["x"], - String[], - [("x", MOI.GreaterThan{Float64}(1.0))], - ) - return -end - -function test_linear_constraints() - s = """ - variables: x, y - linear1: x + y >= 1.0 - linear2: x + y <= 1.0 - linear3: x + y == 1.0 - """ - model = MOIU.Model{Float64}() - x = MOI.add_variable(model) - y = MOI.add_variable(model) - MOI.set(model, MOI.VariableName(), x, "x") - MOI.set(model, MOI.VariableName(), y, "y") - linear1 = MOI.add_constraint( - model, - MOI.ScalarAffineFunction( - MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), - 0.0, - ), - MOI.GreaterThan(1.0), - ) - linear2 = MOI.add_constraint( - model, - MOI.ScalarAffineFunction( - MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), - 0.0, - ), - MOI.LessThan(1.0), - ) - linear3 = MOI.add_constraint( - model, - MOI.ScalarAffineFunction( - MOI.ScalarAffineTerm.([1.0, 1.0], [x, y]), - 0.0, - ), - MOI.EqualTo(1.0), - ) - MOI.set(model, MOI.ConstraintName(), linear1, "linear1") - MOI.set(model, MOI.ConstraintName(), linear2, "linear2") - MOI.set(model, MOI.ConstraintName(), linear3, "linear3") - - model2 = MOIU.Model{Float64}() - MOIU.loadfromstring!(model2, s) - MOI.Test.util_test_models_equal( - model, - model2, - ["x", "y"], - ["linear1", "linear2", "linear3"], - ) - return -end - -function test_minimization_linear_objective() - s = """ - variables: x, y - minobjective: x + -2y + 1.0 - """ - model = MOIU.Model{Float64}() - x = MOI.add_variable(model) - y = MOI.add_variable(model) - MOI.set(model, MOI.VariableName(), x, "x") - MOI.set(model, MOI.VariableName(), y, "y") - MOI.set( - model, - MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), - MOI.ScalarAffineFunction( - MOI.ScalarAffineTerm.([1.0, -2.0], [x, y]), - 1.0, - ), - ) - MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) - - model2 = MOIU.Model{Float64}() - MOIU.loadfromstring!(model2, s) - MOI.Test.util_test_models_equal(model, model2, ["x", "y"], String[]) - return -end - -function test_maximization_linear_objective() - s = """ - variables: x, y - maxobjective: x + -2y + 1.0 - """ - model = MOIU.Model{Float64}() - x = MOI.add_variable(model) - y = MOI.add_variable(model) - MOI.set(model, MOI.VariableName(), x, "x") - MOI.set(model, MOI.VariableName(), y, "y") - MOI.set( - model, - MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), - MOI.ScalarAffineFunction( - MOI.ScalarAffineTerm.([1.0, -2.0], [x, y]), - 1.0, - ), - ) - MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) - - model2 = MOIU.Model{Float64}() - MOIU.loadfromstring!(model2, s) - MOI.Test.util_test_models_equal(model, model2, ["x", "y"], String[]) - return -end - -function test_SecondOrderCone_constraints() - s = """ - variables: x, y, z - varsoc: [x,y,z] in SecondOrderCone(3) - affsoc: [2x,y+1,-1*z] in SecondOrderCone(3) - affsoc2: [1.0,2.0,3.0] in SecondOrderCone(3) - """ - model = MOIU.Model{Float64}() - x = MOI.add_variable(model) - y = MOI.add_variable(model) - z = MOI.add_variable(model) - MOI.set(model, MOI.VariableName(), x, "x") - MOI.set(model, MOI.VariableName(), y, "y") - MOI.set(model, MOI.VariableName(), z, "z") - varsoc = MOI.add_constraint( - model, - MOI.VectorOfVariables([x, y, z]), - MOI.SecondOrderCone(3), - ) - affsoc = MOI.add_constraint( - model, - MOI.VectorAffineFunction( - MOI.VectorAffineTerm.( - [1, 2, 3], - MOI.ScalarAffineTerm.([2.0, 1.0, -1.0], [x, y, z]), - ), - [0.0, 1.0, 0.0], - ), - MOI.SecondOrderCone(3), - ) - affsoc2 = MOI.add_constraint( - model, - MOI.VectorAffineFunction( - MOI.VectorAffineTerm{Float64}[], - [1.0, 2.0, 3.0], - ), - MOI.SecondOrderCone(3), - ) - MOI.set(model, MOI.ConstraintName(), varsoc, "varsoc") - MOI.set(model, MOI.ConstraintName(), affsoc, "affsoc") - MOI.set(model, MOI.ConstraintName(), affsoc2, "affsoc2") - - model2 = MOIU.Model{Float64}() - MOIU.loadfromstring!(model2, s) - MOI.Test.util_test_models_equal( - model, - model2, - ["x", "y", "z"], - ["varsoc", "affsoc", "affsoc2"], - ) - return -end - -function test_Invalid_variable_name() - s = """ - variables: x - y >= 1.0 - """ - model = MOIU.Model{Float64}() - err = ErrorException("Invalid variable name y.") - @test_throws err MOIU.loadfromstring!(model, s) - return -end - -function test_constrained_variables() - model = MOI.Utilities.Model{Float64}() - text = """ - constrainedvariable: [a, b, c] in Nonnegatives(3) - constrainedvariable: d in LessThan(2.0) - """ - MOI.Utilities.loadfromstring!(model, text) - MOI.set( - model, - MOI.ConstraintName(), - MOI.ConstraintIndex{MOI.VectorOfVariables,MOI.Nonnegatives}(1), - "con1", - ) - model2 = MOI.Utilities.Model{Float64}() - text2 = """ - variables: a, b, c, d - con1: [a, b, c] in Nonnegatives(3) - d <= 2.0 - """ - MOI.Utilities.loadfromstring!(model2, text2) - MOI.Test.util_test_models_equal( - model, - model2, - ["a", "b", "c", "d"], - ["con1"], - [("d", MOI.LessThan{Float64}(2.0))], - ) - return -end - -function test_eltypes_int() - model = MOI.Utilities.Model{Int}() - text = """ - variables: x, y - ::Int: x >= 1 - c::Int: 2 * x <= 3 - d::Int: [x, 4 * y] in Zeros(2) - e::Int: [2 * x * x] in Nonnegatives(1) - """ - MOI.Utilities.loadfromstring!(model, text) - c = MOI.get(model, MOI.ConstraintIndex, "c") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), c), - MOI.ScalarAffineFunction{Int}, - ) - d = MOI.get(model, MOI.ConstraintIndex, "d") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), d), - MOI.VectorAffineFunction{Int}, - ) - e = MOI.get(model, MOI.ConstraintIndex, "e") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), e), - MOI.VectorQuadraticFunction{Int}, - ) - return -end - -function test_eltypes_rational_int() - model = MOI.Utilities.Model{Rational{Int}}() - text = """ - variables: x, y - c::Rational{Int}: 2 // 1 * x <= 1 // 3 - d::Rational{Int}: [x, 4 // 2 * y] in Zeros(2) - e::Rational{Int}: [2 // 2 * x * x] in Nonnegatives(1) - """ - MOI.Utilities.loadfromstring!(model, text) - c = MOI.get(model, MOI.ConstraintIndex, "c") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), c), - MOI.ScalarAffineFunction{Rational{Int}}, - ) - d = MOI.get(model, MOI.ConstraintIndex, "d") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), d), - MOI.VectorAffineFunction{Rational{Int}}, - ) - e = MOI.get(model, MOI.ConstraintIndex, "e") - @test isa( - MOI.get(model, MOI.ConstraintFunction(), e), - MOI.VectorQuadraticFunction{Rational{Int}}, - ) - return -end - -function test_eltypes_complex_float64() - # Work-around for https://github.com/jump-dev/MathOptInterface.jl/issues/1947 - model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) - text = """ - variables: x - c::Complex{Float64}: (2.0 + 1im) * x == 0.0 + 0.0im - """ - MOI.Utilities.loadfromstring!(model, text) - x = MOI.get(model, MOI.VariableIndex, "x") - c = MOI.get(model, MOI.ConstraintIndex, "c") - f = MOI.get(model, MOI.ConstraintFunction(), c) - @test f isa MOI.ScalarAffineFunction{Complex{Float64}} - @test isapprox( - MOI.ScalarAffineFunction( - [MOI.ScalarAffineTerm(2.0 + 1.0im, x)], - 0.0 + 0.0im, - ), - f, - ) - return -end - -struct Set2175 <: MOI.AbstractScalarSet end - -function test_parse_external_set_constraint() - error(join(println.(propertynames(Main)), " ")) - model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) - 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() - model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) - MOI.Utilities.loadfromstring!( - model, - "constrainedvariable: x in $(Set2175())", - ) - constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) - @test (MOI.VariableIndex, Set2175) in constraints - return -end - -function test_parse_scope() - @test !isdefined(@__MODULE__, :MathOptInterface) - model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) - MOI.Utilities.loadfromstring!( - model, - "variables: x\nx in MathOptInterface.ZeroOne()", - ) - attr = MOI.NumberOfConstraints{MOI.VariableIndex,MOI.ZeroOne}() - @test MOI.get(model, attr) == 1 - return -end - -function test_parse_unrecognized_expression() - model = MOI.Utilities.Model{Float64}() - @test_throws( - ErrorException("Unrecognized expression []"), - MOI.Utilities.loadfromstring!(model, "[]"), - ) - @test_throws( - ErrorException("Unrecognized expression foo(x)"), - MOI.Utilities.loadfromstring!(model, "variables: x\nfoo(x)"), - ) - return -end - -end # module - -TestParser.runtests() diff --git a/test/Utilities/test_parser.jl b/test/Utilities/test_parser.jl index b2f09cdbba..d3c0101946 100644 --- a/test/Utilities/test_parser.jl +++ b/test/Utilities/test_parser.jl @@ -404,10 +404,7 @@ struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() 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 @@ -417,7 +414,7 @@ function test_parse_external_set_constrained_variable() 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 From e077c474388c57e9d5bde08173dbb06964c7c451 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 10:56:35 +1300 Subject: [PATCH 04/13] Update --- test/Utilities/test_parser.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Utilities/test_parser.jl b/test/Utilities/test_parser.jl index d3c0101946..3147eff28a 100644 --- a/test/Utilities/test_parser.jl +++ b/test/Utilities/test_parser.jl @@ -403,6 +403,7 @@ end struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() + error(join(String.(propertynames(Main))), " <> ") model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) MOI.Utilities.loadfromstring!(model, "variables: x\nx in $(Set2175())") constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) From 31232738a9a379690f96c81d4142ea9ebef3233d Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 11:15:11 +1300 Subject: [PATCH 05/13] Update --- test/Utilities/test_parser.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Utilities/test_parser.jl b/test/Utilities/test_parser.jl index 3147eff28a..4f4c4dacdf 100644 --- a/test/Utilities/test_parser.jl +++ b/test/Utilities/test_parser.jl @@ -403,7 +403,9 @@ end struct Set2175 <: MOI.AbstractScalarSet end function test_parse_external_set_constraint() - error(join(String.(propertynames(Main))), " <> ") + if Sys.iswindows() + return # See #2932 + end model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) MOI.Utilities.loadfromstring!(model, "variables: x\nx in $(Set2175())") constraints = MOI.get(model, MOI.ListOfConstraintTypesPresent()) @@ -412,6 +414,9 @@ function test_parse_external_set_constraint() 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, From 9e0d741650dad6e31e41711c1d4003bea2d56454 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 12:14:51 +1300 Subject: [PATCH 06/13] More parallelism --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0892d719fa..e15f3bf781 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,9 @@ jobs: moi_test_modules: - 'General;Benchmarks;FileFormats;Nonlinear' - 'Bridges/General' - - 'Bridges/Constraint;Bridges/Objective;Bridges/Variable' + - 'Bridges/Constraint' + - 'Bridges/Objective' + - 'Bridges/Variable' - 'Test' - 'Utilities' machine: From eb641bf2d73580eb97200e1db4fda7a7b57e40d7 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 13:12:35 +1300 Subject: [PATCH 07/13] Split some large files into smaller files for better parallelism --- test/Test/test_BigFloat.jl | 45 +++++++++++++ test/Test/test_Float64.jl | 64 +++++++++++++++++++ test/Test/test_Test.jl | 61 ------------------ .../test_cachingoptimizer_runtests.jl | 64 +++++++++++++++++++ test/Utilities/test_model_runtests.jl | 34 ++++++++++ ...test_test_operate!.jl => test_operate!.jl} | 0 ...operation.jl => test_promote_operation.jl} | 0 7 files changed, 207 insertions(+), 61 deletions(-) create mode 100644 test/Test/test_BigFloat.jl create mode 100644 test/Test/test_Float64.jl create mode 100644 test/Utilities/test_cachingoptimizer_runtests.jl create mode 100644 test/Utilities/test_model_runtests.jl rename test/Utilities/{test_test_operate!.jl => test_operate!.jl} (100%) rename test/Utilities/{test_test_promote_operation.jl => test_promote_operation.jl} (100%) diff --git a/test/Test/test_BigFloat.jl b/test/Test/test_BigFloat.jl new file mode 100644 index 0000000000..405b391f6e --- /dev/null +++ b/test/Test/test_BigFloat.jl @@ -0,0 +1,45 @@ +# 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. + +module TestTestBigFloat + +using Test +import MathOptInterface as MOI + +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_bigfloat_tests() + MOI.Test.runtests( + MOI.Utilities.MockOptimizer( + MOI.Utilities.UniversalFallback(MOI.Utilities.Model{BigFloat}()), + BigFloat, + ), + MOI.Test.Config(BigFloat), + exclude = [ + # ========================= Expected failures ====================== + # UniversalFallback supports these tests. + "test_model_copy_to_UnsupportedAttribute", + "test_model_copy_to_UnsupportedConstraint", + "test_model_supports_constraint_ScalarAffineFunction_EqualTo", + "test_model_supports_constraint_VariableIndex_EqualTo", + "test_model_supports_constraint_VectorOfVariables_Nonnegatives", + ], + ) + return +end + +end # module + +TestTestBigFloat.runtests() diff --git a/test/Test/test_Float64.jl b/test/Test/test_Float64.jl new file mode 100644 index 0000000000..fcad511295 --- /dev/null +++ b/test/Test/test_Float64.jl @@ -0,0 +1,64 @@ +# 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. + +module TestTestFloat64 + +using Test +import MathOptInterface as MOI + +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() + # Some tests are excluded because UniversalFallback accepts absolutely + # everything. + MOI.Test.runtests( + MOI.Utilities.MockOptimizer( + MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), + ), + MOI.Test.Config(), + exclude = [ + r"^test_model_ScalarFunctionConstantNotZero$", + "test_model_copy_to_UnsupportedAttribute", + "test_model_copy_to_UnsupportedConstraint", + "test_model_supports_constraint_ScalarAffineFunction_EqualTo", + "test_model_supports_constraint_VariableIndex_EqualTo", + "test_model_supports_constraint_VectorOfVariables_Nonnegatives", + ], + warn_unsupported = true, + verbose = true, + ) + # Run the previously excluded tests, this time without UniversalFallback. + MOI.Test.runtests( + MOI.Utilities.MockOptimizer( + MOI.Utilities.Model{Float64}(), + scalar_function_constant_non_zero = true, + ), + MOI.Test.Config(); + include = [ + r"^test_model_ScalarFunctionConstantNotZero$", + "test_model_copy_to_UnsupportedAttribute", + "test_model_copy_to_UnsupportedConstraint", + "test_model_supports_constraint_ScalarAffineFunction_EqualTo", + "test_model_supports_constraint_VariableIndex_EqualTo", + "test_model_supports_constraint_VectorOfVariables_Nonnegatives", + ], + verbose = true, + ) + return +end + +end # module + +TestTestFloat64.runtests() diff --git a/test/Test/test_Test.jl b/test/Test/test_Test.jl index cadb2d98ff..241255c195 100644 --- a/test/Test/test_Test.jl +++ b/test/Test/test_Test.jl @@ -20,45 +20,6 @@ function runtests() return end -function test_runtests() - # Some tests are excluded because UniversalFallback accepts absolutely - # everything. - MOI.Test.runtests( - MOI.Utilities.MockOptimizer( - MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), - ), - MOI.Test.Config(), - exclude = [ - r"^test_model_ScalarFunctionConstantNotZero$", - "test_model_copy_to_UnsupportedAttribute", - "test_model_copy_to_UnsupportedConstraint", - "test_model_supports_constraint_ScalarAffineFunction_EqualTo", - "test_model_supports_constraint_VariableIndex_EqualTo", - "test_model_supports_constraint_VectorOfVariables_Nonnegatives", - ], - warn_unsupported = true, - verbose = true, - ) - # Run the previously excluded tests, this time without UniversalFallback. - MOI.Test.runtests( - MOI.Utilities.MockOptimizer( - MOI.Utilities.Model{Float64}(), - scalar_function_constant_non_zero = true, - ), - MOI.Test.Config(); - include = [ - r"^test_model_ScalarFunctionConstantNotZero$", - "test_model_copy_to_UnsupportedAttribute", - "test_model_copy_to_UnsupportedConstraint", - "test_model_supports_constraint_ScalarAffineFunction_EqualTo", - "test_model_supports_constraint_VariableIndex_EqualTo", - "test_model_supports_constraint_VectorOfVariables_Nonnegatives", - ], - verbose = true, - ) - return -end - function test_issue_1757() MOI.Test.test_model_ScalarFunctionConstantNotZero( MOI.Utilities.MockOptimizer( @@ -84,28 +45,6 @@ function test_exclude_tests_after() return end -# Non-Float64 tests - -function test_bigfloat_tests() - MOI.Test.runtests( - MOI.Utilities.MockOptimizer( - MOI.Utilities.UniversalFallback(MOI.Utilities.Model{BigFloat}()), - BigFloat, - ), - MOI.Test.Config(BigFloat), - exclude = [ - # ========================= Expected failures ====================== - # UniversalFallback supports these tests. - "test_model_copy_to_UnsupportedAttribute", - "test_model_copy_to_UnsupportedConstraint", - "test_model_supports_constraint_ScalarAffineFunction_EqualTo", - "test_model_supports_constraint_VariableIndex_EqualTo", - "test_model_supports_constraint_VectorOfVariables_Nonnegatives", - ], - ) - return -end - # Special test for issue #2010 struct _UnsupportedModel <: MOI.ModelLike end diff --git a/test/Utilities/test_cachingoptimizer_runtests.jl b/test/Utilities/test_cachingoptimizer_runtests.jl new file mode 100644 index 0000000000..07f2cbec01 --- /dev/null +++ b/test/Utilities/test_cachingoptimizer_runtests.jl @@ -0,0 +1,64 @@ +# 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. + +module TestCachingOptimizerRuntests + +using Test + +import MathOptInterface as MOI +import MathOptInterface.Utilities as MOIU + +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_MOI_Test() + # It seems like these loops might take a while. But the first one takes + # _forever_, and then the rest are really quick (like 140s vs 0.4s). + for state in + (MOIU.NO_OPTIMIZER, MOIU.EMPTY_OPTIMIZER, MOIU.ATTACHED_OPTIMIZER) + for mode in (MOIU.MANUAL, MOIU.AUTOMATIC) + _test_caching_optimizer(state, mode) + end + end + return +end + +function _test_caching_optimizer(state, mode) + model = MOIU.CachingOptimizer(MOIU.Model{Float64}(), mode) + if state != MOIU.NO_OPTIMIZER + optimizer = MOIU.MockOptimizer( + MOIU.Model{Float64}(), + supports_names = false, + ) + MOIU.reset_optimizer(model, optimizer) + if state == MOIU.ATTACHED_OPTIMIZER + MOIU.attach_optimizer(model) + end + end + @test MOIU.state(model) == state + @test MOIU.mode(model) == mode + MOI.Test.runtests( + model, + MOI.Test.Config(exclude = Any[MOI.optimize!]), + exclude = [ + "test_attribute_SolverName", + "test_attribute_SolverVersion", + ], + ) + return +end + +end # module + +TestCachingOptimizerRuntests.runtests() diff --git a/test/Utilities/test_model_runtests.jl b/test/Utilities/test_model_runtests.jl new file mode 100644 index 0000000000..fc375ac626 --- /dev/null +++ b/test/Utilities/test_model_runtests.jl @@ -0,0 +1,34 @@ +# 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. + +module TestModelRuntests + +using Test + +import MathOptInterface as MOI + +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_MOI_Test() + MOI.Test.runtests( + MOI.Utilities.Model{Float64}(), + MOI.Test.Config(exclude = Any[MOI.optimize!,]), + ) + return +end + +end # module + +TestModelRuntests.runtests() diff --git a/test/Utilities/test_test_operate!.jl b/test/Utilities/test_operate!.jl similarity index 100% rename from test/Utilities/test_test_operate!.jl rename to test/Utilities/test_operate!.jl diff --git a/test/Utilities/test_test_promote_operation.jl b/test/Utilities/test_promote_operation.jl similarity index 100% rename from test/Utilities/test_test_promote_operation.jl rename to test/Utilities/test_promote_operation.jl From d3a3975c01cd9819d296696cb25c4b85e9d6176b Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 13:19:15 +1300 Subject: [PATCH 08/13] Update --- .../test_cachingoptimizer_runtests.jl | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/Utilities/test_cachingoptimizer_runtests.jl b/test/Utilities/test_cachingoptimizer_runtests.jl index 07f2cbec01..666d8944e5 100644 --- a/test/Utilities/test_cachingoptimizer_runtests.jl +++ b/test/Utilities/test_cachingoptimizer_runtests.jl @@ -9,7 +9,6 @@ module TestCachingOptimizerRuntests using Test import MathOptInterface as MOI -import MathOptInterface.Utilities as MOIU function runtests() for name in names(@__MODULE__; all = true) @@ -25,9 +24,12 @@ end function test_MOI_Test() # It seems like these loops might take a while. But the first one takes # _forever_, and then the rest are really quick (like 140s vs 0.4s). - for state in - (MOIU.NO_OPTIMIZER, MOIU.EMPTY_OPTIMIZER, MOIU.ATTACHED_OPTIMIZER) - for mode in (MOIU.MANUAL, MOIU.AUTOMATIC) + for state in ( + MOI.Utilities.NO_OPTIMIZER, + MOI.Utilities.EMPTY_OPTIMIZER, + MOI.Utilities.ATTACHED_OPTIMIZER, + ) + for mode in (MOI.Utilities.MANUAL, MOI.Utilities.AUTOMATIC) _test_caching_optimizer(state, mode) end end @@ -35,26 +37,23 @@ function test_MOI_Test() end function _test_caching_optimizer(state, mode) - model = MOIU.CachingOptimizer(MOIU.Model{Float64}(), mode) - if state != MOIU.NO_OPTIMIZER - optimizer = MOIU.MockOptimizer( - MOIU.Model{Float64}(), + model = MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), mode) + if state != MOI.Utilities.NO_OPTIMIZER + optimizer = MOI.Utilities.MockOptimizer( + MOI.Utilities.Model{Float64}(), supports_names = false, ) - MOIU.reset_optimizer(model, optimizer) - if state == MOIU.ATTACHED_OPTIMIZER - MOIU.attach_optimizer(model) + MOI.Utilities.reset_optimizer(model, optimizer) + if state == MOI.Utilities.ATTACHED_OPTIMIZER + MOI.Utilities.attach_optimizer(model) end end - @test MOIU.state(model) == state - @test MOIU.mode(model) == mode + @test MOI.Utilities.state(model) == state + @test MOI.Utilities.mode(model) == mode MOI.Test.runtests( model, MOI.Test.Config(exclude = Any[MOI.optimize!]), - exclude = [ - "test_attribute_SolverName", - "test_attribute_SolverVersion", - ], + exclude = ["test_attribute_SolverName", "test_attribute_SolverVersion"], ) return end From 2d2fe1bbe147df7d9b794d9d1617ee09bd622872 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 14:50:07 +1300 Subject: [PATCH 09/13] Disable redefinition check --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 5070eeb658..bee493b01f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,10 +67,10 @@ import ParallelTestRunner is_test_file(f) = startswith(f, "test_") && endswith(f, ".jl") testsuite = Dict{String,Expr}( - file => :(include_with_method_redefinition_check($file)) for + file => :(include($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) +ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite) From 06fa163fb88549a4c69773dbb807ff75ba946045 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 15:19:31 +1300 Subject: [PATCH 10/13] Revert --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index bee493b01f..5070eeb658 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,10 +67,10 @@ import ParallelTestRunner is_test_file(f) = startswith(f, "test_") && endswith(f, ".jl") testsuite = Dict{String,Expr}( - file => :(include($file)) for + 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) +ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code) From 7e535bb1fa37b4f2a7f599c6471ad2efedfa1822 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 16:40:58 +1300 Subject: [PATCH 11/13] Update --- test/runtests.jl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 5070eeb658..031d715029 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -61,9 +61,6 @@ const init_code = quote end end -import MathOptInterface -import ParallelTestRunner - is_test_file(f) = startswith(f, "test_") && endswith(f, ".jl") testsuite = Dict{String,Expr}( @@ -73,4 +70,13 @@ testsuite = Dict{String,Expr}( file in joinpath.(root, filter(is_test_file, files)) ) -ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code) +@static if Sys.WORD_SIZE == 64 + import MathOptInterface + import ParallelTestRunner + ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code) +else + import Test + Test.@test "$filename" for (filename, _) in testsuite + include(filename) + end +end From 12713b47d9c7bba0931588747d2bc09ddabf8ff3 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 20:51:57 +1300 Subject: [PATCH 12/13] Update test/runtests.jl --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 031d715029..069207becf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,7 +76,7 @@ testsuite = Dict{String,Expr}( ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code) else import Test - Test.@test "$filename" for (filename, _) in testsuite + Test.@testset "$filename" for (filename, _) in testsuite include(filename) end end From f8e14cebef069f8bfcd30dd3aa1f0a6c1d356235 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 5 Feb 2026 21:10:55 +1300 Subject: [PATCH 13/13] Refactor test imports and adjust testset iteration --- test/runtests.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 069207becf..31ebfd8c3a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -70,13 +70,14 @@ testsuite = Dict{String,Expr}( file in joinpath.(root, filter(is_test_file, files)) ) -@static if Sys.WORD_SIZE == 64 - import MathOptInterface - import ParallelTestRunner +import MathOptInterface +import ParallelTestRunner +import Test + +if Sys.WORD_SIZE == 64 ParallelTestRunner.runtests(MathOptInterface, ARGS; testsuite, init_code) else - import Test - Test.@testset "$filename" for (filename, _) in testsuite + Test.@testset "$filename" for filename in keys(testsuite) include(filename) end end