Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Eliminate backtrace display when testing __precompile__() #12519

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using Base.Test

olderr = STDERR
dir = mktempdir()
insert!(LOAD_PATH, 1, dir)
insert!(Base.LOAD_CACHE_PATH, 1, dir)
Expand Down Expand Up @@ -32,8 +33,15 @@ try

# use _require_from_serialized to ensure that the test fails if
# the module doesn't load from the image:
println(STDERR, "\nNOTE: The following 'replacing module' warning indicates normal operation:")
@test nothing !== Base._require_from_serialized(myid(), Foo_module, true)
try
rd, wr = redirect_stderr()
@test nothing !== Base._require_from_serialized(myid(), Foo_module, true)
sleep(5)
redirect_stderr(olderr)
catch exc
redirect_stderr(olderr)
rethow(exc)
end

let Foo = eval(Main, Foo_module)
@test Foo.foo(17) == 18
Expand All @@ -57,8 +65,14 @@ try
end
""")
end
println(STDERR, "\nNOTE: The following 'LoadError: __precompile__(false)' indicates normal operation")
@test_throws ErrorException Base.compilecache("Baz") # from __precompile__(false)
try
rd, wr = redirect_stderr()
Base.compilecache("Baz") # from __precompile__(false)
catch exc
redirect_stderr(olderr)
isa(exc, ErrorException) || rethrow(exc)
search(exc.msg, "__precompile__(false)") == 0 && rethrow(exc)
end

# Issue #12720
FooBar_file = joinpath(dir, "FooBar.jl")
Expand All @@ -79,9 +93,18 @@ try
end
""")
end
println(STDERR, "\nNOTE: The following 'LoadError: break me' indicates normal operation")
@test_throws ErrorException Base.require(:FooBar)
try
rd, wr = redirect_stderr()
Base.require(:FooBar)
catch exc
redirect_stderr(olderr)
isa(exc, ErrorException) || rethrow(exc)
search(exc.msg, "ERROR: LoadError: break me") == 0 && rethrow(exc)
end
finally
if STDERR != olderr
redirect_stderr(olderr)
end
splice!(Base.LOAD_CACHE_PATH, 1)
splice!(LOAD_PATH, 1)
rm(dir, recursive=true)
Expand Down
19 changes: 10 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

include("choosetests.jl")
include("testdefs.jl")

tests, net_on = choosetests(ARGS)
tests = unique(tests)

Expand All @@ -11,22 +13,21 @@ if compile_test
end

cd(dirname(@__FILE__)) do
n = 1
n = net_on ? min(8, CPU_CORES, length(tests)) : 1

if compile_test
n > 1 && print("\tFrom worker 1:\t")
runtests("compile")
end

if net_on
n = min(8, CPU_CORES, length(tests))
n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
@everywhere include("testdefs.jl")
blas_set_num_threads(1)
end

@everywhere include("testdefs.jl")

reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true))

if compile_test
n > 1 && print("\tFrom worker 1:\t")
runtests("compile")
end

@unix_only n > 1 && rmprocs(workers(), waitfor=5.0)
println(" \033[32;1mSUCCESS\033[0m")
end