Skip to content

Commit

Permalink
Merge pull request #1146 from ulysses4ever/fix-regr-test-related
Browse files Browse the repository at this point in the history
Use Gadfly.open_file instead of run(open) in the test suite (fix #1143)
  • Loading branch information
bjarthur authored May 16, 2018
2 parents 418fe2a + 3a3d6c6 commit d31554b
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 @@ -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
Expand Down Expand Up @@ -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})
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 d31554b

Please sign in to comment.