Skip to content

Commit e70aa46

Browse files
committed
test(_comp_load): Copy files with python
Instead of running bash commands, copy directories and create symlinks using pure python. This should hopefully make macos GHA not fail to delete these directories.
1 parent 5d79137 commit e70aa46

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

test/t/unit/test_unit_load.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
import sys
2+
import shutil
33

44
import pytest
55

@@ -25,20 +25,16 @@ def fixture_dir(self, request, bash):
2525
set up symbolic links.
2626
"""
2727

28-
tmpdir = prepare_fixture_dir(request, files=[], dirs=[])
29-
assert_bash_exec(bash, "cp -R %s/* %s/" % (os.getcwd(), tmpdir))
30-
assert_bash_exec(bash, "mkdir -p %s/bin" % tmpdir)
31-
assert_bash_exec(
32-
bash, "ln -sf ../prefix1/bin/cmd1 %s/bin/cmd1" % tmpdir
33-
)
34-
assert_bash_exec(
35-
bash, "ln -sf ../prefix1/sbin/cmd2 %s/bin/cmd2" % tmpdir
36-
)
37-
yield str(tmpdir)
38-
if sys.platform == "darwin":
39-
assert_bash_exec(bash, "sudo rm -rf %s/*" % tmpdir)
40-
else:
41-
assert_bash_exec(bash, "rm -rf %s/*" % tmpdir)
28+
tmpdir = prepare_fixture_dir(request, files=[], dirs=["bin"])
29+
try:
30+
shutil.copytree(os.getcwd(), str(tmpdir), dirs_exist_ok=True)
31+
except TypeError: # For python <= 3.7
32+
from distutils import dir_util # type: ignore[import-not-found]
33+
34+
dir_util.copy_tree(os.getcwd(), str(tmpdir))
35+
os.symlink("../prefix1/bin/cmd1", f"{tmpdir}/bin/cmd1")
36+
os.symlink("../prefix1/sbin/cmd2", f"{tmpdir}/bin/cmd2")
37+
return str(tmpdir)
4238

4339
def test_userdir_1(self, bash, fixture_dir):
4440
with bash_env_saved(bash) as bash_env:

0 commit comments

Comments
 (0)