From 34a71f66110fc621b6d0d90feb1c3d42cf47c1c8 Mon Sep 17 00:00:00 2001 From: odow Date: Wed, 8 Nov 2023 10:53:45 +1300 Subject: [PATCH 1/2] [Test] add verbose kwarg to MOI.Test.runtests --- src/Test/Test.jl | 8 ++++++++ test/Test/Test.jl | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Test/Test.jl b/src/Test/Test.jl index fe7d454a0f..6578aad252 100644 --- a/src/Test/Test.jl +++ b/src/Test/Test.jl @@ -174,6 +174,7 @@ version_added(::F) where {F} = v"0.10.5" # The default for any unlabeled tests. exclude::Vector{Union{String,Regex}} = String[], warn_unsupported::Bool = false, exclude_tests_after::VersionNumber = v"999.0.0", + verbose::Bool = false, ) Run all tests in `MathOptInterface.Test` on `model`. @@ -200,6 +201,8 @@ Run all tests in `MathOptInterface.Test` on `model`. added after that version number. This is useful for solvers who can declare a fixed set of tests, and not cause their tests to break if a new patch of MOI is released with a new test. + * `verbose` is a `Bool` that controls whether the name of the test is printed + before executing it. This can be helpful when debugging. See also: [`setup_test`](@ref). @@ -213,6 +216,7 @@ MathOptInterface.Test.runtests( include = ["test_linear_", r"^test_model_Name\$"], exclude = ["VariablePrimalStart"], warn_unsupported = true, + verbose = true, exclude_tests_after = v"0.10.5", ) ``` @@ -223,6 +227,7 @@ function runtests( include::Vector = String[], exclude::Vector = String[], warn_unsupported::Bool = false, + verbose::Bool = false, exclude_tests_after::VersionNumber = v"999.0.0", ) tests = filter(names(@__MODULE__; all = true)) do name @@ -252,6 +257,9 @@ function runtests( if version_added(test_function) > exclude_tests_after continue end + if verbose + @info "Running $name" + end @testset "$(name)" begin c = copy(config) tear_down = setup_test(test_function, model, c) diff --git a/test/Test/Test.jl b/test/Test/Test.jl index cebf4b9e34..fbadb3a6a4 100644 --- a/test/Test/Test.jl +++ b/test/Test/Test.jl @@ -34,7 +34,7 @@ MOI.Test.runtests( MOI.Utilities.Model{Float64}(), scalar_function_constant_non_zero = true, ), - MOI.Test.Config(), + MOI.Test.Config(); include = [ r"^test_model_ScalarFunctionConstantNotZero$", "test_model_copy_to_UnsupportedAttribute", @@ -43,6 +43,7 @@ MOI.Test.runtests( "test_model_supports_constraint_VariableIndex_EqualTo", "test_model_supports_constraint_VectorOfVariables_Nonnegatives", ], + verbose = true, ) # Test for Issue #1757 From 0f5740db2d32cd79c9efee63b54c559b38a395a7 Mon Sep 17 00:00:00 2001 From: odow Date: Wed, 8 Nov 2023 11:33:49 +1300 Subject: [PATCH 2/2] Update --- src/Test/Test.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Test/Test.jl b/src/Test/Test.jl index 6578aad252..aac5778d1f 100644 --- a/src/Test/Test.jl +++ b/src/Test/Test.jl @@ -253,13 +253,16 @@ function runtests( elseif !isempty(exclude) && any(s -> occursin(s, name), exclude) continue end + if verbose + @info "Running $name" + end test_function = getfield(@__MODULE__, name_sym) if version_added(test_function) > exclude_tests_after + if verbose + println(" Skipping test because of `exclude_tests_after`") + end continue end - if verbose - @info "Running $name" - end @testset "$(name)" begin c = copy(config) tear_down = setup_test(test_function, model, c) @@ -268,6 +271,9 @@ function runtests( try test_function(model, c) catch err + if verbose + println(" Test errored with $(typeof(err))") + end _error_handler(err, name, warn_unsupported) end if tear_down !== nothing