Skip to content

Commit fb24652

Browse files
authored
tests: add testing for scripts processing (#364)
Adding and fixing tests. --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent adf34bf commit fb24652

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

tests/packages/custom_cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ if(NOT EXAMPLE_INCLUDE_FOUND)
1414
endif()
1515

1616
# Testing scripts
17-
install(FILES scripts/script1 DESTINATION "${SKBUILD_SCRIPTS_DIR}")
17+
install(PROGRAMS scripts/script1 DESTINATION "${SKBUILD_SCRIPTS_DIR}")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#/usr/bin/env python3
1+
#!/usr/bin/env python3
22

3-
import sys
3+
from pathlib import Path
44

5-
print(f"Ran script 1 from {sys.executable}")
5+
print(Path(__file__).resolve())

tests/test_custom_modules.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import annotations
22

3+
import sys
34
from pathlib import Path
45

6+
import pytest
7+
58
DIR = Path(__file__).parent
69
PROJECT_DIR = DIR / "packages" / "custom_cmake"
710

@@ -10,4 +13,12 @@ def test_ep(isolated):
1013
isolated.install("hatchling", "scikit-build-core[pyproject]")
1114
isolated.install(PROJECT_DIR / "extern", isolated=False)
1215
isolated.install(PROJECT_DIR, "-v", isolated=False)
13-
# Needs script fix: assert isolated.run("script1") == ""
16+
17+
if sys.platform.startswith("win"):
18+
# TODO: maybe figure out how to make this work on windows?
19+
pytest.skip("Can't run script on Windows")
20+
21+
script = isolated.run("script1", capture=True).strip()
22+
pysys = isolated.execute("import sys; print(sys.executable)").strip()
23+
contents = Path(script).read_text()
24+
assert contents.startswith(f"#!{pysys}")

0 commit comments

Comments
 (0)