Skip to content

Commit

Permalink
Move testenv specific consts and addprocs to a separate file. (JuliaL…
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmurthy authored May 7, 2017
1 parent 2001c26 commit 4d08b54
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
1 change: 1 addition & 0 deletions test/distributed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Run the distributed test outside of the main driver since it needs its own
# set of dedicated workers.

include("testenv.jl")
cmd = `$test_exename $test_exeflags distributed_exec.jl`

if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) && ccall(:jl_running_on_valgrind,Cint,()) == 0
Expand Down
2 changes: 1 addition & 1 deletion test/distributed_exec.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Base.Test
include("testdefs.jl")
include("testenv.jl")

# Test a few "remote" invocations when no workers are present
@test remote(myid)() == 1
Expand Down
11 changes: 4 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Base.Test
include("choosetests.jl")
include("testdefs.jl")
include("testenv.jl")

tests, net_on = choosetests(ARGS)
tests = unique(tests)
Expand Down Expand Up @@ -30,15 +30,12 @@ cd(dirname(@__FILE__)) do
n = 1
if net_on
n = min(Sys.CPU_CORES, length(tests))
if n > 1
addprocs_with_testenv(n)
@sync for p in workers()
@async remotecall_fetch(include, p, "testdefs.jl")
end
end
n > 1 && addprocs_with_testenv(n)
BLAS.set_num_threads(1)
end

@everywhere include("testdefs.jl")

#pretty print the information about gc and mem usage
name_align = maximum([length("Test (Worker)"); map(x -> length(x) + 3 + ndigits(nworkers()), tests)])
elapsed_align = length("Time (s)")
Expand Down
22 changes: 0 additions & 22 deletions test/testdefs.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

if haskey(ENV, "JULIA_TEST_EXEFLAGS")
const test_exeflags = `$(Base.shell_split(ENV["JULIA_TEST_EXEFLAGS"]))`
else
inline_flag = Base.JLOptions().can_inline == 1 ? `` : `--inline=no`
cov_flag = ``
if Base.JLOptions().code_coverage == 1
cov_flag = `--code-coverage=user`
elseif Base.JLOptions().code_coverage == 2
cov_flag = `--code-coverage=all`
end
const test_exeflags = `$cov_flag $inline_flag --check-bounds=yes --startup-file=no --depwarn=error`
end

if haskey(ENV, "JULIA_TEST_EXENAME")
const test_exename = `$(Base.shell_split(ENV["JULIA_TEST_EXENAME"]))`
else
const test_exename = `$(joinpath(JULIA_HOME, Base.julia_exename()))`
end

addprocs_with_testenv(X; kwargs...) = addprocs(X; exename=test_exename, exeflags=test_exeflags, kwargs...)

function runtests(name, isolate=true)
old_print_setting = Base.Test.TESTSET_PRINT_ENABLE[]
Base.Test.TESTSET_PRINT_ENABLE[] = false
Expand All @@ -30,7 +9,6 @@ function runtests(name, isolate=true)
# code it in the test
mod_name = Symbol("Test", rand(1:100), "Main_", replace(name, '/', '_'))
m = @eval(Main, module $mod_name end)
eval(m, :(import Main: test_exename, test_exeflags, addprocs_with_testenv))
else
m = Main
end
Expand Down
22 changes: 22 additions & 0 deletions test/testenv.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

if haskey(ENV, "JULIA_TEST_EXEFLAGS")
const test_exeflags = `$(Base.shell_split(ENV["JULIA_TEST_EXEFLAGS"]))`
else
inline_flag = Base.JLOptions().can_inline == 1 ? `` : `--inline=no`
cov_flag = ``
if Base.JLOptions().code_coverage == 1
cov_flag = `--code-coverage=user`
elseif Base.JLOptions().code_coverage == 2
cov_flag = `--code-coverage=all`
end
const test_exeflags = `$cov_flag $inline_flag --check-bounds=yes --startup-file=no --depwarn=error`
end

if haskey(ENV, "JULIA_TEST_EXENAME")
const test_exename = `$(Base.shell_split(ENV["JULIA_TEST_EXENAME"]))`
else
const test_exename = `$(joinpath(JULIA_HOME, Base.julia_exename()))`
end

addprocs_with_testenv(X; kwargs...) = addprocs(X; exename=test_exename, exeflags=test_exeflags, kwargs...)

0 comments on commit 4d08b54

Please sign in to comment.