diff --git a/src/iterative_wrappers.jl b/src/iterative_wrappers.jl index 3c03ea7d..bb93ba63 100644 --- a/src/iterative_wrappers.jl +++ b/src/iterative_wrappers.jl @@ -306,5 +306,5 @@ function SciMLBase.solve!(cache::LinearCache, alg::KrylovJL; kwargs...) end return SciMLBase.build_linear_solution(alg, cache.u, resid, cache; - iters = stats.niter) + iters = stats.niter, retcode, stats) end diff --git a/test/retcodes.jl b/test/retcodes.jl new file mode 100644 index 00000000..61b4ecaa --- /dev/null +++ b/test/retcodes.jl @@ -0,0 +1,46 @@ +using LinearSolve + +alglist = ( + LUFactorization, + QRFactorization, + DiagonalFactorization, + DirectLdiv!, + SparspakFactorization, + KLUFactorization, + UMFPACKFactorization, + KrylovJL_GMRES, + GenericLUFactorization, + RFLUFactorization, + LDLtFactorization, + BunchKaufmanFactorization, + CHOLMODFactorization, + SVDFactorization, + CholeskyFactorization, + NormalCholeskyFactorization, + AppleAccelerateLUFactorization, + MKLLUFactorization, + KrylovJL_CRAIGMR, + KrylovJL_LSMR, +) + +@testset "Success" begin + for alg in alglist + A = [2.0 1.0; -1.0 1.0] + b = [-1.0, 1.0] + prob = LinearProblem(A, b) + linsolve = init(prob, alg) + sol = solve!(linsolve) + @test SciMLBase.successful_retcode(sol.retcode) || sol.retcode == ReturnCode.Default # The latter seems off... + end +end + +@testset "Failure" begin + for alg in alglist + A = [1.0 1.0; 1.0 1.0] + b = [-1.0, 1.0] + prob = LinearProblem(A, b) + linsolve = init(prob, alg) + sol = solve!(linsolve) + @test !SciMLBase.successful_retcode(sol.retcode) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 4994eba2..8d7b626f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,7 @@ const HAS_EXTENSIONS = isdefined(Base, :get_extension) if GROUP == "All" || GROUP == "Core" @time @safetestset "Quality Assurance" include("qa.jl") @time @safetestset "Basic Tests" include("basictests.jl") + @time @safetestset "Return codes" include("retcodes.jl") @time @safetestset "Re-solve" include("resolve.jl") @time @safetestset "Zero Initialization Tests" include("zeroinittests.jl") @time @safetestset "Non-Square Tests" include("nonsquare.jl")