Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/TestScripts
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-08-20 14:45:30 +0200
committerMartin Hořeňovský2026-08-20 16:24:18 +0200
commit8582805f548e3e091d8d35188f4c3a690f989b0f (patch)
treea378b537da2dbcfce03e406a02193e3107426cf3 /tests/TestScripts
parent0aeb818520028ca05cc2539ed242402ef7a7ae41 (diff)
downloadcatch3-8582805f548e3e091d8d35188f4c3a690f989b0f.tar.gz
Support TEST_{PREFIX,SUFFIX} with leading/trailing whitespace
Closes #2149
Diffstat (limited to 'tests/TestScripts')
-rw-r--r--tests/TestScripts/DiscoverTests/CMakeLists.txt2
-rw-r--r--tests/TestScripts/DiscoverTests/VerifyRegistration.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/tests/TestScripts/DiscoverTests/CMakeLists.txt b/tests/TestScripts/DiscoverTests/CMakeLists.txt
index 1bcefbb1..8ae0decb 100644
--- a/tests/TestScripts/DiscoverTests/CMakeLists.txt
+++ b/tests/TestScripts/DiscoverTests/CMakeLists.txt
@@ -15,6 +15,8 @@ if(CMAKE_VERSION GREATER_EQUAL 3.27)
endif()
catch_discover_tests(
tests
+ TEST_PREFIX " prefix "
+ TEST_SUFFIX " suffix "
ADD_TAGS_AS_LABELS
DISCOVERY_MODE PRE_TEST
${extra_args}
diff --git a/tests/TestScripts/DiscoverTests/VerifyRegistration.py b/tests/TestScripts/DiscoverTests/VerifyRegistration.py
index 3b7474a0..d33006dd 100644
--- a/tests/TestScripts/DiscoverTests/VerifyRegistration.py
+++ b/tests/TestScripts/DiscoverTests/VerifyRegistration.py
@@ -21,6 +21,11 @@ TestInfo = namedtuple('TestInfo', ['name', 'tags'])
cmake_version_regex = re.compile(r'cmake version (\d+)\.(\d+)\.(\d+)')
+# Note that these both intentionally include preceding/trailing space,
+# which should not get stripped.
+CTEST_NAME_PREFIX = ' prefix '
+CTEST_NAME_SUFFIX = ' suffix '
+
def get_cmake_version():
result = subprocess.run(['cmake', '--version'],
capture_output = True,
@@ -221,7 +226,7 @@ def extract_tests_list_from_ctest_script(build_path: str) -> List[str]:
print(f'stdout: {err.stdout}')
exit(4)
- lines = result.stdout.strip().split('\n')
+ lines = [x for x in result.stdout.split('\n') if x.strip()]
test_num_line = lines[0]
test_lines = lines[1:]
@@ -281,7 +286,7 @@ if __name__ == '__main__':
print(f"{len(catch_test_names)} tests matched in CTest listing")
test_list_names = sorted(extract_tests_list_from_ctest_script(build_path))
- expected_names = sorted(info.name for info in raw_catch_test_names)
+ expected_names = sorted(CTEST_NAME_PREFIX + info.name + CTEST_NAME_SUFFIX for info in raw_catch_test_names)
if test_list_names != expected_names:
print("TEST_LIST variable (tests_TESTS) does not match Catch2 test listing!")
for name in test_list_names: