File tree Expand file tree Collapse file tree 1 file changed +33
-6
lines changed Expand file tree Collapse file tree 1 file changed +33
-6
lines changed Original file line number Diff line number Diff line change 11
22import pytest
3+ import textwrap
34
45import cmake
56
67from . 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+
918def 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 )])
You can’t perform that action at this time.
0 commit comments