Skip to content

Commit b1abec5

Browse files
authored
Merge pull request intel#94 from intel/lukevalenty/pytest_args
add a cmake option to pass additional arguments to pytest
2 parents 1a73820 + 6562387 commit b1abec5

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

cmake/test.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ function(collect_library_includes output)
228228
endfunction()
229229

230230
function(add_python_test_target name)
231-
set(multiValueArgs FILES INCLUDE_FILES INCLUDE_DIRECTORIES LIBRARIES)
231+
set(multiValueArgs FILES INCLUDE_FILES INCLUDE_DIRECTORIES LIBRARIES
232+
EXTRA_ARGS)
232233
cmake_parse_arguments(UNIT "" "" "${multiValueArgs}" ${ARGN})
233234
list(TRANSFORM UNIT_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
234235
list(TRANSFORM UNIT_INCLUDE_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
@@ -247,7 +248,7 @@ function(add_python_test_target name)
247248
env "PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR}/__pycache__" pytest
248249
--forked -o "cache_dir=${CMAKE_BINARY_DIR}/.pytest_cache"
249250
--rootdir=${CMAKE_SOURCE_DIR} -s ${UNIT_FILES} ${include_files_arg}
250-
${include_dirs_arg})
251+
${include_dirs_arg} ${UNIT_EXTRA_ARGS})
251252

252253
string(PREPEND name "PYTHON.")
253254
add_test(NAME ${name} COMMAND ${target_test_command} COMMAND_EXPAND_LISTS)

test/application/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ add_unit_test(
8383
diagnostics
8484
warnings)
8585

86-
add_unit_test(pytest_test PYTEST FILES pytest_test.py)
86+
add_unit_test(pytest_test PYTEST FILES pytest_test.py EXTRA_ARGS --pass)
8787
mypy_lint(FILES pytest_test.py)
8888

8989
add_benchmark(

test/application/test/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def pytest_addoption(parser):
3+
parser.addoption("--pass", action="store_true", help="Test option", required=True)

0 commit comments

Comments
 (0)