From f708ea047c878dddf42a0fa2e48335c747b1d7cf Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Thu, 6 Feb 2025 22:51:59 +0530 Subject: [PATCH 01/13] Initial Implementation Signed-off-by: Ameya Vikram Singh --- cmake/FindPytest.cmake | 3 ++- cmake/PytestAddTests.cmake | 2 +- test/06-pytest-args/CMakeLists.txt | 15 +++++++++++++++ test/06-pytest-args/test_basic.py | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/06-pytest-args/CMakeLists.txt create mode 100644 test/06-pytest-args/test_basic.py diff --git a/cmake/FindPytest.cmake b/cmake/FindPytest.cmake index 341d697..74b8d14 100644 --- a/cmake/FindPytest.cmake +++ b/cmake/FindPytest.cmake @@ -58,7 +58,7 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) cmake_parse_arguments( PARSE_ARGV 1 "" "STRIP_PARAM_BRACKETS;INCLUDE_FILE_PATH;BUNDLE_TESTS" "WORKING_DIRECTORY;TRIM_FROM_NAME;TRIM_FROM_FULL_NAME" - "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;PROPERTIES;DEPENDS" + "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;PROPERTIES;DEPENDS;PYTEST_ARGS" ) # Set platform-specific library path environment variable. @@ -132,6 +132,7 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) -D "ENVIRONMENT=${_ENVIRONMENT}" -D "TEST_PROPERTIES=${_PROPERTIES}" -D "CTEST_FILE=${_tests_file}" + -D "PYTEST_ARGS=${_PYTEST_ARGS}" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PytestAddTests.cmake") # Create a custom target to run the tests. diff --git a/cmake/PytestAddTests.cmake b/cmake/PytestAddTests.cmake index 15250cb..d38a3f8 100644 --- a/cmake/PytestAddTests.cmake +++ b/cmake/PytestAddTests.cmake @@ -62,7 +62,7 @@ if(CMAKE_SCRIPT_MODE_FILE) execute_process( COMMAND "${PYTEST_EXECUTABLE}" --collect-only -q - --rootdir=${WORKING_DIRECTORY} . + --rootdir=${WORKING_DIRECTORY} . ${PYTEST_ARGS} OUTPUT_VARIABLE _output_lines ERROR_VARIABLE _output_lines OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt new file mode 100644 index 0000000..f068417 --- /dev/null +++ b/test/06-pytest-args/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.20) + +project(TestPytestArgs) + +find_package(Pytest REQUIRED) + +enable_testing() + +# The --help flag will supress test discovery +pytest_discover_tests( + pytestargs.basic + PYTEST_ARGS --help + DEPENDS test_basic.py +) + diff --git a/test/06-pytest-args/test_basic.py b/test/06-pytest-args/test_basic.py new file mode 100644 index 0000000..3056257 --- /dev/null +++ b/test/06-pytest-args/test_basic.py @@ -0,0 +1,3 @@ + +def test_basic(): + pass From 68de6a2e6c62a2c92a3b8210226e98d09a82290b Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sat, 8 Feb 2025 18:51:08 +0530 Subject: [PATCH 02/13] Update implementation to pass command line flags to generated tests --- cmake/PytestAddTests.cmake | 6 ++++-- test/06-pytest-args/CMakeLists.txt | 32 ++++++++++++++++++++++++++++-- test/06-pytest-args/test_basic.py | 2 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/cmake/PytestAddTests.cmake b/cmake/PytestAddTests.cmake index d38a3f8..e83920c 100644 --- a/cmake/PytestAddTests.cmake +++ b/cmake/PytestAddTests.cmake @@ -26,10 +26,12 @@ if(CMAKE_SCRIPT_MODE_FILE) list(APPEND ENCODED_ENVIRONMENT "${env}") endforeach() + list(JOIN PYTEST_ARGS " " PYTEST_ARGS_STR) + # Macro to create individual tests with optional test properties. macro(create_test NAME IDENTIFIER) string(APPEND _content - "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==])\n" + "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==] " ${PYTEST_ARGS_STR} ")\n" ) # Prepare the properties for the test, including the environment settings. @@ -62,7 +64,7 @@ if(CMAKE_SCRIPT_MODE_FILE) execute_process( COMMAND "${PYTEST_EXECUTABLE}" --collect-only -q - --rootdir=${WORKING_DIRECTORY} . ${PYTEST_ARGS} + --rootdir=${WORKING_DIRECTORY} ${PYTEST_ARGS} . OUTPUT_VARIABLE _output_lines ERROR_VARIABLE _output_lines OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index f068417..e64e01a 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -6,10 +6,38 @@ find_package(Pytest REQUIRED) enable_testing() -# The --help flag will supress test discovery +# The --help flag will suppress test discovery pytest_discover_tests( - pytestargs.basic + pytestargs_no_test_discovered_w_help PYTEST_ARGS --help DEPENDS test_basic.py ) +# The -v flag will suppress test discovery +# as the output for the command: pytest --co -q +# Is affected by this commandline flag +pytest_discover_tests( + pytestargs_no_test_discovered_w_args_v + PYTEST_ARGS -v + DEPENDS test_basic.py +) + +pytest_discover_tests( + pytestargs_no_test_discovered_w_args_v_s + PYTEST_ARGS -v -s + DEPENDS test_basic.py +) + +pytest_discover_tests( + pytestargs_basic_args + PYTEST_ARGS -v -s -q + DEPENDS test_basic.py +) + +# Currently quoted args are not supported +# pytest_discover_tests( +# pytestargs_basic_args_quoted +# PYTEST_ARGS "-v -s -q" +# DEPENDS test_basic.py +# ) + diff --git a/test/06-pytest-args/test_basic.py b/test/06-pytest-args/test_basic.py index 3056257..9388df6 100644 --- a/test/06-pytest-args/test_basic.py +++ b/test/06-pytest-args/test_basic.py @@ -1,3 +1,5 @@ def test_basic(): + print("Test Basic Print") + assert True pass From d14f325c8b7fb2482f32a0efe6e061ef666ebe94 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sat, 8 Feb 2025 19:05:55 +0530 Subject: [PATCH 03/13] Basic validation for test identification Signed-off-by: Ameya Vikram Singh --- test/06-pytest-args/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index e64e01a..e22378a 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -28,12 +28,26 @@ pytest_discover_tests( DEPENDS test_basic.py ) +# add_test(NAME TestPytestArgs.Validate.test_no_discovered_w_args_v_s +# COMMAND ${CMAKE_COMMAND} +# -D "TEST_PREFIX=\"\"" +# -D "EXPECTED=\"\"" +# -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake +# ) + pytest_discover_tests( pytestargs_basic_args PYTEST_ARGS -v -s -q DEPENDS test_basic.py ) +add_test(NAME TestPytestArgs.Validate.test_basic + COMMAND ${CMAKE_COMMAND} + -D "TEST_PREFIX=pytestargs_basic_args.test_basic" + -D "EXPECTED=pytestargs_basic_args.test_basic" + -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake +) + # Currently quoted args are not supported # pytest_discover_tests( # pytestargs_basic_args_quoted From e311149dffb7ddeaca394b7f749e67a5591ada5b Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sat, 8 Feb 2025 20:29:24 +0530 Subject: [PATCH 04/13] Try other variants of using PYTEST_ARGS --- test/06-pytest-args/CMakeLists.txt | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index e22378a..d489c91 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -49,9 +49,22 @@ add_test(NAME TestPytestArgs.Validate.test_basic ) # Currently quoted args are not supported -# pytest_discover_tests( -# pytestargs_basic_args_quoted -# PYTEST_ARGS "-v -s -q" -# DEPENDS test_basic.py -# ) +pytest_discover_tests( + pytestargs_basic_args_quoted + PYTEST_ARGS "-v -s -q" + DEPENDS test_basic.py +) + +# semi-colon value to the PYTEST_ARGS is considered as a list +pytest_discover_tests( + pytestargs_basic_args_semicolon + PYTEST_ARGS -v;-s;-q + DEPENDS test_basic.py +) +add_test(NAME TestPytestArgsSemicolon.Validate.test_basic + COMMAND ${CMAKE_COMMAND} + -D "TEST_PREFIX=pytestargs_basic_args_semicolon.test_basic" + -D "EXPECTED=pytestargs_basic_args_semicolon.test_basic" + -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake +) \ No newline at end of file From dff6fb44a875d131ecc7b312cf5f5249a46d5a04 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sat, 8 Feb 2025 20:30:35 +0530 Subject: [PATCH 05/13] Minor fix --- test/06-pytest-args/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index d489c91..bc59a34 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -67,4 +67,4 @@ add_test(NAME TestPytestArgsSemicolon.Validate.test_basic -D "TEST_PREFIX=pytestargs_basic_args_semicolon.test_basic" -D "EXPECTED=pytestargs_basic_args_semicolon.test_basic" -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake -) \ No newline at end of file +) From dfe32d6507c06a82ee11a0cdcf123b352a92483b Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:23:06 +0530 Subject: [PATCH 06/13] Updates based on review comments --- cmake/FindPytest.cmake | 4 +- cmake/PytestAddTests.cmake | 11 +++-- test/06-pytest-args/CMakeLists.txt | 65 ++------------------------ test/06-pytest-args/test_extra_args.py | 7 +++ 4 files changed, 21 insertions(+), 66 deletions(-) create mode 100644 test/06-pytest-args/test_extra_args.py diff --git a/cmake/FindPytest.cmake b/cmake/FindPytest.cmake index 74b8d14..480b2f5 100644 --- a/cmake/FindPytest.cmake +++ b/cmake/FindPytest.cmake @@ -58,7 +58,7 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) cmake_parse_arguments( PARSE_ARGV 1 "" "STRIP_PARAM_BRACKETS;INCLUDE_FILE_PATH;BUNDLE_TESTS" "WORKING_DIRECTORY;TRIM_FROM_NAME;TRIM_FROM_FULL_NAME" - "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;PROPERTIES;DEPENDS;PYTEST_ARGS" + "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;PROPERTIES;DEPENDS;EXTRA_ARGS" ) # Set platform-specific library path environment variable. @@ -132,7 +132,7 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) -D "ENVIRONMENT=${_ENVIRONMENT}" -D "TEST_PROPERTIES=${_PROPERTIES}" -D "CTEST_FILE=${_tests_file}" - -D "PYTEST_ARGS=${_PYTEST_ARGS}" + -D "EXTRA_ARGS=${_EXTRA_ARGS}" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PytestAddTests.cmake") # Create a custom target to run the tests. diff --git a/cmake/PytestAddTests.cmake b/cmake/PytestAddTests.cmake index e83920c..c13a7e1 100644 --- a/cmake/PytestAddTests.cmake +++ b/cmake/PytestAddTests.cmake @@ -26,12 +26,17 @@ if(CMAKE_SCRIPT_MODE_FILE) list(APPEND ENCODED_ENVIRONMENT "${env}") endforeach() - list(JOIN PYTEST_ARGS " " PYTEST_ARGS_STR) + # Handle EXTRA_ARGS for individual tests + set(EXTRA_ARGS_WRAPPED) + foreach(arg IN LISTS EXTRA_ARGS) + list(APPEND EXTRA_ARGS_WRAPPED "[==[${arg}]==]") + endforeach() + list(JOIN EXTRA_ARGS_WRAPPED " " EXTRA_ARGS_STR) # Macro to create individual tests with optional test properties. macro(create_test NAME IDENTIFIER) string(APPEND _content - "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==] " ${PYTEST_ARGS_STR} ")\n" + "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==] ${EXTRA_ARGS_STR} )\n" ) # Prepare the properties for the test, including the environment settings. @@ -64,7 +69,7 @@ if(CMAKE_SCRIPT_MODE_FILE) execute_process( COMMAND "${PYTEST_EXECUTABLE}" --collect-only -q - --rootdir=${WORKING_DIRECTORY} ${PYTEST_ARGS} . + --rootdir=${WORKING_DIRECTORY} . OUTPUT_VARIABLE _output_lines ERROR_VARIABLE _output_lines OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index bc59a34..01cbe96 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -1,70 +1,13 @@ cmake_minimum_required(VERSION 3.20) -project(TestPytestArgs) +project(TestExtraArgs) find_package(Pytest REQUIRED) enable_testing() -# The --help flag will suppress test discovery pytest_discover_tests( - pytestargs_no_test_discovered_w_help - PYTEST_ARGS --help - DEPENDS test_basic.py -) - -# The -v flag will suppress test discovery -# as the output for the command: pytest --co -q -# Is affected by this commandline flag -pytest_discover_tests( - pytestargs_no_test_discovered_w_args_v - PYTEST_ARGS -v - DEPENDS test_basic.py -) - -pytest_discover_tests( - pytestargs_no_test_discovered_w_args_v_s - PYTEST_ARGS -v -s - DEPENDS test_basic.py -) - -# add_test(NAME TestPytestArgs.Validate.test_no_discovered_w_args_v_s -# COMMAND ${CMAKE_COMMAND} -# -D "TEST_PREFIX=\"\"" -# -D "EXPECTED=\"\"" -# -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake -# ) - -pytest_discover_tests( - pytestargs_basic_args - PYTEST_ARGS -v -s -q - DEPENDS test_basic.py -) - -add_test(NAME TestPytestArgs.Validate.test_basic - COMMAND ${CMAKE_COMMAND} - -D "TEST_PREFIX=pytestargs_basic_args.test_basic" - -D "EXPECTED=pytestargs_basic_args.test_basic" - -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake -) - -# Currently quoted args are not supported -pytest_discover_tests( - pytestargs_basic_args_quoted - PYTEST_ARGS "-v -s -q" - DEPENDS test_basic.py -) - -# semi-colon value to the PYTEST_ARGS is considered as a list -pytest_discover_tests( - pytestargs_basic_args_semicolon - PYTEST_ARGS -v;-s;-q - DEPENDS test_basic.py -) - -add_test(NAME TestPytestArgsSemicolon.Validate.test_basic - COMMAND ${CMAKE_COMMAND} - -D "TEST_PREFIX=pytestargs_basic_args_semicolon.test_basic" - -D "EXPECTED=pytestargs_basic_args_semicolon.test_basic" - -P ${CMAKE_CURRENT_SOURCE_DIR}/../01-modify-name/compare_discovered_tests.cmake + TestExtraArgs + EXTRA_ARGS "--capture=no" + DEPENDS test_extra_args.py ) diff --git a/test/06-pytest-args/test_extra_args.py b/test/06-pytest-args/test_extra_args.py new file mode 100644 index 0000000..84a8bab --- /dev/null +++ b/test/06-pytest-args/test_extra_args.py @@ -0,0 +1,7 @@ +import pytest + +def test_requires_no_capture(request): + """Fails unless '--capture=no' is passed to pytest.""" + if "--capture=no" not in request.config.invocation_params.args: + pytest.fail("Test requires '--capture=no' to properly display output.") + assert True \ No newline at end of file From 5e520657bd4634ed2a067a9e9d9127e7afb08104 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:25:27 +0530 Subject: [PATCH 07/13] Rename test_basic to test_with_args --- test/06-pytest-args/{test_basic.py => test_with_args.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/06-pytest-args/{test_basic.py => test_with_args.py} (100%) diff --git a/test/06-pytest-args/test_basic.py b/test/06-pytest-args/test_with_args.py similarity index 100% rename from test/06-pytest-args/test_basic.py rename to test/06-pytest-args/test_with_args.py From 51e3fe12f0c8f17473a854dce9feffc1fab93bad Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:29:03 +0530 Subject: [PATCH 08/13] Remove test_with_args.py --- test/06-pytest-args/test_with_args.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 test/06-pytest-args/test_with_args.py diff --git a/test/06-pytest-args/test_with_args.py b/test/06-pytest-args/test_with_args.py deleted file mode 100644 index 9388df6..0000000 --- a/test/06-pytest-args/test_with_args.py +++ /dev/null @@ -1,5 +0,0 @@ - -def test_basic(): - print("Test Basic Print") - assert True - pass From 9d0734a70f26399a8d9dab019dba985d3bf9d827 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:36:18 +0530 Subject: [PATCH 09/13] Add an example of test with custom comandline flags Signed-off-by: Ameya Vikram Singh --- test/06-pytest-args/CMakeLists.txt | 2 +- test/06-pytest-args/conftest.py | 10 ++++++++++ test/06-pytest-args/test_extra_args.py | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/06-pytest-args/conftest.py diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-pytest-args/CMakeLists.txt index 01cbe96..e1bac5e 100644 --- a/test/06-pytest-args/CMakeLists.txt +++ b/test/06-pytest-args/CMakeLists.txt @@ -8,6 +8,6 @@ enable_testing() pytest_discover_tests( TestExtraArgs - EXTRA_ARGS "--capture=no" + EXTRA_ARGS "--capture=no" "--cmdopt=demo" DEPENDS test_extra_args.py ) diff --git a/test/06-pytest-args/conftest.py b/test/06-pytest-args/conftest.py new file mode 100644 index 0000000..fcb0d88 --- /dev/null +++ b/test/06-pytest-args/conftest.py @@ -0,0 +1,10 @@ +import pytest + +def pytest_addoption(parser): + parser.addoption( + "--cmdopt", action="store", help="custom options" + ) + +@pytest.fixture +def cmdopt(request): + return request.config.getoption("--cmdopt") \ No newline at end of file diff --git a/test/06-pytest-args/test_extra_args.py b/test/06-pytest-args/test_extra_args.py index 84a8bab..ccc97c0 100644 --- a/test/06-pytest-args/test_extra_args.py +++ b/test/06-pytest-args/test_extra_args.py @@ -4,4 +4,12 @@ def test_requires_no_capture(request): """Fails unless '--capture=no' is passed to pytest.""" if "--capture=no" not in request.config.invocation_params.args: pytest.fail("Test requires '--capture=no' to properly display output.") - assert True \ No newline at end of file + assert True + + +def test_requires_args(cmdopt): + if cmdopt != None: + print(cmdopt) + else: + pytest.fail("Command line option not specified") + pass From da3eb254618b6ac68831232e5dc44b63573b2f6c Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:37:58 +0530 Subject: [PATCH 10/13] Align test directory name to extra-args --- test/{06-pytest-args => 06-extra-args}/CMakeLists.txt | 0 test/{06-pytest-args => 06-extra-args}/conftest.py | 0 test/{06-pytest-args => 06-extra-args}/test_extra_args.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/{06-pytest-args => 06-extra-args}/CMakeLists.txt (100%) rename test/{06-pytest-args => 06-extra-args}/conftest.py (100%) rename test/{06-pytest-args => 06-extra-args}/test_extra_args.py (100%) diff --git a/test/06-pytest-args/CMakeLists.txt b/test/06-extra-args/CMakeLists.txt similarity index 100% rename from test/06-pytest-args/CMakeLists.txt rename to test/06-extra-args/CMakeLists.txt diff --git a/test/06-pytest-args/conftest.py b/test/06-extra-args/conftest.py similarity index 100% rename from test/06-pytest-args/conftest.py rename to test/06-extra-args/conftest.py diff --git a/test/06-pytest-args/test_extra_args.py b/test/06-extra-args/test_extra_args.py similarity index 100% rename from test/06-pytest-args/test_extra_args.py rename to test/06-extra-args/test_extra_args.py From f0271444bc41d7cc269ffbbc65c0f75ba118dac2 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:43:27 +0530 Subject: [PATCH 11/13] Update test/CMakeLists.txt with reference to 06-extra-args --- test/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4732ec5..6eef290 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,3 +52,13 @@ ExternalProject_Add( -C Release -VV -R TestProperties.Validate ) + +ExternalProject_Add( + TestExtraArgs + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/06-extra-args + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/06-extra-args + BUILD_COMMAND ${CMAKE_COMMAND} --build + INSTALL_COMMAND "" + TEST_COMMAND ${CMAKE_CTEST_COMMAND} + -C Release -VV +) From dd7f0ee894caefaef69cf33604e77cc2a1539cb9 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 09:45:40 +0530 Subject: [PATCH 12/13] Fix formatting --- test/06-extra-args/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/06-extra-args/conftest.py b/test/06-extra-args/conftest.py index fcb0d88..2d52afa 100644 --- a/test/06-extra-args/conftest.py +++ b/test/06-extra-args/conftest.py @@ -7,4 +7,4 @@ def pytest_addoption(parser): @pytest.fixture def cmdopt(request): - return request.config.getoption("--cmdopt") \ No newline at end of file + return request.config.getoption("--cmdopt") From b8f86d30b65022fbc2b21bb5e296411952c08c02 Mon Sep 17 00:00:00 2001 From: Ameya Vikram Singh Date: Sun, 9 Feb 2025 10:55:36 +0530 Subject: [PATCH 13/13] Update test documentation, failure messaging --- test/06-extra-args/test_extra_args.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/06-extra-args/test_extra_args.py b/test/06-extra-args/test_extra_args.py index ccc97c0..fe62a0c 100644 --- a/test/06-extra-args/test_extra_args.py +++ b/test/06-extra-args/test_extra_args.py @@ -8,8 +8,9 @@ def test_requires_no_capture(request): def test_requires_args(cmdopt): + """Fails unless '--cmdopt=' is passed to pytest.""" if cmdopt != None: - print(cmdopt) + print(f"Option Value: cmdopt: {cmdopt}") else: - pytest.fail("Command line option not specified") + pytest.fail("Test requires '--cmdopt=' to properly execute the test.") pass