Skip to content

Commit c9504da

Browse files
committed
tests: Add test_cmake_https. See #15
1 parent 7f6414a commit c9504da

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

tests/test_cmake.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11

22
import pytest
3+
import textwrap
34

45
import cmake
56

67
from . import push_argv
78

89

10+
def _run(program, args):
11+
func = getattr(cmake, program)
12+
args = ["%s.py" % program] + args
13+
with push_argv(args), pytest.raises(SystemExit) as excinfo:
14+
func()
15+
assert 0 == excinfo.value.code
16+
17+
918
def test_cmake_module():
10-
with push_argv(["cmake.py", "--version"]), pytest.raises(SystemExit):
11-
cmake.cmake()
19+
_run("cmake", ["--version"])
20+
_run("cpack", ["--version"])
21+
_run("ctest", ["--version"])
22+
1223

13-
with push_argv(["cpack.py", "--version"]), pytest.raises(SystemExit):
14-
cmake.cpack()
24+
def test_cmake_https(tmpdir):
25+
test_script = tmpdir.join("cmake-test-https-download.cmake")
26+
test_script.write(textwrap.dedent(
27+
"""
28+
file(
29+
DOWNLOAD
30+
https://github.com/scikit-build/cmake-python-distributions
31+
${TMP_DIR}/page.html
32+
SHOW_PROGRESS
33+
STATUS status
34+
)
35+
list(GET status 0 error_code)
36+
list(GET status 1 error_msg)
37+
if(error_code)
38+
message(
39+
FATAL_ERROR "error: Failed to download ${url}: ${error_msg}")
40+
endif()
41+
"""
42+
))
1543

16-
with push_argv(["ctest.py", "--version"]), pytest.raises(SystemExit):
17-
cmake.ctest()
44+
_run("cmake", ["-DTMP_DIR:PATH=%s" % str(tmpdir), "-P", str(test_script)])

0 commit comments

Comments
 (0)