Skip to content

Commit c0ddd43

Browse files
authored
Merge pull request #132 from JuliaDebug/sp/fix-tests-1.11
hack: fix 1.11 tests
2 parents b01991a + 72c32b2 commit c0ddd43

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

test/runtests.jl

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,45 @@ function globalref(m, s)
8484
return gr
8585
end
8686

87-
@testset "infiltration tests" begin
88-
if Sys.isunix() && VERSION >= v"1.1.0"
89-
using TerminalRegressionTests
90-
91-
function run_terminal_test(func, result, commands, validation)
92-
test_func = TerminalRegressionTests.automated_test
93-
if haskey(ENV, "INFILTRATOR_CREATE_TEST") && !haskey(ENV, "CI")
94-
test_func = TerminalRegressionTests.create_automated_test
95-
end
96-
test_func(joinpath(@__DIR__, "outputs", validation), commands) do emuterm
97-
Infiltrator.end_session!()
98-
repl = REPL.LineEditREPL(emuterm, true)
99-
repl.interface = REPL.setup_interface(repl)
100-
repl.mistate = REPL.LineEdit.init_state(REPL.terminal(repl), repl.interface)
101-
repl.specialdisplay = REPL.REPLDisplay(repl)
102-
103-
Infiltrator.TEST_TERMINAL_REF[] = repl.t
104-
Infiltrator.TEST_NOSTACK[] = true
105-
Infiltrator.TEST_REPL_REF[] = repl;
106-
Infiltrator.CHECK_TASK[] = false
107-
108-
@test func(repl.t) == result
109-
110-
Infiltrator.TEST_TERMINAL_REF[] = nothing
111-
Infiltrator.TEST_NOSTACK[] = false
112-
Infiltrator.TEST_REPL_REF[] = nothing
113-
if VERSION > v"1.9-"
114-
finalize(emuterm.pty)
115-
end
87+
@static if Sys.isunix() && VERSION >= v"1.1.0"
88+
using TerminalRegressionTests
89+
90+
@static if VERSION >= v"1.11"
91+
# FIXME: this is a hack to work around the test failures on 1.11.
92+
# The LineEdit code now assumes that eof and peek interact correctly (i.e. that
93+
# `eof(term) || peek(term)` won't error), but that's not true for EmulatedTerminals.
94+
@eval Base.peek(::TerminalRegressionTests.EmulatedTerminal) = UInt8(0)
95+
end
96+
97+
function run_terminal_test(func, result, commands, validation)
98+
test_func = TerminalRegressionTests.automated_test
99+
if haskey(ENV, "INFILTRATOR_CREATE_TEST") && !haskey(ENV, "CI")
100+
test_func = TerminalRegressionTests.create_automated_test
101+
end
102+
test_func(joinpath(@__DIR__, "outputs", validation), commands) do emuterm
103+
Infiltrator.end_session!()
104+
repl = REPL.LineEditREPL(emuterm, true)
105+
repl.interface = REPL.setup_interface(repl)
106+
repl.mistate = REPL.LineEdit.init_state(REPL.terminal(repl), repl.interface)
107+
repl.specialdisplay = REPL.REPLDisplay(repl)
108+
109+
Infiltrator.TEST_TERMINAL_REF[] = repl.t
110+
Infiltrator.TEST_NOSTACK[] = true
111+
Infiltrator.TEST_REPL_REF[] = repl;
112+
Infiltrator.CHECK_TASK[] = false
113+
114+
@test func(repl.t) == result
115+
116+
Infiltrator.TEST_TERMINAL_REF[] = nothing
117+
Infiltrator.TEST_NOSTACK[] = false
118+
Infiltrator.TEST_REPL_REF[] = nothing
119+
if VERSION > v"1.9-"
120+
finalize(emuterm.pty)
116121
end
117122
end
123+
end
124+
125+
@testset "infiltration tests" begin
118126
run_terminal_test((t) -> f(3), [3, 4, 5],
119127
["?\n", "@trace\n", "@locals\n", "x.*y\n", "3+\n4\n", "ans\n", "baz\n", "0//0\n", "@toggle\n", "@toggle\n", "@toggle\n", "\x4"],
120128
"Julia_f_$(VERSION.major).$(VERSION.minor).multiout")
@@ -227,15 +235,27 @@ end
227235
run_terminal_test((t) -> cond(t), nothing,
228236
["@continue\n", "@continue\n", "@cond i > 6\n", "@continue\n", "i\n", "@exit\n"],
229237
"Julia_cond_$(VERSION.major).$(VERSION.minor).multiout")
238+
end
230239

231-
# @infiltry
232-
println("inflitry")
240+
@testset "infiltry" begin
233241
run_terminal_test((t) -> try; infiltry(0); catch; nothing; end, nothing,
234242
["@exception\n", "@locals\n", "@exit\n"],
235243
"Julia_infiltry_$(VERSION.major).$(VERSION.minor).multiout")
236-
else
237-
@warn "Skipping UI tests on non unix systems"
244+
245+
function foo(x)
246+
@infiltry z = 2x
247+
z
248+
end
249+
@test foo(2) == 4
250+
251+
function bar(x)
252+
@infiltry y, z = 2x, 3x
253+
y + z
254+
end
255+
@test bar(1) == 5
238256
end
257+
else
258+
@warn "Skipping UI tests on non unix systems"
239259
end
240260

241261
@testset "exfiltration tests" begin
@@ -259,17 +279,3 @@ end
259279
@test 6 == Core.eval(@__MODULE__, :(Infiltrator.@withstore(2y)))
260280
@test "asd" == Core.eval(@__MODULE__, :(Infiltrator.@withstore(string(foo))))
261281
end
262-
263-
@testset "infiltry allows assignments" begin
264-
function foo(x)
265-
@infiltry z = 2x
266-
z
267-
end
268-
@test foo(2) == 4
269-
270-
function bar(x)
271-
@infiltry y, z = 2x, 3x
272-
y + z
273-
end
274-
@test bar(1) == 5
275-
end

0 commit comments

Comments
 (0)