From 43429b6ee0ca5fa0ab88ececc5a98b3f1e8fecbf Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Mon, 12 Oct 2015 12:58:08 -0400 Subject: [PATCH] Run each test in separate julia process to save memory --- test/char.jl | 1 - test/runtests.jl | 28 +++++++++++++++++++++++++--- test/testdefs.jl | 16 ++++------------ 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/test/char.jl b/test/char.jl index 838466a313c12..f7c5c3401ca6b 100644 --- a/test/char.jl +++ b/test/char.jl @@ -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' diff --git a/test/runtests.jl b/test/runtests.jl index 349faf18c64f9..812bc8744f582 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") diff --git a/test/testdefs.jl b/test/testdefs.jl index 944b86d16c781..eb3bbb6c925e4 100644 --- a/test/testdefs.jl +++ b/test/testdefs.jl @@ -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