From 7ce21ff472dc8931b010058d6b22460459df2bc0 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 18 Jan 2024 18:10:45 +0100 Subject: [PATCH] wait killing the process (#14) * wait for the kill * test windows * use old version because of windows * didn't help * bump version number --- .github/workflows/tests.yml | 3 ++- Project.toml | 3 ++- src/PlotlyKaleido.jl | 14 +++++++------- test/runtests.jl | 12 +++++++++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed10489..5e5c495 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,10 +12,11 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: julia-version: ['1.6', '1'] julia-arch: [x64] - os: [ubuntu-latest, macOS-latest] + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v2 diff --git a/Project.toml b/Project.toml index 1a7a4ee..3dd332d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyKaleido" uuid = "f2990250-8cf9-495f-b13a-cce12b45703c" authors = ["Simon Christ ", "Spencer Lyon "] -version = "2.2.0" +version = "2.2.1" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" @@ -11,6 +11,7 @@ Kaleido_jll = "f7e6163d-2fa5-5f23-b69c-1db539e41963" [compat] JSON = "0.21" julia = "1.6" +Kaleido_jll = "0.1, 0.2" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/PlotlyKaleido.jl b/src/PlotlyKaleido.jl index df603de..a8f7937 100644 --- a/src/PlotlyKaleido.jl +++ b/src/PlotlyKaleido.jl @@ -20,14 +20,14 @@ const P = Pipes() const _mathjax_url_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax" const _mathjax_last_version = v"2.7.9" -kill_kaleido() = is_running() && kill(P.proc) +kill_kaleido() = is_running() && (kill(P.proc); wait(P.proc)) is_running() = isdefined(P, :proc) && isopen(P.stdin) && process_running(P.proc) -restart(;kwargs...) = (kill_kaleido(); sleep(0.1); start(;kwargs...)) +restart(;kwargs...) = (kill_kaleido(); start(;kwargs...)) -function start(;plotly_version = missing, - mathjax = missing, mathjax_version::VersionNumber = _mathjax_last_version, +function start(;plotly_version = missing, + mathjax = missing, mathjax_version::VersionNumber = _mathjax_last_version, kwargs...) is_running() && return cmd = joinpath(Kaleido_jll.artifact_dir, "kaleido" * (Sys.iswindows() ? ".cmd" : "")) @@ -50,12 +50,12 @@ function start(;plotly_version = missing, end if mathjax isa Bool && mathjax push!(chromium_flags, "--mathjax=$(_mathjax_url_path)/$(mathjax_version)/MathJax.js") - elseif mathjax isa String + elseif mathjax isa String # We expect the keyword argument to be a valid URL or similar, else error "Kaleido startup failed with code 1". push!(chromium_flags, "--mathjax=$(mathjax)") else - @warn """The value of the provided argument - mathjax=$(mathjax) + @warn """The value of the provided argument + mathjax=$(mathjax) is neither a Bool nor a String and has been ignored.""" end end diff --git a/test/runtests.jl b/test/runtests.jl index e58f5a1..a8c634b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,11 @@ using Test @test_nowarn @eval using PlotlyKaleido -PlotlyKaleido.start() +@testset "Start" begin + @test_nowarn PlotlyKaleido.start() + @test PlotlyKaleido.is_running() +end + import PlotlyLight, EasyConfig, PlotlyJS @@ -29,3 +33,9 @@ end end end end + +@testset "Shutdown" begin + PlotlyKaleido.kill_kaleido() + @test !PlotlyKaleido.is_running() + +end