Skip to content

Commit

Permalink
during regression testing only show b&w images that have some differe…
Browse files Browse the repository at this point in the history
…nces
  • Loading branch information
bjarthur committed Mar 26, 2018
1 parent a111e38 commit 19ccdbe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
5 changes: 4 additions & 1 deletion docs/src/dev/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ So the automated regression analysis workflow is then as follows:
5. checkout master,
6. `Pkg.test` again,
7. `Pkg.add("ArgParse")` and, for B&W images, Cairo, Fontconfig, Rsvg, and Images as well,
8. check for differences with `julia test/compare_examples.jl [--diff] [--two] [--bw] [-h] [filter]`
8. check for differences with `julia test/compare_examples.jl [--diff] [--two]
[--bw] [-h] [filter]`. For example, `julia test/compare_examples.jl -bw
.js.svg` will show black and white images hightlighting the differences between
the svg test images.
45 changes: 28 additions & 17 deletions test/compare_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,35 @@ for file in intersect(cached_files,genned_files)
diffcmd = `diff $(joinpath(cachedout, file)) $(joinpath(gennedout, file))`
run(ignorestatus(diffcmd))
end
args["two"] && run(`open $(joinpath(cachedout,file))`)
args["two"] && run(`open $(joinpath(gennedout,file))`)
if args["bw"]
if endswith(file,".svg")
gimg = svg2img(joinpath(gennedout,file));
cimg = svg2img(joinpath(cachedout,file));
elseif endswith(file,".png")
gimg = load(joinpath(gennedout,file));
cimg = load(joinpath(cachedout,file));
end
if endswith(file,".svg") || endswith(file,".png")
dimg = convert(Matrix{Gray}, gimg.==cimg)
fout = joinpath(diffedout,file*".png")
Images.save(fout, dimg)
args["bw"] && run(`open $fout`)
end
if args["two"]
run(`open $(joinpath(cachedout,file))`)
run(`open $(joinpath(gennedout,file))`)
end
args["diff"] || args["two"] || args["bw"] || continue
if args["bw"] && (endswith(file,".svg") || endswith(file,".png"))
wait_for_user = false
if endswith(file,".svg")
gimg = svg2img(joinpath(gennedout,file));
cimg = svg2img(joinpath(cachedout,file));
elseif endswith(file,".png")
gimg = load(joinpath(gennedout,file));
cimg = load(joinpath(cachedout,file));
end
if size(gimg)==size(cimg)
dimg = convert(Matrix{Gray}, gimg.==cimg)
if any(dimg.==0)
fout = joinpath(diffedout,file*".png")
Images.save(fout, dimg)
wait_for_user = true
run(`open $fout`)
else
println("files are different but PNGs are the same")
end
else
wait_for_user = true
println("PNGs are different sizes :(")
end
end
args["diff"] || args["two"] || (args["bw"] && wait_for_user) || continue
println("Press ENTER to continue, CTRL-C to quit")
readline()
end
Expand Down

0 comments on commit 19ccdbe

Please sign in to comment.