Skip to content

Commit bdd4e05

Browse files
authored
make choosetests find the test files for devved stdlibs (JuliaLang#56558)
I want to move out LinearAlgebra into its own repository but I still want to be able to run its tests in parallel. The easiest would be to be able to use `Base.runtests` but right now it hard codes the path to the stdlib folder. Instead, use the loading mechanism to look up where the stdlib of the active project actively resides.
1 parent 4ed8814 commit bdd4e05

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

base/util.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,20 +678,22 @@ end
678678

679679
"""
680680
Base.runtests(tests=["all"]; ncores=ceil(Int, Sys.CPU_THREADS / 2),
681-
exit_on_error=false, revise=false, [seed])
681+
exit_on_error=false, revise=false, propagate_project=true, [seed])
682682
683683
Run the Julia unit tests listed in `tests`, which can be either a string or an array of
684684
strings, using `ncores` processors. If `exit_on_error` is `false`, when one test
685685
fails, all remaining tests in other files will still be run; they are otherwise discarded,
686686
when `exit_on_error == true`.
687687
If `revise` is `true`, the `Revise` package is used to load any modifications to `Base` or
688688
to the standard libraries before running the tests.
689+
If `propagate_project` is true the current project is propagated to the test environment.
689690
If a seed is provided via the keyword argument, it is used to seed the
690691
global RNG in the context where the tests are run; otherwise the seed is chosen randomly.
691692
"""
692693
function runtests(tests = ["all"]; ncores::Int = ceil(Int, Sys.CPU_THREADS / 2),
693694
exit_on_error::Bool=false,
694695
revise::Bool=false,
696+
propagate_project::Bool=false,
695697
seed::Union{BitInteger,Nothing}=nothing)
696698
if isa(tests,AbstractString)
697699
tests = split(tests)
@@ -706,8 +708,9 @@ function runtests(tests = ["all"]; ncores::Int = ceil(Int, Sys.CPU_THREADS / 2),
706708
ENV2["JULIA_LOAD_PATH"] = string("@", pathsep, "@stdlib")
707709
ENV2["JULIA_TESTS"] = "true"
708710
delete!(ENV2, "JULIA_PROJECT")
711+
project_flag = propagate_project ? `--project` : ``
709712
try
710-
run(setenv(`$(julia_cmd()) $(joinpath(Sys.BINDIR,
713+
run(setenv(`$(julia_cmd()) $project_flag $(joinpath(Sys.BINDIR,
711714
Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2))
712715
nothing
713716
catch

test/choosetests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ const NETWORK_REQUIRED_LIST = vcat(INTERNET_REQUIRED_LIST, ["Sockets"])
4848
function test_path(test)
4949
t = split(test, '/')
5050
if t[1] in STDLIBS
51+
pkgdir = abspath(Base.find_package(String(t[1])), "..", "..")
5152
if length(t) == 2
52-
return joinpath(STDLIB_DIR, t[1], "test", t[2])
53+
return joinpath(pkgdir, "test", t[2])
5354
else
54-
return joinpath(STDLIB_DIR, t[1], "test", "runtests")
55+
return joinpath(pkgdir, "test", "runtests")
5556
end
5657
elseif t[1] == "Compiler"
5758
testpath = length(t) >= 2 ? t[2:end] : ("runtests",)

0 commit comments

Comments
 (0)