Skip to content

Commit 74cd8b5

Browse files
pfitzsebtimholy
authored andcommitted
Better diff printing (#5)
Uses DeepDiffs package
1 parent be94e5f commit 74cd8b5

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ author = ["Keno Fischer <[email protected]>"]
44
version = "0.1.3"
55

66
[deps]
7+
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
78
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
89
VT100 = "7774df62-37c0-5c21-b34d-f6d7f98f54bc"
910

src/TerminalRegressionTests.jl

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module TerminalRegressionTests
22
using VT100
3+
using DeepDiffs
34
import REPL
45

56
function load_outputs(file)
@@ -98,25 +99,19 @@ module TerminalRegressionTests
9899
REPL.Terminals.pipe_writer(t::EmulatedTerminal) = t.out_stream
99100

100101
function _compare(output, outbuf)
101-
result = outbuf == output
102+
outstring = String(output)
103+
bufstring = String(outbuf)
104+
result = outstring == bufstring
102105
if !result
103106
println("Test failed. Expected result written to expected.out,
104107
actual result written to failed.out")
105108
open("failed.out","w") do f
106-
write(f,outbuf)
109+
write(f,bufstring)
107110
end
108111
open("expected.out","w") do f
109-
write(f,output)
110-
end
111-
for (i,c) in enumerate(output)
112-
if c == Char(outbuf[i])
113-
print(Char(c))
114-
elseif c == '\n'
115-
println()
116-
else
117-
printstyled(stdout, "", color=:red)
118-
end
112+
write(f,outstring)
119113
end
114+
println(stdout, deepdiff(outstring, bufstring))
120115
error()
121116
end
122117
return result

0 commit comments

Comments
 (0)