Skip to content

Commit

Permalink
make pipeline test non-blocking for windows kernel happiness
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Aug 28, 2015
1 parent 5314765 commit f6f2b71
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit f6f2b71

Please sign in to comment.