Skip to content

Commit

Permalink
Merge branch 'add-https-cmake-test'
Browse files Browse the repository at this point in the history
* 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
jcfr committed Nov 29, 2016
2 parents 4ccb6f1 + c9504da commit 8062ead
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ flake8==3.0.4
pytest==3.0.3
pytest-cov==2.4.0
pytest-runner==2.9
git+https://github.com/jcfr/pytest-plugins@pytest-shutil-2016-11-08-c50ac56#egg=pytest-shutil
pytest-virtualenv==1.2.2
pytest-virtualenv==1.2.4
scikit-build==0.4.0
virtualenv==15.0.3
39 changes: 33 additions & 6 deletions tests/test_cmake.py
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)])

0 comments on commit 8062ead

Please sign in to comment.