Skip to content

Commit 7b560c7

Browse files
committed
Add diff of AST dump to itest_parse test tool
1 parent 223902b commit 7b560c7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

test/test_utils.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,24 @@ function itest_parse(production, code; version::VersionNumber=v"1.6")
219219

220220
f_ex = JuliaSyntax.remove_linenums!(Meta.parse(code, raise=false))
221221
if JuliaSyntax.remove_linenums!(ex) != f_ex
222-
println(stdout, "\n\n# AST dump")
223-
dump(ex)
224-
225222
printstyled(stdout, "\n\n# flisp Julia Expr:\n", color=:red)
226223
show(stdout, MIME"text/plain"(), f_ex)
224+
225+
printstyled(stdout, "\n\n# Diff of AST dump:\n", color=:red)
226+
if Sys.isunix()
227+
mktemp() do path1, io1
228+
mktemp() do path2, io2
229+
dump(io1, ex); close(io1)
230+
dump(io2, f_ex); close(io2)
231+
run(ignorestatus(`diff -U10 --color=always $path1 $path2`))
232+
end
233+
end
234+
else
235+
dump(ex)
236+
println("------------------------------------")
237+
dump(f_ex)
238+
end
239+
return (ex, f_ex)
227240
# return (code, stream, t, s, ex)
228241
end
229242
nothing

0 commit comments

Comments
 (0)