Skip to content

Commit

Permalink
Use path replacement for the UI tests (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Jan 18, 2020
1 parent 2322c76 commit 515d93c
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 21 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1
- julia_version: 1.1
- julia_version: nightly

platform:
Expand Down
62 changes: 58 additions & 4 deletions test/interpret_ui.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,70 @@
# This was copied from Debugger.jl and then modified

using TerminalRegressionTests, Rebugger, Revise
using TerminalRegressionTests, Rebugger, Revise, CodeTracking
using HeaderREPLs, REPL
using Test

includet("my_gcd.jl")

function run_terminal_test(cmd, validation, commands)
function compare_replace(em, target; replace=nothing)
# Compare two buffer, skipping over the equivalent of key=>rep replacement
# However, because of potential differences in wrapping we don't explicitly
# perform the replacement; instead, we make the comparison tolerant of difference
# `\n`.
buf = IOBuffer()
decoratorbuf = IOBuffer()
TerminalRegressionTests.VT100.dump(buf, decoratorbuf, em)
outbuf = take!(buf)
success = true
if replace !== nothing
output = String(outbuf)
key, rep = replace
idxkey = findfirst(key, target)
iout, itgt = firstindex(output), firstindex(target)
outlast, tgtlast = lastindex(output), lastindex(target)
lrep = length(rep)
while success && iout <= outlast && itgt <= tgtlast
if itgt == first(idxkey)
itgt += length(key)
for c in rep
cout = output[iout]
while c != cout && cout == '\n'
iout = nextind(output, iout)
cout = output[iout]
end
if c != cout
success = false
break
end
iout = nextind(output, iout)
end
else
cout, ctgt = output[iout], target[itgt]
success = cout == ctgt
iout, itgt = nextind(output, iout), nextind(target, itgt)
end
end
success && iout > outlast && itgt > tgtlast && return true
end
outbuf == codeunits(target) && return true
open("failed.out","w") do f
write(f, output)
end
open("expected.out","w") do f
write(f, target)
end
error("Test failed. Expected result written to expected.out,
actual result written to failed.out")
end

dirpath = joinpath(@__DIR__, "ui", "v$(VERSION.major).$(VERSION.minor)")
isdir(dirpath) || mkpath(dirpath)
filepath = joinpath(dirpath, validation)
TerminalRegressionTests.automated_test(filepath, commands) do emuterm
# Fix the path of gcd to match the current running version of Julia
gcdfile, gcdline = whereis(@which my_gcd(10, 20))
cmp(a, b, decorator) = compare_replace(a, b; replace="****" => gcdfile*':'*string(gcdline))
TerminalRegressionTests.automated_test(cmp, filepath, commands) do emuterm
# TerminalRegressionTests.create_automated_test(filepath, commands) do emuterm
main_repl = REPL.LineEditREPL(emuterm, true)
main_repl.interface = REPL.setup_interface(main_repl)
Expand All @@ -25,8 +81,6 @@ function run_terminal_test(cmd, validation, commands)
end
end

includet("my_gcd.jl")

CTRL_C = "\x3"
EOT = "\x4"
UP_ARROW = "\e[A"
Expand Down
4 changes: 2 additions & 2 deletions test/ui/v1.2/gcd.multiout
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|gcd(10, 20)
|gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt1
|6, UInt32, UInt64, UInt8} in Base at /home/tim/src/julia-1/base/intfuncs.jl:31
|6, UInt32, UInt64, UInt8} in Base at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -12,8 +12,8 @@
|
--------------------------------------------------
|AAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAA
|AAAAAAAA
|AAAAAAAAAAA
Expand Down
4 changes: 2 additions & 2 deletions test/ui/v1.2/gcdsc.multiout
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|__gcdval__ = gcd(10, 20);
|gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt1
|6, UInt32, UInt64, UInt8} in Base at /home/tim/src/julia-1/base/intfuncs.jl:31
|6, UInt32, UInt64, UInt8} in Base at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -12,8 +12,8 @@
|
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAA
|AAAAAAAA
|AAAAAAAAAAA
Expand Down
5 changes: 2 additions & 3 deletions test/ui/v1.3/gcd.multiout
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|my_gcd(10, 20)
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
|d.jl:4
|nt16, UInt32, UInt64, UInt8} in Main at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -23,4 +22,4 @@
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
5 changes: 2 additions & 3 deletions test/ui/v1.3/gcdsc.multiout
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|__gcdval__ = my_gcd(10, 20);
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
|d.jl:4
|nt16, UInt32, UInt64, UInt8} in Main at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -23,4 +22,4 @@
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
5 changes: 2 additions & 3 deletions test/ui/v1.5/gcd.multiout
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|my_gcd(10, 20)
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
|d.jl:4
|nt16, UInt32, UInt64, UInt8} in Main at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -23,4 +22,4 @@
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
5 changes: 2 additions & 3 deletions test/ui/v1.5/gcdsc.multiout
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|__gcdval__ = my_gcd(10, 20);
|my_gcd(a::T, b::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UI
|nt16, UInt32, UInt64, UInt8} in Main at /home/tim/.julia/dev/Rebugger/test/my_gc
|d.jl:4
|nt16, UInt32, UInt64, UInt8} in Main at ****
| a = 10
| b = 20
| T = Int64
Expand All @@ -23,4 +22,4 @@
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|

2 comments on commit 515d93c

@timholy
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8125

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.3 -m "<description of version>" 515d93c4484e7df677212a74643137ee1b013232
git push origin v0.3.3

Please sign in to comment.