-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2155 from jan-cerny/issue2153
Check autotailor unit test dependencies
- Loading branch information
Showing
3 changed files
with
51 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Find if a Python module is installed | ||
# Found at http://www.cmake.org/pipermail/cmake/2011-January/041666.html | ||
# To use do: find_python_module(PyQt4 REQUIRED) | ||
|
||
# Keep filename as is | ||
# lint_cmake: -convention/filename, -package/stdargs | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
function(find_python_module module) | ||
string(TOUPPER ${module} module_upper) | ||
if(NOT PY_${module_upper}) | ||
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED") | ||
set(PY_${module}_FIND_REQUIRED TRUE) | ||
endif() | ||
if($ENV{SSG_USE_PIP_PACKAGES}) | ||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" | ||
"import platform; print(''.join('python'+platform.python_version()[:-2]))" | ||
RESULT_VARIABLE _python_version_status | ||
OUTPUT_VARIABLE _python_version | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(NOT ${_python_version_status}) | ||
set(ENV{PYTHONPATH} "/usr/local/lib/${_python_version}/site-packages:/usr/local/lib64/${_python_version}/site-packages") | ||
endif() | ||
endif() | ||
# A module's location is usually a directory, but for binary modules | ||
# it's a .so file. | ||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" | ||
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" | ||
RESULT_VARIABLE _${module}_status | ||
OUTPUT_VARIABLE _${module}_location | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(NOT _${module}_status) | ||
set(PY_${module_upper} ${_${module}_location} CACHE STRING | ||
"Location of Python module ${module}") | ||
endif() | ||
endif() | ||
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper}) | ||
endfunction() |
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,7 +1,9 @@ | ||
add_oscap_test("autotailor_integration_test.sh") | ||
add_oscap_test("test_utils_args.sh") | ||
|
||
add_test( | ||
NAME "autotailor-unit-tests" | ||
COMMAND ${PYTHON_EXECUTABLE} -m pytest -v "${CMAKE_CURRENT_SOURCE_DIR}/test_autotailor.py" | ||
) | ||
if(PY_PYTEST) | ||
add_test( | ||
NAME "autotailor-unit-tests" | ||
COMMAND ${PYTHON_EXECUTABLE} -m pytest -v "${CMAKE_CURRENT_SOURCE_DIR}/test_autotailor.py" | ||
) | ||
endif() |