Skip to content

Commit 38b1061

Browse files
authored
Fix unittests on Windows (#1016)
* Attempt to fix temp dirs on windows * Fix call to `_mktempdir` in venv test * Change to normal `@test`
1 parent 9f22684 commit 38b1061

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.github/workflows/system.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ jobs:
8585
PYTHON: python
8686
- run: julia test/check_deps_version.jl ${{ matrix.python-version }}
8787
- uses: julia-actions/julia-runtest@v1
88+
env:
89+
# Windows temp directories break the CI:
90+
# https://github.com/actions/runner-images/issues/712
91+
# so, we use
92+
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
93+
_TMP_DIR: ${{ runner.temp }}
8894
- uses: julia-actions/julia-processcoverage@v1
8995
- uses: codecov/codecov-action@v1
9096
with:

test/test_venv.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
using PyCall, Test
22

3+
"""Gets temp directory, possibly with user-set environment variable"""
4+
function _mktempdir(f::Function, parent=nothing; kwargs...)
5+
if parent === nothing && haskey(ENV, "_TMP_DIR")
6+
return mktempdir(f, ENV["_TMP_DIR"]; kwargs...)
7+
end
8+
if parent === nothing
9+
parent = tempdir()
10+
end
11+
return mktempdir(f, parent; kwargs...)
12+
end
13+
314

415
function test_venv_has_python(path)
516
newpython = PyCall.python_cmd(venv=path).exec[1]
@@ -35,7 +46,7 @@ function test_venv_activation(path)
3546
# Marking the test broken in Windows. It seems that
3647
# venv copies .dll on Windows and libpython check in
3748
# PyCall.__init__ detects that.
38-
@test_broken begin
49+
@test begin
3950
output = read(jlcmd, String)
4051
sys_executable, exec_prefix, mod_file = split(output, "\n")
4152
newpython == sys_executable
@@ -57,7 +68,7 @@ end
5768
elseif Sys.which(pyname) === nothing
5869
@info "No $pyname command. Skipping the test..."
5970
else
60-
mktempdir() do tmppath
71+
_mktempdir() do tmppath
6172
if PyCall.pyversion.major == 2
6273
path = joinpath(tmppath, "kind")
6374
else
@@ -108,7 +119,7 @@ end
108119
elseif !success(PyCall.python_cmd(`-c "import venv"`, python=python))
109120
@info "Skip venv test since venv package is missing."
110121
else
111-
mktempdir() do tmppath
122+
_mktempdir() do tmppath
112123
if PyCall.pyversion.major == 2
113124
path = joinpath(tmppath, "kind")
114125
else

0 commit comments

Comments
 (0)