From 7dc6ea355c352b53282315481b98777ecbfa1694 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 15 Sep 2019 21:29:08 +0200 Subject: [PATCH 01/10] update Plots tests for GR --- .travis.yml | 24 ++++++++++++++++- Project.toml | 6 ++--- src/Plots.jl | 2 +- src/examples.jl | 10 +++---- test/imgcomp.jl | 68 +++------------------------------------------- test/runtests.jl | 70 +++++++++++++++++++++++++++++++++--------------- 6 files changed, 84 insertions(+), 96 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc303b0f..9b0ad9bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ os: julia: - 1.1 - nightly - + matrix: allow_failures: - julia: nightly @@ -16,5 +16,27 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pwd ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./test/install_wkhtmltoimage.sh ; fi +addons: + apt: + packages: + - qt5-default + # pgfplots + - pdf2svg + - texlive-latex-base + - texlive-binaries + - texlive-pictures + - texlive-latex-extra + - texlive-luatex + - ghostscript-x + # orca + - libgconf2-4 + +env: + - PYTHON = "" MPLBACKEND = "agg" + notifications: email: true + +script: + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + - xvfb-run julia -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' diff --git a/Project.toml b/Project.toml index 3eb2c8c0..80d71153 100644 --- a/Project.toml +++ b/Project.toml @@ -41,17 +41,17 @@ julia = "≥ 1.0.0" [extras] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" -BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" [targets] -test = ["BinaryProvider", "Pkg", "Test", "Random", "StatsPlots", "VisualRegressionTests", "LaTeXStrings", "Images", "ImageMagick", "RDatasets", "FileIO", "UnicodePlots"] +test = ["FileIO", "Gtk", "ImageMagick", "Images", "LaTeXStrings", "LibGit2", "Random", "RDatasets", "StatsPlots", "Test", "UnicodePlots", "VisualRegressionTests"] diff --git a/src/Plots.jl b/src/Plots.jl index 54d34615..731acd49 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -1,6 +1,6 @@ module Plots -_current_plots_version = v"0.26.1" +const _current_plots_version = VersionNumber(split(first(filter(line -> occursin("version", line), readlines(normpath(@__DIR__, "..", "Project.toml")))), "\"")[2]) using Reexport diff --git a/src/examples.jl b/src/examples.jl index d55d3b4c..808520e1 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -238,12 +238,12 @@ build with the method `text(string, attr...)`, which wraps font and color attrib """, [:(begin y = rand(10) -plot(y, annotations = (3,y[3],text("this is #3",:left)), leg=false) -annotate!([(5, y[5], text("this is #5",16,:red,:center)), - (10, y[10], text("this is #10",:right,20,"courier"))]) +plot(y, annotations = (3,y[3], Plots.text("this is #3",:left)), leg=false) +annotate!([(5, y[5], Plots.text("this is #5",16,:red,:center)), + (10, y[10], Plots.text("this is #10",:right,20,"courier"))]) scatter!(range(2, stop=8, length=6), rand(6), marker=(50,0.2,:orange), series_annotations = ["series","annotations","map","to","series", - text("data",:green)]) + Plots.text("data",:green)]) end)] ), @@ -461,7 +461,7 @@ _animation_examples = [2, 30] _backend_skips = Dict( :gr => [25, 30], :pyplot => [25, 30], - :plotlyjs => [2, 21, 25, 30, 31], + :plotlyjs => [2, 21, 24, 25, 30, 31], :pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30], ) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 1aa4ceee..e7151573 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -1,34 +1,6 @@ import Plots._current_plots_version -# Taken from MakieGallery -""" -Downloads the reference images from ReferenceImages for a specific version -""" -function download_reference(version = v"0.0.1") - download_dir = abspath(@__DIR__, "reference_images") - isdir(download_dir) || mkpath(download_dir) - tarfile = joinpath(download_dir, "reference_images.zip") - url = "https://github.com/JuliaPlots/PlotReferenceImages.jl/archive/v$(version).tar.gz" - refpath = joinpath(download_dir, "PlotReferenceImages.jl-$(version)") - if !isdir(refpath) # if not yet downloaded - @info "downloading reference images for version $version" - download(url, tarfile) - BinaryProvider.unpack(tarfile, download_dir) - # check again after download - if !isdir(refpath) - error("Something went wrong while downloading reference images. Plots can't be compared to references") - else - rm(tarfile, force = true) - end - else - @info "using reference images for version $version (already downloaded)" - end - refpath -end - -const ref_image_dir = download_reference() - -function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2) +function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = !is_ci(), sigma = [1,1], tol = 1e-2) Plots._debugMode.on = debug example = Plots._examples[idx] Plots.theme(:default) @@ -39,36 +11,9 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # ensure consistent results Random.seed!(1234) - # reference image directory setup - refdir = joinpath(ref_image_dir, "Plots", string(pkg)) fn = "ref$idx.png" - - # firgure out version info - vns = filter(x->x[1] != '.', readdir(refdir)) - versions = sort(VersionNumber.(vns), rev = true) - versions = filter(v -> v <= _current_plots_version, versions) - # @show refdir fn versions - - newdir = joinpath(refdir, string(_current_plots_version)) - newfn = joinpath(newdir, fn) - - # figure out which reference file we should compare to, by finding the highest versioned file - reffn = nothing - for v in versions - tmpfn = joinpath(refdir, string(v), fn) - if isfile(tmpfn) - reffn = tmpfn - break - end - end - - # now we have the fn (if any)... do the comparison - # @show reffn - if reffn === nothing - reffn = newfn - end - # @show reffn - # return + reffn = reference_file(pkg, idx, _current_plots_version) + newfn = joinpath(reference_path(pkg, _current_plots_version), fn) # test function func = (fn, idx) -> begin @@ -78,13 +23,6 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is png(fn) end - # try - # run(`mkdir -p $newdir`) - # catch err - # display(err) - # end - # # reffn = joinpath(refdir, "ref$idx.png") - # the test vtest = VisualTest(func, reffn, idx) test_images(vtest, popup=popup, sigma=sigma, tol=tol, newfn = newfn) diff --git a/test/runtests.jl b/test/runtests.jl index b0515c58..97ad4e9a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,40 +1,68 @@ using VisualRegressionTests using Plots using Random -using BinaryProvider using Test using FileIO -using GeometryTypes +using Gtk + +reference_dir(args...) = joinpath(homedir(), ".julia", "dev", "PlotReferenceImages", args...) + +function reference_file(backend, i, version) + refdir = reference_dir("Plots", string(backend)) + fn = "ref$i.png" + versions = sort(VersionNumber.(readdir(refdir)), rev = true) + + reffn = joinpath(refdir, string(version), fn) + for v in versions + tmpfn = joinpath(refdir, string(v), fn) + if isfile(tmpfn) + reffn = tmpfn + break + end + end + + return reffn +end + +reference_path(backend, version) = reference_dir("Plots", string(backend), string(version)) + +if !isdir(reference_dir()) + LibGit2.clone("https://github.com/JuliaPlots/PlotReferenceImages.jl.git", reference_dir()) +end include("imgcomp.jl") # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) -img_tol = isinteractive() ? 1e-2 : 10e-2 +is_ci() = get(ENV, "CI", false) +img_tol = is_ci() ? 10e-2 : 10e-2 -@testset "GR" begin - ENV["PLOTS_TEST"] = "true" - ENV["GKSwstype"] = "100" - @test gr() == Plots.GRBackend() - @test backend() == Plots.GRBackend() +@testset "Backends" begin - @static if Sys.islinux() - image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) + @testset "GR" begin + ENV["PLOTS_TEST"] = "true" + ENV["GKSwstype"] = "100" + @test gr() == Plots.GRBackend() + @test backend() == Plots.GRBackend() + + @static if Sys.islinux() + image_comparison_facts(:gr, tol=img_tol, skip = Plots._backend_skips[:gr]) + end end -end + @testset "UnicodePlots" begin + @test unicodeplots() == Plots.UnicodePlotsBackend() + @test backend() == Plots.UnicodePlotsBackend() -@testset "UnicodePlots" begin - @test unicodeplots() == Plots.UnicodePlotsBackend() - @test backend() == Plots.UnicodePlotsBackend() + # lets just make sure it runs without error + p = plot(rand(10)) + @test isa(p, Plots.Plot) == true + @test isa(display(p), Nothing) == true + p = bar(randn(10)) + @test isa(p, Plots.Plot) == true + @test isa(display(p), Nothing) == true + end - # lets just make sure it runs without error - p = plot(rand(10)) - @test isa(p, Plots.Plot) == true - @test isa(display(p), Nothing) == true - p = bar(randn(10)) - @test isa(p, Plots.Plot) == true - @test isa(display(p), Nothing) == true end @testset "Axes" begin From eba6e2909289111bdcc00dfd808f7063b25a5de8 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 15 Sep 2019 21:32:44 +0200 Subject: [PATCH 02/10] use default travis script --- .travis.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b0ad9bc..0bdcb930 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,27 +16,5 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pwd ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./test/install_wkhtmltoimage.sh ; fi -addons: - apt: - packages: - - qt5-default - # pgfplots - - pdf2svg - - texlive-latex-base - - texlive-binaries - - texlive-pictures - - texlive-latex-extra - - texlive-luatex - - ghostscript-x - # orca - - libgconf2-4 - -env: - - PYTHON = "" MPLBACKEND = "agg" - notifications: email: true - -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - xvfb-run julia -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' From 5ad4c517e192b0c8a0c8cec31c4819853ec21615 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 15 Sep 2019 22:48:54 +0200 Subject: [PATCH 03/10] update travis for gtk --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0bdcb930..6a1751b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,12 @@ julia: - 1.1 - nightly -matrix: - allow_failures: - - julia: nightly +addons: + apt: + packages: + - xvfb + - xauth + - libgtk-3-dev sudo: required before_install: @@ -18,3 +21,8 @@ before_install: notifications: email: true + +script: + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + - if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi + - $TESTCMD -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' From 57286ea40d11882787ed3acc5d31f63e720837e2 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 15 Sep 2019 22:57:39 +0200 Subject: [PATCH 04/10] using LibGit2 --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index 97ad4e9a..26ccecfa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,7 @@ using Random using Test using FileIO using Gtk +using LibGit2 reference_dir(args...) = joinpath(homedir(), ".julia", "dev", "PlotReferenceImages", args...) From d7cc15d39121b84b7e9fb03ed20dc02b09d852d7 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Mon, 16 Sep 2019 10:50:11 +0200 Subject: [PATCH 05/10] add another travis dependency --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a1751b1..10d4eadd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,10 @@ julia: addons: apt: packages: - - xvfb - - xauth + - at-spi2-core - libgtk-3-dev + - xauth + - xvfb sudo: required before_install: From 1650049b88a9b82df86c97e35347339b1e778449 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Mon, 16 Sep 2019 11:08:16 +0200 Subject: [PATCH 06/10] fix checking for ci --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 26ccecfa..b0e9a8ef 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -35,7 +35,7 @@ include("imgcomp.jl") # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) -is_ci() = get(ENV, "CI", false) +is_ci() = get(ENV, "CI", "false") == "true" img_tol = is_ci() ? 10e-2 : 10e-2 @testset "Backends" begin From 9775abecc206433fcb182f02a3765cc69ba1d481 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Mon, 16 Sep 2019 11:24:16 +0200 Subject: [PATCH 07/10] import ImageMagick --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index b0e9a8ef..7e40db40 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,3 +1,4 @@ +import ImageMagick using VisualRegressionTests using Plots using Random From 1e0fcbc65ee376b42bfc96708ca74d9fd1f69627 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 17 Sep 2019 14:06:15 +0200 Subject: [PATCH 08/10] use GeometryTypes in Tests --- Project.toml | 3 ++- test/runtests.jl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 80d71153..2ac80ca7 100644 --- a/Project.toml +++ b/Project.toml @@ -41,6 +41,7 @@ julia = "≥ 1.0.0" [extras] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb" Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" @@ -54,4 +55,4 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] -test = ["FileIO", "Gtk", "ImageMagick", "Images", "LaTeXStrings", "LibGit2", "Random", "RDatasets", "StatsPlots", "Test", "UnicodePlots", "VisualRegressionTests"] +test = ["FileIO", "GeometryTypes", "Gtk", "ImageMagick", "Images", "LaTeXStrings", "LibGit2", "Random", "RDatasets", "StatsPlots", "Test", "UnicodePlots", "VisualRegressionTests"] diff --git a/test/runtests.jl b/test/runtests.jl index 7e40db40..71877e34 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,7 @@ using Test using FileIO using Gtk using LibGit2 +using GeometryTypes reference_dir(args...) = joinpath(homedir(), ".julia", "dev", "PlotReferenceImages", args...) From f7e19bcf6368df653daafd74cfbf22c06ae84eaa Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 17 Sep 2019 15:40:00 +0200 Subject: [PATCH 09/10] fix Point ambiguity --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 71877e34..6cdc6d60 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -128,6 +128,6 @@ end [(missing,missing)], [(missing,missing,missing),("a","b","c")]) for z in zipped @test isequal(collect(zip(Plots.unzip(z)...)), z) - @test isequal(collect(zip(Plots.unzip(Point.(z))...)), z) + @test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z) end end From ba8110dc20edbc1ef65b18abad05180470220f70 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 18 Sep 2019 18:38:01 +0200 Subject: [PATCH 10/10] create PlotReferenceImages dev path for appveyor --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index 6cdc6d60..24feab44 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,6 +30,7 @@ end reference_path(backend, version) = reference_dir("Plots", string(backend), string(version)) if !isdir(reference_dir()) + mkpath(reference_dir()) LibGit2.clone("https://github.com/JuliaPlots/PlotReferenceImages.jl.git", reference_dir()) end