Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pytest to generate junit xml files for python tests #1562

Merged
merged 2 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ libxi-dev
libxmu-dev
python3-distutils
python3-pybind11
python3-pytest
qml-module-qt-labs-folderlistmodel
qml-module-qt-labs-settings
qml-module-qtqml-models2
Expand Down
20 changes: 18 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,25 @@ if (BUILD_TESTING)
testFixture_TEST
)

execute_process(COMMAND "${PYTHON_EXECUTABLE}" -m pytest --version
OUTPUT_VARIABLE PYTEST_output
ERROR_VARIABLE PYTEST_error
RESULT_VARIABLE PYTEST_result)
if(${PYTEST_result} EQUAL 0)
set(pytest_FOUND TRUE)
else()
message("")
message(WARNING "Pytest package not available: ${PYTEST_error}")
endif()

foreach (test ${python_tests})
add_test(NAME ${test}.py COMMAND
"${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/python/test/${test}.py")
if (pytest_FOUND)
add_test(NAME ${test}.py COMMAND
"${PYTHON_EXECUTABLE}" -m pytest "${CMAKE_SOURCE_DIR}/python/test/${test}.py" --junitxml "${CMAKE_BINARY_DIR}/test_results/UNIT_${test}.xml")
else()
add_test(NAME ${test}.py COMMAND
"${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/python/test/${test}.py")
endif()

set(_env_vars)
list(APPEND _env_vars "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/python/")
Expand Down