|
2 | 2 |
|
3 | 3 | using Base.Test
|
4 | 4 |
|
| 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 |
5 | 12 | dir = mktempdir()
|
6 | 13 | dir2 = mktempdir()
|
7 | 14 | insert!(LOAD_PATH, 1, dir)
|
|
32 | 39 |
|
33 | 40 | # use _require_from_serialized to ensure that the test fails if
|
34 | 41 | # 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 |
37 | 48 |
|
38 | 49 | let Foo = eval(Main, Foo_module)
|
39 | 50 | @test Foo.foo(17) == 18
|
|
57 | 68 | end
|
58 | 69 | """)
|
59 | 70 |
|
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 |
62 | 80 |
|
63 | 81 | # Issue #12720
|
64 | 82 | FooBar_file = joinpath(dir, "FooBar.jl")
|
|
89 | 107 | end
|
90 | 108 | """)
|
91 | 109 |
|
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 |
95 | 119 | finally
|
| 120 | + if STDERR != olderr |
| 121 | + redirect_stderr(olderr) |
| 122 | + end |
96 | 123 | splice!(Base.LOAD_CACHE_PATH, 1:2)
|
97 | 124 | splice!(LOAD_PATH, 1)
|
98 | 125 | rm(dir, recursive=true)
|
|
0 commit comments