Skip to content

Commit b3b1411

Browse files
committed
Merge pull request #14117 from JuliaLang/ScottPJones-spj/redirectcompile
spj/redirectcompile
2 parents 06c93ce + 33545c0 commit b3b1411

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

test/compile.jl

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
using Base.Test
44

5+
function redirected_stderr()
6+
rd, wr = redirect_stderr()
7+
@async readall(rd) # make sure the kernel isn't being forced to buffer the output
8+
nothing
9+
end
10+
11+
olderr = STDERR
512
dir = mktempdir()
613
dir2 = mktempdir()
714
insert!(LOAD_PATH, 1, dir)
@@ -32,8 +39,12 @@ try
3239

3340
# use _require_from_serialized to ensure that the test fails if
3441
# the module doesn't load from the image:
35-
println(STDERR, "\nNOTE: The following 'replacing module' warning indicates normal operation:")
36-
@test nothing !== Base._require_from_serialized(myid(), Foo_module, true)
42+
try
43+
redirected_stderr()
44+
@test nothing !== Base._require_from_serialized(myid(), Foo_module, #=broadcast-load=#false)
45+
finally
46+
redirect_stderr(olderr)
47+
end
3748

3849
let Foo = eval(Main, Foo_module)
3950
@test Foo.foo(17) == 18
@@ -57,8 +68,15 @@ try
5768
end
5869
""")
5970

60-
println(STDERR, "\nNOTE: The following 'LoadError: __precompile__(false)' indicates normal operation")
61-
@test_throws ErrorException Base.compilecache("Baz") # from __precompile__(false)
71+
try
72+
redirected_stderr()
73+
Base.compilecache("Baz") # from __precompile__(false)
74+
error("__precompile__ disabled test failed")
75+
catch exc
76+
redirect_stderr(olderr)
77+
isa(exc, ErrorException) || rethrow(exc)
78+
!isempty(search(exc.msg, "__precompile__(false)")) && rethrow(exc)
79+
end
6280

6381
# Issue #12720
6482
FooBar_file = joinpath(dir, "FooBar.jl")
@@ -89,10 +107,19 @@ try
89107
end
90108
""")
91109

92-
println(STDERR, "\nNOTE: The following 'LoadError: break me' indicates normal operation")
93-
@test_throws ErrorException Base.require(:FooBar)
94-
110+
try
111+
redirected_stderr()
112+
Base.require(:FooBar)
113+
error("\"LoadError: break me\" test failed")
114+
catch exc
115+
redirect_stderr(olderr)
116+
isa(exc, ErrorException) || rethrow(exc)
117+
!isempty(search(exc.msg, "ERROR: LoadError: break me")) && rethrow(exc)
118+
end
95119
finally
120+
if STDERR != olderr
121+
redirect_stderr(olderr)
122+
end
96123
splice!(Base.LOAD_CACHE_PATH, 1:2)
97124
splice!(LOAD_PATH, 1)
98125
rm(dir, recursive=true)

0 commit comments

Comments
 (0)