Skip to content

Commit

Permalink
Use Gadfly.open_file instead of run(open) in the test suite (fix Giov…
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses4ever authored and bjarthur committed May 23, 2018
1 parent 0d9e54b commit badd63d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
13 changes: 1 addition & 12 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ include("aesthetics.jl")
include("mapping.jl")
include("scale.jl")
include("theme.jl")
include("open_file.jl")


### rename to ElementOrFunctionOrTheme ?
Expand Down Expand Up @@ -982,18 +983,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})
Expand Down
12 changes: 12 additions & 0 deletions src/open_file.jl
Original file line number Diff line number Diff line change
@@ -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

8 changes: 5 additions & 3 deletions test/compare_examples.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(joinpath(@__DIR__,"..","src","open_file.jl"))

using ArgParse

s = ArgParseSettings()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit badd63d

Please sign in to comment.