Skip to content

Commit c48113f

Browse files
committed
improve test debug printing
1 parent 448761b commit c48113f

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

test/check_base.jl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ function cst_parse_file(str)
9999
x0, CSTParser.has_error(ps), isempty(sp)
100100
end
101101

102+
_compare(x, y) = x == y
103+
104+
function _compare(x::Expr, y::Expr)
105+
if x == y
106+
return true
107+
else
108+
if x.head != y.head || length(x.args) != length(y.args)
109+
printstyled(x, bold = true, color = :light_red)
110+
println()
111+
printstyled(y, bold=true, color=:light_green)
112+
println()
113+
end
114+
for i = 1:min(length(x.args), length(y.args))
115+
if !_compare(x.args[i], y.args[i])
116+
printstyled(x.args[i], bold = true, color = :light_red)
117+
println()
118+
printstyled(y.args[i], bold=true, color=:light_green)
119+
println()
120+
end
121+
end
122+
return false
123+
end
124+
end
125+
102126
@testset "Parsing files in Base" begin
103127
dir = joinpath(Sys.BINDIR, Base.DATAROOTDIR)
104128
for (root, _, files) in walkdir(dir; follow_symlinks=true)
@@ -126,11 +150,7 @@ end
126150
@test true
127151
else
128152
@error "parsing difference" file=file
129-
c0, c1 = CSTParser.compare(cst_expr, meta_expr)
130-
printstyled(c0, bold = true, color = :light_red)
131-
println()
132-
printstyled(c1, bold=true, color=:light_green)
133-
println()
153+
_compare(cst_expr, meta_expr)
134154
@test false
135155
end
136156
end

test/errparse.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
end
5555
if sizeof(s) != x.fullspan
5656
@info "sizeof(s) != x.fullspan for :"
57-
@info s
57+
println(">>>>>>>>>>>>>>>>>>")
58+
println(s)
59+
println("<<<<<<<<<<<<<<<<<<")
5860
end
5961
check_itr_order(s, x)
6062
end
@@ -84,7 +86,9 @@
8486
end
8587
else
8688
@info "check_itr_order failed: "
87-
@info s
89+
println(">>>>>>>>>>>>>>>>>>")
90+
println(s)
91+
println("<<<<<<<<<<<<<<<<<<")
8892
error()
8993
end
9094
end

0 commit comments

Comments
 (0)