diff --git a/docs/src/dev/regression.md b/docs/src/dev/regression.md index 277a8b787..79a6aa9b2 100644 --- a/docs/src/dev/regression.md +++ b/docs/src/dev/regression.md @@ -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. diff --git a/test/compare_examples.jl b/test/compare_examples.jl index 902b50d8b..73cd468ff 100644 --- a/test/compare_examples.jl +++ b/test/compare_examples.jl @@ -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