From f6f2b71f40f4526cae5edc419a10f626a791231d Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 28 Aug 2015 13:49:05 -0400 Subject: [PATCH] make pipeline test non-blocking for windows kernel happiness --- test/spawn.jl | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/test/spawn.jl b/test/spawn.jl index 45ae4b7a1b5e4..66c7320fef6a2 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -248,24 +248,29 @@ let bad = "bad\0name" @test_throws ArgumentError run(setenv(`echo hello`, "good"=>bad)) end -let out = Pipe(), echo = `$exename -f -e 'print(STDOUT, " 1\t", readall(STDIN))'` +let out = Pipe(), echo = `$exename -f -e 'print(STDOUT, " 1\t", readall(STDIN))'`, ready = Condition() @test_throws ArgumentError write(out, "not open error") - open(echo, "w", out) do in1 - open(echo, "w", out) do in2 - write(in1, 'h') - write(in2, UInt8['w']) - println(in1, "ello") - write(in2, "orld\n") + @async begin # spawn writer task + open(echo, "w", out) do in1 + open(echo, "w", out) do in2 + notify(ready) + write(in1, 'h') + write(in2, UInt8['w']) + println(in1, "ello") + write(in2, "orld\n") + end end + show(out, out) + notify(ready) + @test isreadable(out) + @test iswritable(out) + close(out.in) + @test_throws ArgumentError write(out, "now closed error") + @test isreadable(out) + @test !iswritable(out) + @test isopen(out) end - show(out, out) - @test isreadable(out) - @test iswritable(out) - close(out.in) - @test_throws ArgumentError write(out, "now closed error") - @test isreadable(out) - @test !iswritable(out) - @test isopen(out) + wait(ready) # wait for writer task to be ready before using `out` @test nb_available(out) == 0 @test endswith(readuntil(out, '1'), '1') @test read(out, UInt8) == '\t' @@ -285,7 +290,7 @@ let out = Pipe(), echo = `$exename -f -e 'print(STDOUT, " 1\t", readall(STDIN))' @test ln1 == "orld\n" @test isempty(readbytes(out)) @test eof(out) - @test desc == "Pipe(open => open, 0 bytes waiting)" + @test desc == "Pipe(open => active, 0 bytes waiting)" end # issue #8529