Skip to content

Commit 8062ead

Browse files
committed
Merge branch 'add-https-cmake-test'
* add-https-cmake-test: tests: Add test_cmake_https. See #15 requirements-dev: Update pytest-virtualenv from 1.2.2 to 1.2.4
2 parents 4ccb6f1 + c9504da commit 8062ead

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ flake8==3.0.4
44
pytest==3.0.3
55
pytest-cov==2.4.0
66
pytest-runner==2.9
7-
git+https://github.com/jcfr/pytest-plugins@pytest-shutil-2016-11-08-c50ac56#egg=pytest-shutil
8-
pytest-virtualenv==1.2.2
7+
pytest-virtualenv==1.2.4
98
scikit-build==0.4.0
109
virtualenv==15.0.3

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)