Skip to content

Commit de5ff8a

Browse files
authored
[libc++][test] Improves C++ Standard filtering. (#89499)
Adds a new lit directive to improve C++ Standard filtering. This is based on the [Discourse](https://discourse.llvm.org/t/rfc-improving-c-standard-filtering-in-the-lit-tests/78474) discussion.
1 parent 1a53d4b commit de5ff8a

File tree

8 files changed

+40
-7
lines changed

8 files changed

+40
-7
lines changed

libcxx/docs/TestingLibcxx.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,38 @@ writing tests easier. See `libc++-specific Lit Directives`_ for more information
435435
extension.)
436436

437437

438+
C++ Standard version tests
439+
~~~~~~~~~~~~~~~~~~~~~~~~~~
440+
441+
Historically libc++ tests used to filter the tests for C++ Standard versions
442+
with lit directives like:
443+
444+
.. code-block:: cpp
445+
446+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
447+
448+
With C++ Standards released every 3 years, this solution is not scalable.
449+
Instead use:
450+
451+
.. code-block:: cpp
452+
453+
// UNSUPPORTED: std-at-least-c++26
454+
455+
There is no corresponding ``std-at-most-c++23``. This could be useful when
456+
tests are only valid for a small set of standard versions. For example, a
457+
deprecation test is only valid when the feature is deprecated until it is
458+
removed from the Standard. These tests should be written like:
459+
460+
.. code-block:: cpp
461+
462+
// REQUIRES: c++17 || c++20 || c++23
463+
464+
.. note::
465+
466+
There are a lot of tests with the first style, these can remain as they are.
467+
The new style is only intended to be used for new tests.
468+
469+
438470
Benchmarks
439471
==========
440472

libcxx/test/std/input.output/iostream.format/print.fun/includes.compile.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9+
// REQUIRES: std-at-least-c++23
1010
// UNSUPPORTED: no-filesystem
1111
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1212

libcxx/test/std/input.output/iostream.format/print.fun/no_file_description.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9+
// REQUIRES: std-at-least-c++23
1010
// UNSUPPORTED: no-filesystem
1111
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1212

libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14, c++26
9+
// REQUIRES: c++17 || c++20 || c++23
1010
// UNSUPPORTED: no-wide-characters
1111

1212
// <codecvt>

libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14, c++26
9+
// REQUIRES: c++17 || c++20 || c++23
1010

1111
// XFAIL: no-wide-characters
1212

libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT
1010

11-
// UNSUPPORTED: c++03, c++11, c++14, c++26
11+
// REQUIRES: c++17 || c++20 || c++23
1212
// UNSUPPORTED: no-wide-characters
1313

1414
// <codecvt>

libcxx/test/std/strings/basic.string/string.capacity/reserve.deprecated_in_cxx20.verify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// void reserve(); // Deprecated in C++20
1212

13-
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++26
13+
// REQUIRES: c++20 || c++23
1414

1515
#include <string>
1616

libcxx/utils/libcxx/test/params.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def getSuitableClangTidy(cfg):
186186
AddFeature(std),
187187
AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),
188188
AddCompileFlag(lambda cfg: getStdFlag(cfg, std)),
189-
],
189+
]
190+
+ [AddFeature(f"std-at-least-{s}") for s in _allStandards if s <= std],
190191
),
191192
Parameter(
192193
name="optimization",

0 commit comments

Comments
 (0)