Skip to content

Commit

Permalink
Run each test in separate julia process to save memory
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Oct 12, 2015
1 parent 6aa15b8 commit 43429b6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
1 change: 0 additions & 1 deletion test/char.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

#tests for /base/char.jl

@test typemin(Char) == 0
@test ndims(Char) == 0
@test getindex('a', 1) == 'a'
Expand Down
28 changes: 25 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,35 @@ cd(dirname(@__FILE__)) do
n = 1
if net_on
n = min(8, CPU_CORES, length(tests))
n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
blas_set_num_threads(1)
# n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
# blas_set_num_threads(1)
end

@everywhere include("testdefs.jl")

reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true))
# reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true))
tr = Int[]
m = 0
while !isempty(tests)
if m < n
testi = shift!(tests)
m += 1
@schedule begin
push!(tr, !runtests(testi))
m -= 1
return nothing
end
else
sleep(0.5)
end
sleep(0.1)
end
while m > 0
wait()
end
if sum(tr) > 0
error("total number of errors was $(sum(tr))")
end

if compile_test
n > 1 && print("\tFrom worker 1:\t")
Expand Down
16 changes: 4 additions & 12 deletions test/testdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
using Base.Test

function runtests(name)
exename = joinpath(JULIA_HOME, Base.julia_exename())
testcmd = "using Base.Test; blas_set_num_threads(1); include(\"$name.jl\") " # use space to add single quotes when printed in shell
tt = @elapsed (r = success(pipeline(`$exename --check-bounds=yes --depwarn=error -e $testcmd`, stderr=STDERR)))
@printf(" \033[1m*\033[0m \033[31m%-21s\033[0m", name)
tt = @elapsed include("$name.jl")
@printf(" in %6.2f seconds\n", tt)
nothing
end

function propagate_errors(a,b)
if isa(a,Exception)
rethrow(a)
end
if isa(b,Exception)
rethrow(b)
end
nothing
return r
end

# looking in . messes things up badly
Expand Down

0 comments on commit 43429b6

Please sign in to comment.