Skip to content

Commit

Permalink
Fix tests/run.py handling of existing build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Dec 1, 2024
1 parent f194277 commit 56f35c5
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,29 @@ def create_test_workdir(
test_workdir: Path,
custom_gdextension_api: Optional[Path],
) -> None:
if test_workdir.exists():
try:
# Check the directory exists and is not empty
next(test_workdir.iterdir())
print(
f"{YELLOW}{test_dir.name}: workdir {test_workdir} already populated, leaving it as is{NO_COLOR}",
flush=True,
)
return
except (FileNotFoundError, StopIteration):
pass

print(
f"{YELLOW}{test_dir.name}: Create&populate test workdir in {test_workdir}{NO_COLOR}",
flush=True,
)
shutil.copytree(test_dir, test_workdir, dirs_exist_ok=True, symlinks=True)
symlink(distrib_workdir / "addons", test_workdir / "addons")
shutil.copy(distrib_workdir / "pythonscript.gdextension", test_workdir)
# GDExtension headers are needed to compile Cython modules
if custom_gdextension_api:
shutil.copytree(custom_gdextension_api, test_workdir / "gdextension_api", symlinks=True)
else:
print(
f"{YELLOW}{test_dir.name}: Create&populate test workdir in {test_workdir}{NO_COLOR}",
flush=True,
)
shutil.copytree(test_dir, test_workdir, dirs_exist_ok=True, symlinks=True)
symlink(distrib_workdir / "addons", test_workdir / "addons")
shutil.copy(distrib_workdir / "pythonscript.gdextension", test_workdir)
# GDExtension headers are needed to compile Cython modules
if custom_gdextension_api:
shutil.copytree(custom_gdextension_api, test_workdir / "gdextension_api", symlinks=True)
else:
symlink(build_dir / "gdextension_api", test_workdir / "gdextension_api")
symlink(build_dir / "gdextension_api", test_workdir / "gdextension_api")

build_script = test_workdir / "build.py"
if build_script.exists():
Expand Down

0 comments on commit 56f35c5

Please sign in to comment.