diff --git a/requirements-dev.txt b/requirements-dev.txt index d5a3706f2..6d908ed5a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 diff --git a/tests/test_cmake.py b/tests/test_cmake.py index 8dd6a9960..42a32342d 100644 --- a/tests/test_cmake.py +++ b/tests/test_cmake.py @@ -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)])