From d16ffb3eca4b9fd4a906c73f8eb026afe34e0980 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Fri, 2 Dec 2022 21:25:16 -0500 Subject: [PATCH 1/3] Attempt to fix temp dirs on windows --- .github/workflows/system.yml | 6 ++++++ test/test_venv.jl | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/system.yml b/.github/workflows/system.yml index f61f59fc..ec3fc7f5 100644 --- a/.github/workflows/system.yml +++ b/.github/workflows/system.yml @@ -85,6 +85,12 @@ jobs: PYTHON: python - run: julia test/check_deps_version.jl ${{ matrix.python-version }} - uses: julia-actions/julia-runtest@v1 + env: + # Windows temp directories break the CI: + # https://github.com/actions/runner-images/issues/712 + # so, we use + # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context + _TMP_DIR: ${{ runner.temp }} - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v1 with: diff --git a/test/test_venv.jl b/test/test_venv.jl index 01255462..822b3023 100644 --- a/test/test_venv.jl +++ b/test/test_venv.jl @@ -1,5 +1,16 @@ using PyCall, Test +"""Gets temp directory, possibly with user-set environment variable""" +function _mktempdir(parent=nothing; kwargs...) + if parent === nothing && haskey(ENV, "_TMP_DIR") + return mktempdir(ENV["_TMP_DIR"]; kwargs...) + end + if parent === nothing + parent = tempdir() + end + return mktempdir(parent; kwargs...) +end + function test_venv_has_python(path) newpython = PyCall.python_cmd(venv=path).exec[1] @@ -57,7 +68,7 @@ end elseif Sys.which(pyname) === nothing @info "No $pyname command. Skipping the test..." else - mktempdir() do tmppath + _mktempdir() do tmppath if PyCall.pyversion.major == 2 path = joinpath(tmppath, "kind") else @@ -108,7 +119,7 @@ end elseif !success(PyCall.python_cmd(`-c "import venv"`, python=python)) @info "Skip venv test since venv package is missing." else - mktempdir() do tmppath + _mktempdir() do tmppath if PyCall.pyversion.major == 2 path = joinpath(tmppath, "kind") else From 14ea33b70f85c10c8705d700c7b0e6011d68b0c0 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Fri, 2 Dec 2022 21:35:24 -0500 Subject: [PATCH 2/3] Fix call to `_mktempdir` in venv test --- test/test_venv.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_venv.jl b/test/test_venv.jl index 822b3023..25213b6f 100644 --- a/test/test_venv.jl +++ b/test/test_venv.jl @@ -1,14 +1,14 @@ using PyCall, Test """Gets temp directory, possibly with user-set environment variable""" -function _mktempdir(parent=nothing; kwargs...) +function _mktempdir(f::Function, parent=nothing; kwargs...) if parent === nothing && haskey(ENV, "_TMP_DIR") - return mktempdir(ENV["_TMP_DIR"]; kwargs...) + return mktempdir(f, ENV["_TMP_DIR"]; kwargs...) end if parent === nothing parent = tempdir() end - return mktempdir(parent; kwargs...) + return mktempdir(f, parent; kwargs...) end From 77115f5fbbeee77de291e520f25f1ee5d9c3e779 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Fri, 2 Dec 2022 21:51:13 -0500 Subject: [PATCH 3/3] Change to normal `@test` --- test/test_venv.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_venv.jl b/test/test_venv.jl index 25213b6f..3d24ceda 100644 --- a/test/test_venv.jl +++ b/test/test_venv.jl @@ -46,7 +46,7 @@ function test_venv_activation(path) # Marking the test broken in Windows. It seems that # venv copies .dll on Windows and libpython check in # PyCall.__init__ detects that. - @test_broken begin + @test begin output = read(jlcmd, String) sys_executable, exec_prefix, mod_file = split(output, "\n") newpython == sys_executable