From e30ae679f32c848dd670e62100e935f226957f78 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Fri, 17 May 2024 11:40:43 -0400 Subject: [PATCH] Clean up the testing --- .buildkite/pipeline.yml | 2 +- .github/workflows/FormatCheck.yml | 43 +++----------------------- Project.toml | 6 ++-- test/core/23_test_problems_tests.jl | 16 ++++++---- test/core/adjoint_tests.jl | 2 +- test/core/aqua_tests.jl | 2 +- test/core/forward_ad_tests.jl | 4 +-- test/core/least_squares_tests.jl | 2 +- test/core/matrix_resizing_tests.jl | 2 +- test/core/rootfind_tests.jl | 48 ++++++----------------------- test/gpu/cuda_tests.jl | 4 +-- test/runtests.jl | 15 +++++---- 12 files changed, 44 insertions(+), 102 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f95a835..6083fe1 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -22,4 +22,4 @@ env: JULIA_PKG_SERVER: "" RETESTITEMS_NWORKERS: 4 RETESTITEMS_NWORKER_THREADS: 2 - SECRET_CODECOV_TOKEN: "HsC3X/h3CrsRhMR199BUbw9xmASfTTEtdT2JMJlbkW6nsMtZXDIWxKzBNOpn0123zn3K+VE30i7+aLpcqZjlux0BQDMVLx5O5KudjrJmBE2G8KMMv1pra+UHEOFdFP3TzjHXGcHzpUrjpG8if8cHbsWdyQCV0Hdx2qAPnhX5haGPyMuIlRfoaWQfdxJPl5fDLXs1xe0LnMcYMx8uUsvvJZ/hhFtMYWJU0WFtqnAkCR8h/pQd6yZOaGP2SXJkOR8+1xbx+M8m6agH9idp2BjDPpXMOo27V3O2Gkoy3R4b5ouLdqOMaZSIOemoYCv6oh+EkbKaFvZydvm0xCW5YBFPPw==;U2FsdGVkX19FT0yFV6EMY/NVSQslXE6byckN0qa/HVU5dd3d4swmOCWBkBPtemRPGvCMP669iXSPfDTlw7ZSvw==" \ No newline at end of file + SECRET_CODECOV_TOKEN: "HsC3X/h3CrsRhMR199BUbw9xmASfTTEtdT2JMJlbkW6nsMtZXDIWxKzBNOpn0123zn3K+VE30i7+aLpcqZjlux0BQDMVLx5O5KudjrJmBE2G8KMMv1pra+UHEOFdFP3TzjHXGcHzpUrjpG8if8cHbsWdyQCV0Hdx2qAPnhX5haGPyMuIlRfoaWQfdxJPl5fDLXs1xe0LnMcYMx8uUsvvJZ/hhFtMYWJU0WFtqnAkCR8h/pQd6yZOaGP2SXJkOR8+1xbx+M8m6agH9idp2BjDPpXMOo27V3O2Gkoy3R4b5ouLdqOMaZSIOemoYCv6oh+EkbKaFvZydvm0xCW5YBFPPw==;U2FsdGVkX19FT0yFV6EMY/NVSQslXE6byckN0qa/HVU5dd3d4swmOCWBkBPtemRPGvCMP669iXSPfDTlw7ZSvw==" diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index 45bd09c..8601ad5 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -1,42 +1,9 @@ -name: format-check +name: Format suggestions -on: - push: - branches: - - 'main' - - 'release-' - tags: '*' - pull_request: +on: [pull_request] jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - julia-version: [1] - julia-arch: [x86] - os: [ubuntu-latest] + code-style: + runs-on: ubuntu-latest steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - # This will use the latest version by default but you can set the version like so: - # - # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".", verbose=true)' - - name: Format check - run: | - julia -e ' - out = Cmd(`git diff --name-only`) |> read |> String - if out == "" - exit(0) - else - @error "Some files have not been formatted !!!" - write(stdout, out) - exit(1) - end' + - uses: julia-actions/julia-format@v2 diff --git a/Project.toml b/Project.toml index 9a95cb7..c19ca0d 100644 --- a/Project.toml +++ b/Project.toml @@ -39,7 +39,7 @@ SimpleNonlinearSolveZygoteExt = "Zygote" ADTypes = "1" AllocCheck = "0.1.1" Aqua = "0.8" -ArrayInterface = "7.8" +ArrayInterface = "7.9" CUDA = "5.2" ChainRulesCore = "1.22" ConcreteStructs = "0.2.3" @@ -59,8 +59,8 @@ Random = "1.10" ReTestItems = "1.23" Reexport = "1.2" ReverseDiff = "1.15" -SciMLBase = "2.28.0" -SciMLSensitivity = "7.56" +SciMLBase = "2.37.0" +SciMLSensitivity = "7.58" StaticArrays = "1.9" StaticArraysCore = "1.4.2" Test = "1.10" diff --git a/test/core/23_test_problems_tests.jl b/test/core/23_test_problems_tests.jl index 8b8f239..2180943 100644 --- a/test/core/23_test_problems_tests.jl +++ b/test/core/23_test_problems_tests.jl @@ -41,7 +41,7 @@ end export problems, dicts, test_on_library end -@testitem "SimpleNewtonRaphson" setup=[RobustnessTesting] begin +@testitem "SimpleNewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleNewtonRaphson(),) broken_tests = Dict(alg => Int[] for alg in alg_ops) @@ -50,7 +50,7 @@ end test_on_library(problems, dicts, alg_ops, broken_tests) end -@testitem "SimpleTrustRegion" setup=[RobustnessTesting] begin +@testitem "SimpleTrustRegion" setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleTrustRegion(), SimpleTrustRegion(; nlsolve_update_rule = Val(true))) @@ -61,16 +61,20 @@ end test_on_library(problems, dicts, alg_ops, broken_tests) end -@testitem "SimpleDFSane" setup=[RobustnessTesting] begin +@testitem "SimpleDFSane" setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleDFSane(),) broken_tests = Dict(alg => Int[] for alg in alg_ops) - broken_tests[alg_ops[1]] = [1, 2, 3, 4, 5, 6, 11, 21] + if Sys.isapple() + broken_tests[alg_ops[1]] = [1, 2, 3, 5, 6, 21] + else + broken_tests[alg_ops[1]] = [1, 2, 3, 4, 5, 6, 11, 21] + end test_on_library(problems, dicts, alg_ops, broken_tests) end -@testitem "SimpleBroyden" retries=5 setup=[RobustnessTesting] begin +@testitem "SimpleBroyden" retries=5 setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleBroyden(),) broken_tests = Dict(alg => Int[] for alg in alg_ops) @@ -79,7 +83,7 @@ end test_on_library(problems, dicts, alg_ops, broken_tests) end -@testitem "SimpleKlement" setup=[RobustnessTesting] begin +@testitem "SimpleKlement" setup=[RobustnessTesting] tags=[:core] begin alg_ops = (SimpleKlement(),) broken_tests = Dict(alg => Int[] for alg in alg_ops) diff --git a/test/core/adjoint_tests.jl b/test/core/adjoint_tests.jl index 74d745f..749be1a 100644 --- a/test/core/adjoint_tests.jl +++ b/test/core/adjoint_tests.jl @@ -1,4 +1,4 @@ -@testitem "Simple Adjoint Test" begin +@testitem "Simple Adjoint Test" tags=[:core] begin using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote ff(u, p) = u .^ 2 .- p diff --git a/test/core/aqua_tests.jl b/test/core/aqua_tests.jl index 72437ff..364f51b 100644 --- a/test/core/aqua_tests.jl +++ b/test/core/aqua_tests.jl @@ -1,4 +1,4 @@ -@testitem "Aqua" begin +@testitem "Aqua" tags=[:core] begin using Aqua Aqua.test_all(SimpleNonlinearSolve; piracies = false, ambiguities = false) diff --git a/test/core/forward_ad_tests.jl b/test/core/forward_ad_tests.jl index e0852ba..50fc18e 100644 --- a/test/core/forward_ad_tests.jl +++ b/test/core/forward_ad_tests.jl @@ -40,7 +40,7 @@ __compatible(::SimpleHalley, ::Val{:iip}) = false export test_f, test_f!, jacobian_f, solve_with, __compatible end -@testitem "ForwardDiff.jl Integration: Rootfinding" setup=[ForwardADRootfindingTesting] begin +@testitem "ForwardDiff.jl Integration: Rootfinding" setup=[ForwardADRootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in (SimpleNewtonRaphson(), SimpleTrustRegion(), SimpleTrustRegion(; nlsolve_update_rule = Val(true)), SimpleHalley(), SimpleBroyden(), SimpleKlement(), SimpleDFSane()) @@ -133,7 +133,7 @@ export loss_function, loss_function!, loss_function_jac, loss_function_vjp, loss_function_jac!, loss_function_vjp!, θ_init, x, y_target end -@testitem "ForwardDiff.jl Integration: NLLS" setup=[ForwardADNLLSTesting] begin +@testitem "ForwardDiff.jl Integration: NLLS" setup=[ForwardADNLLSTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in ( SimpleNewtonRaphson(), SimpleGaussNewton(), SimpleNewtonRaphson(AutoFiniteDiff()), SimpleGaussNewton(AutoFiniteDiff())) diff --git a/test/core/least_squares_tests.jl b/test/core/least_squares_tests.jl index 840a4f2..ef3a055 100644 --- a/test/core/least_squares_tests.jl +++ b/test/core/least_squares_tests.jl @@ -1,4 +1,4 @@ -@testitem "Nonlinear Least Squares" begin +@testitem "Nonlinear Least Squares" tags=[:core] begin using LinearAlgebra true_function(x, θ) = @. θ[1] * exp(θ[2] * x) * cos(θ[3] * x + θ[4]) diff --git a/test/core/matrix_resizing_tests.jl b/test/core/matrix_resizing_tests.jl index 54cf86b..17cd3d6 100644 --- a/test/core/matrix_resizing_tests.jl +++ b/test/core/matrix_resizing_tests.jl @@ -1,4 +1,4 @@ -@testitem "Matrix Resizing" begin +@testitem "Matrix Resizing" tags=[:core] begin ff(u, p) = u .* u .- p u0 = ones(2, 3) p = 2.0 diff --git a/test/core/rootfind_tests.jl b/test/core/rootfind_tests.jl index 726a6dd..ca0e26e 100644 --- a/test/core/rootfind_tests.jl +++ b/test/core/rootfind_tests.jl @@ -39,7 +39,7 @@ export quadratic_f, quadratic_f!, quadratic_f2, newton_fails, TERMINATION_CONDIT end -@testitem "First Order Methods" setup=[RootfindingTesting] begin +@testitem "First Order Methods" setup=[RootfindingTesting] tags=[:core] begin @testset "$(alg)" for alg in (SimpleNewtonRaphson, SimpleTrustRegion, (args...; kwargs...) -> SimpleTrustRegion(args...; nlsolve_update_rule = Val(true), kwargs...)) @@ -70,7 +70,7 @@ end end end -@testitem "SimpleHalley" setup=[RootfindingTesting] begin +@testitem "SimpleHalley" setup=[RootfindingTesting] tags=[:core] begin @testset "AutoDiff: $(nameof(typeof(autodiff)))" for autodiff in (AutoFiniteDiff(), AutoForwardDiff()) @testset "[OOP] u0: $(nameof(typeof(u0)))" for u0 in ([1.0, 1.0], @@ -89,7 +89,7 @@ end end end -@testitem "Derivative Free Metods" setup=[RootfindingTesting] begin +@testitem "Derivative Free Metods" setup=[RootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in [SimpleBroyden(), SimpleKlement(), SimpleDFSane(), SimpleLimitedMemoryBroyden(), SimpleBroyden(; linesearch = Val(true)), @@ -115,7 +115,7 @@ end end end -@testitem "Newton Fails" setup=[RootfindingTesting] begin +@testitem "Newton Fails" setup=[RootfindingTesting] tags=[:core] begin u0 = [-10.0, -1.0, 1.0, 2.0, 3.0, 4.0, 10.0] p = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] @@ -127,13 +127,13 @@ end end end -@testitem "Kwargs Propagation" setup=[RootfindingTesting] begin +@testitem "Kwargs Propagation" setup=[RootfindingTesting] tags=[:core] begin prob = NonlinearProblem(quadratic_f, ones(4), 2.0; maxiters = 2) sol = solve(prob, SimpleNewtonRaphson()) @test sol.retcode === ReturnCode.MaxIters end -@testitem "Allocation Checks" setup=[RootfindingTesting] begin +@testitem "Allocation Checks" setup=[RootfindingTesting] tags=[:core] begin if Sys.islinux() # Very slow on other OS @testset "$(nameof(typeof(alg)))" for alg in (SimpleNewtonRaphson(), SimpleHalley(), SimpleBroyden(), SimpleKlement(), SimpleLimitedMemoryBroyden(), @@ -165,7 +165,7 @@ end end end -@testitem "Interval Nonlinear Problems" setup=[RootfindingTesting] begin +@testitem "Interval Nonlinear Problems" setup=[RootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in (Bisection(), Falsi(), Ridder(), Brent(), ITP(), Alefeld()) tspan = (1.0, 20.0) @@ -209,7 +209,7 @@ end end end -@testitem "Tolerance Tests Interval Methods" setup=[RootfindingTesting] begin +@testitem "Tolerance Tests Interval Methods" setup=[RootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in (Bisection(), Falsi(), ITP()) tspan = (1.0, 20.0) probB = IntervalNonlinearProblem(quadratic_f, tspan, 2.0) @@ -224,7 +224,7 @@ end end end -@testitem "Tolerance Tests Interval Methods 2" setup=[RootfindingTesting] begin +@testitem "Tolerance Tests Interval Methods 2" setup=[RootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in (Ridder(), Brent()) tspan = (1.0, 20.0) probB = IntervalNonlinearProblem(quadratic_f, tspan, 2.0) @@ -239,7 +239,7 @@ end end end -@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTesting] begin +@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTesting] tags=[:core] begin @testset "$(nameof(typeof(alg)))" for alg in (Alefeld(), Bisection(), Falsi(), Brent(), ITP(), Ridder()) f1(u, p) = u * u - p @@ -257,31 +257,3 @@ end end end end - -# The following tests were included in the previos versions but these kwargs never did -# anything! -# # Garuntee Tests for Bisection -# f = function (u, p) -# if u < 2.0 -# return u - 2.0 -# elseif u > 3.0 -# return u - 3.0 -# else -# return 0.0 -# end -# end -# probB = IntervalNonlinearProblem(f, (0.0, 4.0)) - -# sol = solve(probB, Bisection(; exact_left = true)) -# @test f(sol.left, nothing) < 0.0 -# @test f(nextfloat(sol.left), nothing) >= 0.0 - -# sol = solve(probB, Bisection(; exact_right = true)) -# @test f(sol.right, nothing) >= 0.0 -# @test f(prevfloat(sol.right), nothing) <= 0.0 - -# sol = solve(probB, Bisection(; exact_left = true, exact_right = true); immutable = false) -# @test f(sol.left, nothing) < 0.0 -# @test f(nextfloat(sol.left), nothing) >= 0.0 -# @test f(sol.right, nothing) >= 0.0 -# @test f(prevfloat(sol.right), nothing) <= 0.0 diff --git a/test/gpu/cuda_tests.jl b/test/gpu/cuda_tests.jl index 37999da..dae6a87 100644 --- a/test/gpu/cuda_tests.jl +++ b/test/gpu/cuda_tests.jl @@ -1,4 +1,4 @@ -@testitem "Solving on GPUs" begin +@testitem "Solving on GPUs" tags=[:cuda] begin using StaticArrays, CUDA CUDA.allowscalar(false) @@ -36,7 +36,7 @@ end end -@testitem "CUDA Kernel Launch Test" begin +@testitem "CUDA Kernel Launch Test" tags=[:cuda] begin using StaticArrays, CUDA CUDA.allowscalar(false) diff --git a/test/runtests.jl b/test/runtests.jl index 1a2e93b..1dacfd3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,10 @@ -using ReTestItems +using ReTestItems, CUDA -const GROUP = get(ENV, "GROUP", "All") +const GROUP = get(ENV, "GROUP", CUDA.functional() ? "All" : "Core") -if GROUP == "All" || GROUP == "Core" - ReTestItems.runtests(joinpath(@__DIR__, "core/")) -end - -if GROUP == "GPU" - ReTestItems.runtests(joinpath(@__DIR__, "gpu/")) +if GROUP == "All" + ReTestItems.runtests(@__DIR__; tags = [:all]) +else + tags = [Symbol(lowercase(GROUP))] + ReTestItems.runtests(@__DIR__; tags) end