diff options
| author | Martin Hořeňovský | 2026-09-10 23:33:38 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-09-11 11:27:27 +0200 |
| commit | 1767d9fad0bc28e2b80744daa93c3430d0c6d238 (patch) | |
| tree | acef2d114ed86427fe216855c47850cb2c754446 | |
| parent | ee4b6eadb7f82b4a866324a3c29637d743880bcc (diff) | |
| download | catch3-1767d9fad0bc28e2b80744daa93c3430d0c6d238.tar.gz | |
Add tests for tag validation during test registration
| -rw-r--r-- | tests/ExtraTests/CMakeLists.txt | 21 | ||||
| -rw-r--r-- | tests/ExtraTests/X37-ReportingInvalidTestCaseTags.cpp | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index a7b78748..168b739d 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -461,6 +461,27 @@ set_tests_properties(Reporters::CrashInJunitReporter ) +add_executable(ReportingInvalidTestCaseTags ${TESTS_DIR}/X37-ReportingInvalidTestCaseTags.cpp) +target_link_libraries(ReportingInvalidTestCaseTags PRIVATE Catch2::Catch2WithMain) +add_test( + NAME Validation::TestCaseTags + COMMAND $<TARGET_FILE:ReportingInvalidTestCaseTags> +) +# Passing multiple PASS_REGULAR_EXPRESSION does not work, so we join multiple ones with '.*' +set(regexp + "Found an empty tag while registering test case 'Empty tag is not allowed'" + "Tag name: \\[!abc\\] is not allowed." + "Tag names starting with non-alphanumeric characters are reserved." + "Tag name: \\[@def\\] is not allowed." + "Tag names starting with non-alphanumeric characters are reserved." +) +list(JOIN regexp ".*" regexp) +set_tests_properties(Validation::TestCaseTags + PROPERTIES + PASS_REGULAR_EXPRESSION ${regexp} +) + + add_executable(QuickExitInTest ${TESTS_DIR}/X40-QuickExit.cpp) target_link_libraries(QuickExitInTest PRIVATE Catch2::Catch2WithMain) add_test( diff --git a/tests/ExtraTests/X37-ReportingInvalidTestCaseTags.cpp b/tests/ExtraTests/X37-ReportingInvalidTestCaseTags.cpp new file mode 100644 index 00000000..d70aa34c --- /dev/null +++ b/tests/ExtraTests/X37-ReportingInvalidTestCaseTags.cpp @@ -0,0 +1,19 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/**\file + * Checks that TEST_CASE registration validates tags. + */ + +#include <catch2/catch_test_macros.hpp> + +TEST_CASE( "Empty tag is not allowed", "[]" ) {} + +TEST_CASE( "Exclamation point + unknown followup", "[!abc]" ) {} + +TEST_CASE( "At is not allowed either (it is tag-alias in CLI)", "[@def]" ) {} |