1
1
# This was copied from Debugger.jl and then modified
2
2
3
- using TerminalRegressionTests, Rebugger, Revise
3
+ using TerminalRegressionTests, Rebugger, Revise, CodeTracking
4
4
using HeaderREPLs, REPL
5
5
using Test
6
6
7
+ includet (" my_gcd.jl" )
8
+
7
9
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
+
8
61
dirpath = joinpath (@__DIR__ , " ui" , " v$(VERSION . major) .$(VERSION . minor) " )
9
62
isdir (dirpath) || mkpath (dirpath)
10
63
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
12
68
# TerminalRegressionTests.create_automated_test(filepath, commands) do emuterm
13
69
main_repl = REPL. LineEditREPL (emuterm, true )
14
70
main_repl. interface = REPL. setup_interface (main_repl)
@@ -25,8 +81,6 @@ function run_terminal_test(cmd, validation, commands)
25
81
end
26
82
end
27
83
28
- includet (" my_gcd.jl" )
29
-
30
84
CTRL_C = " \x 3"
31
85
EOT = " \x 4"
32
86
UP_ARROW = " \e [A"
0 commit comments