|
1 | 1 |
|
2 | 2 | import pytest
|
| 3 | +import textwrap |
3 | 4 |
|
4 | 5 | import cmake
|
5 | 6 |
|
6 | 7 | from . import push_argv
|
7 | 8 |
|
8 | 9 |
|
| 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 | + |
9 | 18 | 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 | + |
12 | 23 |
|
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 | + )) |
15 | 43 |
|
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