Skip to content

Commit

Permalink
test/file: try to fix freezing of test_22566
Browse files Browse the repository at this point in the history
- wrap the long single scripts

- using `$(repr(fn))` for inserting temp file name
  • Loading branch information
iblislin committed Jul 29, 2017
1 parent e1a604e commit 35150c0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,16 @@ function test_13559()
fn = tempname()
run(`mkfifo $fn`)
# use subprocess to write 127 bytes to FIFO
writer_cmds = "x=open(\"$fn\", \"w\"); for i=1:127 write(x,0xaa); flush(x); sleep(0.1) end; close(x); quit()"
writer_cmds = """
x = open($(repr(fn)), "w")
for i=1:127
write(x,0xaa)
flush(x)
sleep(0.1)
end
close(x)
quit()
"""
open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=STDERR))
#quickly read FIFO, draining it and blocking but not failing with EOFError yet
r = open(fn, "r")
Expand All @@ -1133,19 +1142,26 @@ function test_13559()
end
test_13559()
end
@test_throws ArgumentError mkpath("fakepath",-1)
@test_throws ArgumentError mkpath("fakepath", -1)

# issue #22566
if !Sys.iswindows()
function test_22566()
fn = tempname()
run(`mkfifo $fn`)

script = "x = open(\"$fn\", \"w\"); close(x)"
script = """
x = open($(repr(fn)), "w")
write(x, 0x42)
flush(x)
close(x)
quit()
"""
cmd = `$(Base.julia_cmd()) --startup-file=no -e $script`
open(pipeline(cmd, stderr=STDERR))

r = open(fn, "r")
@test read(r, Int8) == 66
close(r)

rm(fn)
Expand Down

0 comments on commit 35150c0

Please sign in to comment.