-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add-https-cmake-test: tests: Add test_cmake_https. See #15 requirements-dev: Update pytest-virtualenv from 1.2.2 to 1.2.4
- Loading branch information
Showing
2 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,44 @@ | ||
|
||
import pytest | ||
import textwrap | ||
|
||
import cmake | ||
|
||
from . import push_argv | ||
|
||
|
||
def _run(program, args): | ||
func = getattr(cmake, program) | ||
args = ["%s.py" % program] + args | ||
with push_argv(args), pytest.raises(SystemExit) as excinfo: | ||
func() | ||
assert 0 == excinfo.value.code | ||
|
||
|
||
def test_cmake_module(): | ||
with push_argv(["cmake.py", "--version"]), pytest.raises(SystemExit): | ||
cmake.cmake() | ||
_run("cmake", ["--version"]) | ||
_run("cpack", ["--version"]) | ||
_run("ctest", ["--version"]) | ||
|
||
|
||
with push_argv(["cpack.py", "--version"]), pytest.raises(SystemExit): | ||
cmake.cpack() | ||
def test_cmake_https(tmpdir): | ||
test_script = tmpdir.join("cmake-test-https-download.cmake") | ||
test_script.write(textwrap.dedent( | ||
""" | ||
file( | ||
DOWNLOAD | ||
https://github.com/scikit-build/cmake-python-distributions | ||
${TMP_DIR}/page.html | ||
SHOW_PROGRESS | ||
STATUS status | ||
) | ||
list(GET status 0 error_code) | ||
list(GET status 1 error_msg) | ||
if(error_code) | ||
message( | ||
FATAL_ERROR "error: Failed to download ${url}: ${error_msg}") | ||
endif() | ||
""" | ||
)) | ||
|
||
with push_argv(["ctest.py", "--version"]), pytest.raises(SystemExit): | ||
cmake.ctest() | ||
_run("cmake", ["-DTMP_DIR:PATH=%s" % str(tmpdir), "-P", str(test_script)]) |