diff --git a/test/allocation_test.jl b/test/allocation_test.jl index 0d31234..9378da6 100644 --- a/test/allocation_test.jl +++ b/test/allocation_test.jl @@ -20,7 +20,7 @@ function alloc_solve_model(solve, XData, H, g, ng, calls, max_calls, α) return nothing end -for (Data, solve) in ( +@testset "Allocation test in preprocess and solvemodel" for (Data, solve) in ( (PDataKARC, AdaptiveRegularization.solve_modelKARC), (PDataTRK, AdaptiveRegularization.solve_modelTRK), (PDataST, AdaptiveRegularization.solve_modelST_TR), diff --git a/test/allocation_test_utils.jl b/test/allocation_test_utils.jl index eb094df..e7f0fa8 100644 --- a/test/allocation_test_utils.jl +++ b/test/allocation_test_utils.jl @@ -19,16 +19,18 @@ function alloc_increase(XData, α, TR) return nothing end -for XData in (PDataKARC(S, T, n), PDataTRK(S, T, n), PDataST(S, T, n)) - @testset "Allocation test in AdaptiveRegularization.decrease for $(typeof(XData))" begin - alloc_decrease(XData, α, TR) - al = @allocated alloc_decrease(XData, α, TR) - @test al == 0 - end - @testset "Allocation test in AdaptiveRegularization.decrease for $(typeof(XData))" begin - alloc_increase(XData, α, TR) - al = @allocated alloc_increase(XData, α, TR) - @test al == 0 +@testset "Allocation test in increase/decrease" begin + for XData in (PDataKARC(S, T, n), PDataTRK(S, T, n), PDataST(S, T, n)) + @testset "Allocation test in decrease for $(typeof(XData))" begin + alloc_decrease(XData, α, TR) + al = @allocated alloc_decrease(XData, α, TR) + @test al == 0 + end + @testset "Allocation test in increase for $(typeof(XData))" begin + alloc_increase(XData, α, TR) + al = @allocated alloc_increase(XData, α, TR) + @test al == 0 + end end end @@ -44,15 +46,17 @@ function alloc_hessian(who, nlp, x0) return nothing end -@testset "Test in-place hessian allocations" for (Workspace, limit) in ( - (HessDense, 1952), - (HessSparse, 944), - (HessSparseCOO, 0), - (HessOp, 960), -) - who = Workspace(nlp, n) - alloc_hessian(who, nlp, x0) - al = @allocated alloc_hessian(who, nlp, x0) - @test al <= limit - println("Allocations for $Workspace is $al.") +@testset "Test in-place hessian allocations" begin + @testset "$Workspace" for (Workspace, limit) in ( + (HessDense, 1952), + (HessSparse, 944), + (HessSparseCOO, 0), + (HessOp, 960), + ) + who = Workspace(nlp, n) + alloc_hessian(who, nlp, x0) + al = @allocated alloc_hessian(who, nlp, x0) + @test al <= limit + println("Allocations for $Workspace is $al.") + end end diff --git a/test/runtests.jl b/test/runtests.jl index edab6e1..fb839dd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,19 +23,22 @@ end end end -global nbsolver = 0 -for solver in ALL_solvers - global nbsolver += 1 - nlp = extrosnb(n = 2) - nlpstop = NLPStopping(nlp) - println(nbsolver, " ", solver) - eval(solver)(nlpstop, verbose = true) - final_nlp_at_x, optimal = nlpstop.current_state, nlpstop.meta.optimal - @test optimal - reset!(nlp) - stats = eval(solver)(nlp, verbose = false) - @test stats.status == :first_order - reset!(nlp) +@testset "Invidivual tests on all solvers" begin + global nbsolver = 0 + verbose = false # turn true for debug + @testset "Testing $solver individually" for solver in ALL_solvers + global nbsolver += 1 + nlp = extrosnb(n = 2) + nlpstop = NLPStopping(nlp) + verbose && println(nbsolver, " ", solver) + eval(solver)(nlpstop, verbose = verbose) + final_nlp_at_x, optimal = nlpstop.current_state, nlpstop.meta.optimal + @test optimal + reset!(nlp) + stats = eval(solver)(nlp, verbose = verbose) + @test stats.status == :first_order + reset!(nlp) + end end if VERSION >= v"1.7.0"