From 0d36b107a9a15c5826d4d105e08ca9c74c3ec0a7 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 15 Apr 2021 20:20:03 -0400 Subject: [PATCH] fix remotecall --- test/misc.jl | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/test/misc.jl b/test/misc.jl index dbe26fb19e9ee5..1c1b35f85a0103 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -519,23 +519,36 @@ let buf = IOBuffer() end # stdin is unavailable on the workers. Run test on master. -remotecall_fetch(1) do - let buf = IOBuffer() - original_stdin = stdin - (rd, wr) = redirect_stdin() - @test Base.prompt(rd, buf, "baz", default="foobar", timeout = 1) == "foobar" - @test String(take!(buf)) == "baz [foobar] timeout 1 second: timed out\n" - @test Base.prompt(rd, buf, "baz", default="foobar", timeout = 2) == "foobar" - @test String(take!(buf)) == "baz [foobar] timeout 2 seconds: timed out\n" - write(wr, "foo\n") - @test Base.prompt(rd, buf, "baz", default="foobar", timeout = 1) == "foo" - @test String(take!(buf)) == "baz [foobar] timeout 1 second: " - write(wr, "\n") - @test Base.prompt(rd, buf, "baz", default="foobar", timeout = 1) == "foobar" - @test String(take!(buf)) == "baz [foobar] timeout 1 second: " - redirect_stdin(original_stdin) +ret = Core.eval(Main, quote + remotecall_fetch(1) do + let buf = IOBuffer() + original_stdin = stdin + (rd, wr) = redirect_stdin() + vals = String[] + push!(vals, Base.prompt(rd, buf, "baz", default="foobar", timeout = 1)) + push!(vals, String(take!(buf))) + push!(vals, Base.prompt(rd, buf, "baz", default="foobar", timeout = 2)) + push!(vals, String(take!(buf))) + write(wr, "foo\n") + push!(vals, Base.prompt(rd, buf, "baz", default="foobar", timeout = 1)) + push!(vals, String(take!(buf))) + write(wr, "\n") + push!(vals, Base.prompt(rd, buf, "baz", default="foobar", timeout = 1)) + push!(vals, String(take!(buf))) + redirect_stdin(original_stdin) + vals + end end -end +end) + +@test ret[1] == "foobar" +@test ret[2] == "baz [foobar] timeout 1 second: timed out\n" +@test ret[3] == "foobar" +@test ret[4] == "baz [foobar] timeout 2 seconds: timed out\n" +@test ret[5] == "foo" +@test ret[6] == "baz [foobar] timeout 1 second: " +@test ret[7] == "foobar" +@test ret[8] == "baz [foobar] timeout 1 second: " # these tests are not in a test block so that they will compile separately @static if Sys.iswindows()