diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-01-03 23:43:56 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-01-05 06:46:54 +0000 |
commit | 2e411dba93bf2ceecf3dd201b2d100864229ce02 (patch) | |
tree | d6fc878b4b9962d6ee364eca05d32142c2e1346f /CMakeLists.txt | |
parent | f100f7f122885418dfd4d65a062632c6bbdd20c7 (diff) |
test: allow running pytest without specifying the tests directory
This allows `pytest` to be executed from the top-level source or build
directory (or any other directory below).
Change-Id: Ib7af2ea2aaf01319d6839d2dc67228fbb5a7bc34
Reviewed-on: https://code.wireshark.org/review/31370
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e175bc6177..275b0b46f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3170,6 +3170,15 @@ foreach(_group_name ${_test_group_list}) set_tests_properties(${_group_name} PROPERTIES TIMEOUT 600) endforeach() +# Make it possible to run pytest without passing the full path as argument. +if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini) + string(REGEX REPLACE "\naddopts = ([^\n]+)" + "\naddopts = ${CMAKE_CURRENT_SOURCE_DIR}/test \\1" + pytest_ini "${pytest_ini}") + file(WRITE "${CMAKE_BINARY_DIR}/pytest.ini" "${pytest_ini}") +endif() + if (GIT_EXECUTABLE) # Update AUTHORS file with entries from git shortlog add_custom_target( |