Skip to content

Commit 515d93c

Browse files
authored
Use path replacement for the UI tests (#77)
1 parent 2322c76 commit 515d93c

8 files changed

+71
-21
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
environment:
22
matrix:
3+
- julia_version: 1.0
34
- julia_version: 1
4-
- julia_version: 1.1
55
- julia_version: nightly
66

77
platform:

test/interpret_ui.jl

+58-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,70 @@
11
# This was copied from Debugger.jl and then modified
22

3-
using TerminalRegressionTests, Rebugger, Revise
3+
using TerminalRegressionTests, Rebugger, Revise, CodeTracking
44
using HeaderREPLs, REPL
55
using Test
66

7+
includet("my_gcd.jl")
8+
79
function run_terminal_test(cmd, validation, commands)
10+
function compare_replace(em, target; replace=nothing)
11+
# Compare two buffer, skipping over the equivalent of key=>rep replacement
12+
# However, because of potential differences in wrapping we don't explicitly
13+
# perform the replacement; instead, we make the comparison tolerant of difference
14+
# `\n`.
15+
buf = IOBuffer()
16+
decoratorbuf = IOBuffer()
17+
TerminalRegressionTests.VT100.dump(buf, decoratorbuf, em)
18+
outbuf = take!(buf)
19+
success = true
20+
if replace !== nothing
21+
output = String(outbuf)
22+
key, rep = replace
23+
idxkey = findfirst(key, target)
24+
iout, itgt = firstindex(output), firstindex(target)
25+
outlast, tgtlast = lastindex(output), lastindex(target)
26+
lrep = length(rep)
27+
while success && iout <= outlast && itgt <= tgtlast
28+
if itgt == first(idxkey)
29+
itgt += length(key)
30+
for c in rep
31+
cout = output[iout]
32+
while c != cout && cout == '\n'
33+
iout = nextind(output, iout)
34+
cout = output[iout]
35+
end
36+
if c != cout
37+
success = false
38+
break
39+
end
40+
iout = nextind(output, iout)
41+
end
42+
else
43+
cout, ctgt = output[iout], target[itgt]
44+
success = cout == ctgt
45+
iout, itgt = nextind(output, iout), nextind(target, itgt)
46+
end
47+
end
48+
success && iout > outlast && itgt > tgtlast && return true
49+
end
50+
outbuf == codeunits(target) && return true
51+
open("failed.out","w") do f
52+
write(f, output)
53+
end
54+
open("expected.out","w") do f
55+
write(f, target)
56+
end
57+
error("Test failed. Expected result written to expected.out,
58+
actual result written to failed.out")
59+
end
60+
861
dirpath = joinpath(@__DIR__, "ui", "v$(VERSION.major).$(VERSION.minor)")
962
isdir(dirpath) || mkpath(dirpath)
1063
filepath = joinpath(dirpath, validation)
11-
TerminalRegressionTests.automated_test(filepath, commands) do emuterm
64+
# Fix the path of gcd to match the current running version of Julia
65+
gcdfile, gcdline = whereis(@which my_gcd(10, 20))
66+
cmp(a, b, decorator) = compare_replace(a, b; replace="****" => gcdfile*':'*string(gcdline))
67+
TerminalRegressionTests.automated_test(cmp, filepath, commands) do emuterm
1268
# TerminalRegressionTests.create_automated_test(filepath, commands) do emuterm
1369
main_repl = REPL.LineEditREPL(emuterm, true)
1470
main_repl.interface = REPL.setup_interface(main_repl)
@@ -25,8 +81,6 @@ function run_terminal_test(cmd, validation, commands)
2581
end
2682
end
2783

28-
includet("my_gcd.jl")
29-
3084
CTRL_C = "\x3"
3185
EOT = "\x4"
3286
UP_ARROW = "\e[A"

test/ui/v1.2/gcd.multiout

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|gcd(10, 20)
33
|gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt1
4-
|6, UInt32, UInt64, UInt8} in Base at /home/tim/src/julia-1/base/intfuncs.jl:31
4+
|6, UInt32, UInt64, UInt8} in Base at ****
55
| a = 10
66
| b = 20
77
| T = Int64
@@ -12,8 +12,8 @@
1212
|
1313
--------------------------------------------------
1414
|AAAAAAAAAAA
15-
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1615
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
16+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1717
|AAAAAAAA
1818
|AAAAAAAA
1919
|AAAAAAAAAAA

test/ui/v1.2/gcdsc.multiout

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|__gcdval__ = gcd(10, 20);
33
|gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt1
4-
|6, UInt32, UInt64, UInt8} in Base at /home/tim/src/julia-1/base/intfuncs.jl:31
4+
|6, UInt32, UInt64, UInt8} in Base at ****
55
| a = 10
66
| b = 20
77
| T = Int64
@@ -12,8 +12,8 @@
1212
|
1313
--------------------------------------------------
1414
|AAAAAAAAAAAAAAAAAAAAAAAAA
15-
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1615
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
16+
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1717
|AAAAAAAA
1818
|AAAAAAAA
1919
|AAAAAAAAAAA

test/ui/v1.3/gcd.multiout

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|my_gcd(10, 20)
33
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
4-
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
5-
|d.jl:4
4+
|nt16, UInt32, UInt64, UInt8} in Main at ****
65
| a = 10
76
| b = 20
87
| T = Int64
@@ -23,4 +22,4 @@
2322
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2423
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2524
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
26-
|
25+
|

test/ui/v1.3/gcdsc.multiout

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|__gcdval__ = my_gcd(10, 20);
33
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
4-
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
5-
|d.jl:4
4+
|nt16, UInt32, UInt64, UInt8} in Main at ****
65
| a = 10
76
| b = 20
87
| T = Int64
@@ -23,4 +22,4 @@
2322
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2423
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2524
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
26-
|
25+
|

test/ui/v1.5/gcd.multiout

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|my_gcd(10, 20)
33
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
4-
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
5-
|d.jl:4
4+
|nt16, UInt32, UInt64, UInt8} in Main at ****
65
| a = 10
76
| b = 20
87
| T = Int64
@@ -23,4 +22,4 @@
2322
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2423
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2524
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
26-
|
25+
|

test/ui/v1.5/gcdsc.multiout

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
++++++++++++++++++++++++++++++++++++++++++++++++++
22
|__gcdval__ = my_gcd(10, 20);
33
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
4-
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
5-
|d.jl:4
4+
|nt16, UInt32, UInt64, UInt8} in Main at ****
65
| a = 10
76
| b = 20
87
| T = Int64
@@ -23,4 +22,4 @@
2322
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2423
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2524
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
26-
|
25+
|

0 commit comments

Comments
 (0)