From ccd26a6d42e07b7fcddf217312bb844cdeb9603c Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 13:25:09 +0200 Subject: [PATCH 1/5] drop FactCheck in tests --- test/imgcomp.jl | 4 +-- test/runtests.jl | 82 +++++++++++++++++++++++------------------------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index cd3b7058..1d4d3e05 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -15,7 +15,7 @@ end using Plots using StatPlots -using FactCheck +using Base.Test using Glob default(size=(500,300)) @@ -99,7 +99,7 @@ function image_comparison_facts(pkg::Symbol; for i in 1:length(Plots._examples) i in skip && continue if only == nothing || i in only - @fact @eval(image_comparison_tests(Symbol(String(Symbol($pkg))[7:end]), $i, debug=$debug, sigma=$sigma, eps=$eps)) |> success --> true + @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success == true end end end diff --git a/test/runtests.jl b/test/runtests.jl index 75f4302c..ba8666ec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,35 +7,35 @@ srand(1234) default(show=false, reuse=true) img_eps = isinteractive() ? 1e-2 : 10e-2 -facts("GR") do - @fact gr() --> Plots.GRBackend() - @fact backend() --> Plots.GRBackend() +@testset "GR" begin + @fact gr() == Plots.GRBackend() + @fact backend() == Plots.GRBackend() image_comparison_facts(:gr, eps=img_eps) end -facts("PyPlot") do - @fact pyplot() --> Plots.PyPlotBackend() - @fact backend() --> Plots.PyPlotBackend() +@testset "PyPlot" begin + @fact pyplot() == Plots.PyPlotBackend() + @fact backend() == Plots.PyPlotBackend() image_comparison_facts(:pyplot, eps=img_eps) end -facts("UnicodePlots") do - @fact unicodeplots() --> Plots.UnicodePlotsBackend() - @fact backend() --> Plots.UnicodePlotsBackend() +@testset "UnicodePlots" begin + @fact unicodeplots() == Plots.UnicodePlotsBackend() + @fact backend() == Plots.UnicodePlotsBackend() # lets just make sure it runs without error - @fact isa(plot(rand(10)), Plots.Plot) --> true + @fact isa(plot(rand(10)), Plots.Plot) == true end # The plotlyjs testimages return a connection error on travis: # connect: connection refused (ECONNREFUSED) -# facts("PlotlyJS") do -# @fact plotlyjs() --> Plots.PlotlyJSBackend() -# @fact backend() --> Plots.PlotlyJSBackend() +@testset "PlotlyJS" begin +# @fact plotlyjs() == Plots.PlotlyJSBackend() +# @fact backend() == Plots.PlotlyJSBackend() # # if is_linux() && isinteractive() # image_comparison_facts(:plotlyjs, @@ -53,9 +53,9 @@ end # ERROR: LoadError: InitError: Cannot open display: # in Gtk.GLib.GError(::Gtk.##229#230) at /home/travis/.julia/v0.5/Gtk/src/GLib/gerror.jl:17 -# facts("InspectDR") do -# @fact inspectdr() --> Plots.InspectDRBackend() -# @fact backend() --> Plots.InspectDRBackend() +# @testset "InspectDR" begin +# @fact inspectdr() == Plots.InspectDRBackend() +# @fact backend() == Plots.InspectDRBackend() # # image_comparison_facts(:inspectdr, # skip=[ @@ -72,41 +72,41 @@ end # end -# facts("Plotly") do -# @fact plotly() --> Plots.PlotlyBackend() -# @fact backend() --> Plots.PlotlyBackend() +# @testset "Plotly" begin +# @fact plotly() == Plots.PlotlyBackend() +# @fact backend() == Plots.PlotlyBackend() # # # # until png generation is reliable on OSX, just test on linux # # @static is_linux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) # end -# facts("Immerse") do -# @fact immerse() --> Plots.ImmerseBackend() -# @fact backend() --> Plots.ImmerseBackend() +# @testset "Immerse" begin +# @fact immerse() == Plots.ImmerseBackend() +# @fact backend() == Plots.ImmerseBackend() # # # as long as we can plot anything without error, it should be the same as Gadfly # image_comparison_facts(:immerse, only=[1], eps=img_eps) # end -# facts("PlotlyJS") do -# @fact plotlyjs() --> Plots.PlotlyJSBackend() -# @fact backend() --> Plots.PlotlyJSBackend() +# @testset "PlotlyJS" begin +# @fact plotlyjs() == Plots.PlotlyJSBackend() +# @fact backend() == Plots.PlotlyJSBackend() # # # as long as we can plot anything without error, it should be the same as Plotly # image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) # end -# facts("Gadfly") do -# @fact gadfly() --> Plots.GadflyBackend() -# @fact backend() --> Plots.GadflyBackend() +# @testset "Gadfly" begin +# @fact gadfly() == Plots.GadflyBackend() +# @fact backend() == Plots.GadflyBackend() # -# @fact typeof(plot(1:10)) --> Plots.Plot{Plots.GadflyBackend} -# @fact plot(Int[1,2,3], rand(3)) --> not(nothing) -# @fact plot(sort(rand(10)), rand(Int, 10, 3)) --> not(nothing) -# @fact plot!(rand(10,3), rand(10,3)) --> not(nothing) +# @fact typeof(plot(1:10)) == Plots.Plot{Plots.GadflyBackend} +# @fact plot(Int[1,2,3], rand(3)) == not(nothing) +# @fact plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) +# @fact plot!(rand(10,3), rand(10,3)) == not(nothing) # # image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) # end @@ -114,24 +114,24 @@ end -facts("Axes") do +@testset "Axes" begin p = plot() axis = p.subplots[1][:xaxis] - @fact typeof(axis) --> Plots.Axis - @fact Plots.discrete_value!(axis, "HI") --> (0.5, 1) - @fact Plots.discrete_value!(axis, :yo) --> (1.5, 2) - @fact Plots.ignorenan_extrema(axis) --> (0.5,1.5) - @fact axis[:discrete_map] --> Dict{Any,Any}(:yo => 2, "HI" => 1) + @fact typeof(axis) == Plots.Axis + @fact Plots.discrete_value!(axis, "HI") == (0.5, 1) + @fact Plots.discrete_value!(axis, :yo) == (1.5, 2) + @fact Plots.ignorenan_extrema(axis) == (0.5,1.5) + @fact axis[:discrete_map] == Dict{Any,Any}(:yo => 2, "HI" => 1) Plots.discrete_value!(axis, ["x$i" for i=1:5]) Plots.discrete_value!(axis, ["x$i" for i=0:2]) - @fact Plots.ignorenan_extrema(axis) --> (0.5, 7.5) + @fact Plots.ignorenan_extrema(axis) == (0.5, 7.5) end # tests for preprocessing recipes -# facts("recipes") do +# @testset "recipes" begin # user recipe @@ -168,6 +168,4 @@ end # end - -FactCheck.exitstatus() end # module From 371406845ca713d458aaff749ada1db15b18f8e2 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 13:43:58 +0200 Subject: [PATCH 2/5] drop Glob (enable testing on Windows) --- test/imgcomp.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 1d4d3e05..f600d94c 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -16,7 +16,6 @@ end using Plots using StatPlots using Base.Test -using Glob default(size=(500,300)) @@ -43,11 +42,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is fn = "ref$idx.png" # firgure out version info - G = glob(joinpath(relpath(refdir), "*")) - # @show refdir fn G - slash = (@static is_windows() ? "\\" : "/") - versions = map(fn -> VersionNumber(split(fn, slash)[end]), G) - versions = reverse(sort(versions)) + versions = sort(VersionNumber.(readdir(refdir)), rev = true) versions = filter(v -> v <= _current_plots_version, versions) # @show refdir fn versions From 7b15f7d74b1cc57941b437346a8f9bb4c000f713 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 16:08:45 +0200 Subject: [PATCH 3/5] fix round() deprecation in gr.jl --- src/backends/gr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 989a0751..8ab730f3 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -853,7 +853,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # create the colorbar of contour levels if sp[:colorbar] != :none gr_set_viewport_cmap(sp) - l = round(Int32, 1000 + (h - ignorenan_minimum(h)) / (ignorenan_maximum(h) - ignorenan_minimum(h)) * 255) + l = round.(Int32, 1000 + (h - ignorenan_minimum(h)) / (ignorenan_maximum(h) - ignorenan_minimum(h)) * 255) GR.setwindow(xmin, xmax, zmin, zmax) GR.cellarray(xmin, xmax, zmax, zmin, 1, length(l), l) ztick = 0.5 * GR.tick(zmin, zmax) From 82ecf894c0e1623215efe0f4864879aef2d96955 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 21:50:06 +0200 Subject: [PATCH 4/5] fix issues - replace at-fact with at-test --- test/runtests.jl | 60 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index ba8666ec..69b4d393 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,34 +8,34 @@ default(show=false, reuse=true) img_eps = isinteractive() ? 1e-2 : 10e-2 @testset "GR" begin - @fact gr() == Plots.GRBackend() - @fact backend() == Plots.GRBackend() + @test gr() == Plots.GRBackend() + @test backend() == Plots.GRBackend() image_comparison_facts(:gr, eps=img_eps) end @testset "PyPlot" begin - @fact pyplot() == Plots.PyPlotBackend() - @fact backend() == Plots.PyPlotBackend() + @test pyplot() == Plots.PyPlotBackend() + @test backend() == Plots.PyPlotBackend() image_comparison_facts(:pyplot, eps=img_eps) end @testset "UnicodePlots" begin - @fact unicodeplots() == Plots.UnicodePlotsBackend() - @fact backend() == Plots.UnicodePlotsBackend() + @test unicodeplots() == Plots.UnicodePlotsBackend() + @test backend() == Plots.UnicodePlotsBackend() # lets just make sure it runs without error - @fact isa(plot(rand(10)), Plots.Plot) == true + @test isa(plot(rand(10)), Plots.Plot) == true end # The plotlyjs testimages return a connection error on travis: # connect: connection refused (ECONNREFUSED) -@testset "PlotlyJS" begin -# @fact plotlyjs() == Plots.PlotlyJSBackend() -# @fact backend() == Plots.PlotlyJSBackend() +# @testset "PlotlyJS" begin +# @test plotlyjs() == Plots.PlotlyJSBackend() +# @test backend() == Plots.PlotlyJSBackend() # # if is_linux() && isinteractive() # image_comparison_facts(:plotlyjs, @@ -54,8 +54,8 @@ end # in Gtk.GLib.GError(::Gtk.##229#230) at /home/travis/.julia/v0.5/Gtk/src/GLib/gerror.jl:17 # @testset "InspectDR" begin -# @fact inspectdr() == Plots.InspectDRBackend() -# @fact backend() == Plots.InspectDRBackend() +# @test inspectdr() == Plots.InspectDRBackend() +# @test backend() == Plots.InspectDRBackend() # # image_comparison_facts(:inspectdr, # skip=[ @@ -73,8 +73,8 @@ end # @testset "Plotly" begin -# @fact plotly() == Plots.PlotlyBackend() -# @fact backend() == Plots.PlotlyBackend() +# @test plotly() == Plots.PlotlyBackend() +# @test backend() == Plots.PlotlyBackend() # # # # until png generation is reliable on OSX, just test on linux # # @static is_linux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) @@ -82,8 +82,8 @@ end # @testset "Immerse" begin -# @fact immerse() == Plots.ImmerseBackend() -# @fact backend() == Plots.ImmerseBackend() +# @test immerse() == Plots.ImmerseBackend() +# @test backend() == Plots.ImmerseBackend() # # # as long as we can plot anything without error, it should be the same as Gadfly # image_comparison_facts(:immerse, only=[1], eps=img_eps) @@ -91,8 +91,8 @@ end # @testset "PlotlyJS" begin -# @fact plotlyjs() == Plots.PlotlyJSBackend() -# @fact backend() == Plots.PlotlyJSBackend() +# @test plotlyjs() == Plots.PlotlyJSBackend() +# @test backend() == Plots.PlotlyJSBackend() # # # as long as we can plot anything without error, it should be the same as Plotly # image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) @@ -100,13 +100,13 @@ end # @testset "Gadfly" begin -# @fact gadfly() == Plots.GadflyBackend() -# @fact backend() == Plots.GadflyBackend() +# @test gadfly() == Plots.GadflyBackend() +# @test backend() == Plots.GadflyBackend() # -# @fact typeof(plot(1:10)) == Plots.Plot{Plots.GadflyBackend} -# @fact plot(Int[1,2,3], rand(3)) == not(nothing) -# @fact plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) -# @fact plot!(rand(10,3), rand(10,3)) == not(nothing) +# @test typeof(plot(1:10)) == Plots.Plot{Plots.GadflyBackend} +# @test plot(Int[1,2,3], rand(3)) == not(nothing) +# @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) +# @test plot!(rand(10,3), rand(10,3)) == not(nothing) # # image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) # end @@ -117,15 +117,15 @@ end @testset "Axes" begin p = plot() axis = p.subplots[1][:xaxis] - @fact typeof(axis) == Plots.Axis - @fact Plots.discrete_value!(axis, "HI") == (0.5, 1) - @fact Plots.discrete_value!(axis, :yo) == (1.5, 2) - @fact Plots.ignorenan_extrema(axis) == (0.5,1.5) - @fact axis[:discrete_map] == Dict{Any,Any}(:yo => 2, "HI" => 1) + @test typeof(axis) == Plots.Axis + @test Plots.discrete_value!(axis, "HI") == (0.5, 1) + @test Plots.discrete_value!(axis, :yo) == (1.5, 2) + @test Plots.ignorenan_extrema(axis) == (0.5,1.5) + @test axis[:discrete_map] == Dict{Any,Any}(:yo => 2, "HI" => 1) Plots.discrete_value!(axis, ["x$i" for i=1:5]) Plots.discrete_value!(axis, ["x$i" for i=0:2]) - @fact Plots.ignorenan_extrema(axis) == (0.5, 7.5) + @test Plots.ignorenan_extrema(axis) == (0.5, 7.5) end From da7e57989c2f3727cb16a213fea7a02b918a3aea Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 22:55:05 +0200 Subject: [PATCH 5/5] drop FactCheck and Glob in test/REQUIRE --- test/REQUIRE | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/REQUIRE b/test/REQUIRE index 57bc7828..e748b0c5 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,5 +1,4 @@ StatPlots -FactCheck Images ImageMagick @osx QuartzImageIO @@ -7,4 +6,3 @@ GR RDatasets VisualRegressionTests UnicodePlots -Glob