From a3be970f29f42e4b714caef6e4009fbde573a274 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 9 May 2019 11:48:40 +0200 Subject: [PATCH] get around registered PLotReferenceImages by downloading source of tags --- Project.toml => .Project.toml | 0 REQUIRE | 16 +++++++++++ test/.gitignore | 1 + test/REQUIRE | 11 ++++++++ test/imgcomp.jl | 51 ++++++++++++++++++++--------------- test/runtests.jl | 3 --- 6 files changed, 57 insertions(+), 25 deletions(-) rename Project.toml => .Project.toml (100%) create mode 100644 REQUIRE create mode 100644 test/.gitignore create mode 100644 test/REQUIRE diff --git a/Project.toml b/.Project.toml similarity index 100% rename from Project.toml rename to .Project.toml diff --git a/REQUIRE b/REQUIRE new file mode 100644 index 00000000..bd236535 --- /dev/null +++ b/REQUIRE @@ -0,0 +1,16 @@ +julia 1.0 + +RecipesBase 0.6.0 +PlotUtils 0.4.1 +PlotThemes 0.1.3 +Reexport +GeometryTypes +FixedPointNumbers 0.3 +Measures +Showoff +StatsBase 0.14.0 +JSON +NaNMath +Requires +Contour +GR 0.39.0 diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 00000000..2a6ccb02 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +reference_images diff --git a/test/REQUIRE b/test/REQUIRE new file mode 100644 index 00000000..f357d290 --- /dev/null +++ b/test/REQUIRE @@ -0,0 +1,11 @@ +FileIO +ImageMagick +Images +LaTeXStrings +RDatasets +Random +StatsPlots +Test +UnicodePlots +VisualRegressionTests +BinaryProvider diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 6d7dd457..c8ae9966 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -1,26 +1,7 @@ - using VisualRegressionTests -# using ExamplePlots - -if isinteractive() - @eval Main import Gtk -end - -# import DataFrames, RDatasets - -# don't let pyplot use a gui... it'll crash -# note: Agg will set gui -> :none in PyPlot -# ENV["MPLBACKEND"] = "Agg" -# try -# @eval import PyPlot -# @info("Matplotlib version: $(PyPlot.matplotlib[:__version__])") -# end - - using Plots -# using StatsPlots -import PlotReferenceImages using Random +using BinaryProvider using Test default(size=(500,300)) @@ -31,6 +12,33 @@ default(size=(500,300)) 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) Plots._debugMode.on = debug @@ -43,8 +51,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is Random.seed!(1234) # reference image directory setup - # refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg)) - refdir = joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots", string(pkg)) + refdir = joinpath(ref_image_dir, "Plots", string(pkg)) fn = "ref$idx.png" # firgure out version info diff --git a/test/runtests.jl b/test/runtests.jl index 924aa2ea..167eb6a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,9 +2,6 @@ module PlotsTests using Pkg -# This should be fine since it's run in it's own test env? -pkg"add https://github.com/JuliaPlots/PlotReferenceImages.jl.git" - include("imgcomp.jl")