From 3a3d6c65eb2bdb43cb9af75bc470fe32d0447dd2 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Tue, 15 May 2018 13:54:33 +0200 Subject: [PATCH] Use Gadfly.open_file instead of run(open) in the test suite (fix #1143) --- src/Gadfly.jl | 13 +------------ src/open_file.jl | 12 ++++++++++++ test/compare_examples.jl | 8 +++++--- 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/open_file.jl diff --git a/src/Gadfly.jl b/src/Gadfly.jl index ac2a92339..86f930503 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -88,6 +88,7 @@ include("aesthetics.jl") include("mapping.jl") include("scale.jl") include("theme.jl") +include("open_file.jl") # The layer and plot functions can also take functions that are evaluated with @@ -1028,18 +1029,6 @@ function display(d::REPLDisplay, p::Union{Plot,Compose.Context}) throw(MethodError) end -function open_file(filename) - if is_apple() - run(`open $(filename)`) - elseif is_linux() || is_bsd() - run(`xdg-open $(filename)`) - elseif is_windows() - run(`$(ENV["COMSPEC"]) /c start $(filename)`) - else - warn("Showing plots is not supported on OS $(string(Compat.KERNEL))") - end -end - # Fallback display method. When there isn't a better option, we write to a # temporary file and try to open it. function display(d::REPLDisplay, ::MIME"image/png", p::Union{Plot,Compose.Context}) diff --git a/src/open_file.jl b/src/open_file.jl new file mode 100644 index 000000000..a20fe1ed9 --- /dev/null +++ b/src/open_file.jl @@ -0,0 +1,12 @@ +function open_file(filename) + if is_apple() + run(`open $(filename)`) + elseif is_linux() || is_bsd() + run(`xdg-open $(filename)`) + elseif is_windows() + run(`$(ENV["COMSPEC"]) /c start $(filename)`) + else + warn("Showing plots is not supported on OS $(string(Compat.KERNEL))") + end +end + diff --git a/test/compare_examples.jl b/test/compare_examples.jl index 06dcdd5b9..9c5ebaf77 100644 --- a/test/compare_examples.jl +++ b/test/compare_examples.jl @@ -1,3 +1,5 @@ +include(joinpath(@__DIR__,"..","src","open_file.jl")) + using ArgParse s = ArgParseSettings() @@ -94,8 +96,8 @@ for file in intersect(cached_files,genned_files) run(ignorestatus(diffcmd)) end if args["two"] - run(`open $(joinpath(cachedout,file))`) - run(`open $(joinpath(gennedout,file))`) + open_file("$(joinpath(cachedout,file))") + open_file("$(joinpath(gennedout,file))") end if args["bw"] && (endswith(file,".svg") || endswith(file,".png")) wait_for_user = false @@ -112,7 +114,7 @@ for file in intersect(cached_files,genned_files) fout = joinpath(diffedout,file*".png") Images.save(fout, dimg) wait_for_user = true - run(`open $fout`) + open_file("$fout") else println("files are different but PNGs are the same") end