|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
2 | | -using Test, LinearAlgebra, SparseArrays |
3 | 2 |
|
4 | | -if Base.get_bool_env("SPARSEARRAYS_AQUA_TEST", false) |
5 | | - include("ambiguous.jl") |
6 | | -end |
| 3 | +using Test, LinearAlgebra, SparseArrays |
7 | 4 |
|
8 | | -for file in readlines(joinpath(@__DIR__, "testgroups")) |
9 | | - file == "" && continue # skip empty lines |
10 | | - include(file * ".jl") |
11 | | -end |
| 5 | +testfiles = [file * ".jl" for file in readlines(joinpath(@__DIR__, "testgroups")) if file != ""] |
12 | 6 |
|
13 | 7 | if Base.USE_GPL_LIBS |
| 8 | + push!(testfiles, "threads_suite.jl") |
| 9 | +end |
14 | 10 |
|
15 | | - nt = @static if isdefined(Threads, :maxthreadid) |
16 | | - Threads.maxthreadid() |
17 | | - else |
18 | | - Threads.nthreads() |
19 | | - end |
20 | | - |
21 | | - # Test multithreaded execution |
22 | | - @testset "threaded SuiteSparse tests" verbose = true begin |
23 | | - @testset "threads = $nt" begin |
24 | | - include("threads.jl") |
25 | | - end |
26 | | - # test both nthreads==1 and nthreads>1. spawn a process to test whichever |
27 | | - # case we are not running currently. |
28 | | - other_nthreads = nt == 1 ? 4 : 1 |
29 | | - @testset "threads = $other_nthreads" begin |
30 | | - let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl` |
31 | | - p = run( |
32 | | - pipeline( |
33 | | - setenv( |
34 | | - cmd, |
35 | | - "JULIA_NUM_THREADS" => other_nthreads, |
36 | | - dir=@__DIR__()), |
37 | | - stdout = stdout, |
38 | | - stderr = stderr), |
39 | | - wait = false) |
40 | | - if !success(p) |
41 | | - error("SuiteSparse threads test failed with nthreads == $other_nthreads") |
42 | | - else |
43 | | - @test true # mimic the one @test in threads.jl |
44 | | - end |
45 | | - end |
46 | | - end |
47 | | - end |
48 | | - |
| 11 | +# ParallelTestRunner comes from the Pkg.test target; Julia base CI runs this |
| 12 | +# file without it and falls back to the serial path. |
| 13 | +if Base.find_package("ParallelTestRunner") !== nothing |
| 14 | + using ParallelTestRunner |
| 15 | + # Auto CPU thread count detection in ParallelTestRunner is bad |
| 16 | + push!(ARGS, "--jobs=$(Sys.CPU_THREADS)") |
| 17 | + testsuite = Dict{String,Expr}(splitext(f)[1] => :(include($(joinpath(@__DIR__, f)))) |
| 18 | + for f in testfiles) |
| 19 | + runtests(SparseArrays, ARGS; testsuite) |
| 20 | +else |
| 21 | + foreach(include, testfiles) |
49 | 22 | end |
0 commit comments