diff --git a/Project.toml b/Project.toml index 2581cbc9..ba300180 100644 --- a/Project.toml +++ b/Project.toml @@ -40,17 +40,18 @@ 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" +PlotReferenceImages = "c5e800db-1e6b-5f72-915a-308d267b7a19" 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 = ["Pkg", "Test", "Random", "StatsPlots", "VisualRegressionTests", "LaTeXStrings", "Images", "ImageMagick", "RDatasets", "FileIO", "Gtk", "UnicodePlots", "PlotReferenceImages"] diff --git a/src/examples.jl b/src/examples.jl index 6dd1b7f4..14fb710e 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)] ), diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 206b8d50..22c617d5 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 e2f7b9c5..2f12d588 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,15 +1,18 @@ using VisualRegressionTests using Plots using Random -using BinaryProvider using Test using FileIO +using PlotReferenceImages +using Gtk + 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 : 1e-2 @testset "GR" begin ENV["PLOTS_TEST"] = "true"