[libcxx-commits] [libcxx] 7d2b9fa - [libc++] Use Lit annotations for all .gen.py tests
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 6 13:29:15 PDT 2023
Author: Louis Dionne
Date: 2023-06-06T13:28:09-07:00
New Revision: 7d2b9fafabd6f1a67e05ab2fa0abb5f7c8a451e7
URL: https://github.com/llvm/llvm-project/commit/7d2b9fafabd6f1a67e05ab2fa0abb5f7c8a451e7
DIFF: https://github.com/llvm/llvm-project/commit/7d2b9fafabd6f1a67e05ab2fa0abb5f7c8a451e7.diff
LOG: [libc++] Use Lit annotations for all .gen.py tests
Instead of guarding header tests using #ifdefs inside the tests,
use Lit markup to mark all the tests as unsupported. This is simpler
but also provides better feedback about which tests are being run
when running the test suite.
Differential Revision: https://reviews.llvm.org/D151893
Added:
Modified:
libcxx/include/__memory_resource/synchronized_pool_resource.h
libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
libcxx/test/libcxx/clang_tidy.gen.py
libcxx/test/libcxx/double_include.gen.py
libcxx/test/libcxx/header_inclusions.gen.py
libcxx/test/libcxx/modules_include.gen.py
libcxx/test/libcxx/nasty_macros.gen.py
libcxx/test/libcxx/no_assert_include.gen.py
libcxx/test/libcxx/private_headers.gen.py
libcxx/test/libcxx/transitive_includes.gen.py
libcxx/utils/libcxx/test/header_information.py
Removed:
################################################################################
diff --git a/libcxx/include/__memory_resource/synchronized_pool_resource.h b/libcxx/include/__memory_resource/synchronized_pool_resource.h
index 576a29a4d5c21..cddcd3479aae5 100644
--- a/libcxx/include/__memory_resource/synchronized_pool_resource.h
+++ b/libcxx/include/__memory_resource/synchronized_pool_resource.h
@@ -14,9 +14,7 @@
#include <__memory_resource/pool_options.h>
#include <__memory_resource/unsynchronized_pool_resource.h>
#include <cstddef>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <mutex>
-#endif
+#include <mutex>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
index 2bf9b66f1be94..f72c257402936 100644
--- a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
+++ b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
@@ -14,22 +14,20 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
for header in public_headers:
# Skip C compatibility headers.
if header.endswith('.h'):
continue
- test_condition_begin = f'#if {header_restrictions[header]}' if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
- XFAIL = 'XFAIL' # Make sure Lit doesn't think we are XFAILing this test
+ BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
print(f"""\
//--- {header}.compile.pass.cpp
-// {XFAIL}: availability-verbose_abort-missing
-#include <__config>
-{test_condition_begin}
+{lit_header_restrictions.get(header, '')}
+
+// XFAIL{BLOCKLIT}: availability-verbose_abort-missing
+
#include <{header}>
using HandlerType = decltype(std::__libcpp_verbose_abort);
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/clang_tidy.gen.py b/libcxx/test/libcxx/clang_tidy.gen.py
index 7ced030883d9a..a7b8e7b3ec549 100644
--- a/libcxx/test/libcxx/clang_tidy.gen.py
+++ b/libcxx/test/libcxx/clang_tidy.gen.py
@@ -12,13 +12,10 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
for header in public_headers:
BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
-
print(f"""\
//--- {header}.sh.cpp
@@ -27,12 +24,11 @@
// The GCC compiler flags are not always compatible with clang-tidy.
// UNSUPPORTED{BLOCKLIT}: gcc
+{lit_header_restrictions.get(header, '')}
+
// TODO: run clang-tidy with modules enabled once they are supported
// RUN{BLOCKLIT}: %{{clang-tidy}} %s --warnings-as-errors=* -header-filter=.* --checks='-*,libcpp-*' --load=%{{test-tools}}/clang_tidy_checks/libcxx-tidy.plugin -- %{{compile_flags}} -fno-modules
// RUN{BLOCKLIT}: %{{clang-tidy}} %s --warnings-as-errors=* -header-filter=.* --config-file=%{{libcxx}}/.clang-tidy -- -Wweak-vtables %{{compile_flags}} -fno-modules
-#include <__config>
-{test_condition_begin}
#include <{header}>
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/double_include.gen.py b/libcxx/test/libcxx/double_include.gen.py
index 10b7be341a86e..ad18121d53be0 100644
--- a/libcxx/test/libcxx/double_include.gen.py
+++ b/libcxx/test/libcxx/double_include.gen.py
@@ -12,29 +12,22 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
+
+for header in public_headers:
+ BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
+ print(f"""\
+//--- {header}.sh.cpp
+{lit_header_restrictions.get(header, '')}
-BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
-print(f"""\
-//--- double_include.sh.cpp
// RUN{BLOCKLIT}: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
// RUN{BLOCKLIT}: %{{cxx}} -c %s -o %t.second.o -DWITH_MAIN %{{flags}} %{{compile_flags}}
// RUN{BLOCKLIT}: %{{cxx}} -o %t.exe %t.first.o %t.second.o %{{flags}} %{{link_flags}}
// RUN{BLOCKLIT}: %{{run}}
-""")
-for header in public_headers:
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
- print(f"""\
-#include <__config>
-{test_condition_begin}
#include <{header}>
-{test_condition_end}
-""")
-print("""
#if defined(WITH_MAIN)
-int main(int, char**) { return 0; }
+int main(int, char**) {{ return 0; }}
#endif
""")
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index 3273f013ea3b3..f41ac27b651b3 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -13,12 +13,9 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers, mandatory_inclusions
+from libcxx.test.header_information import lit_header_restrictions, public_headers, mandatory_inclusions
for header in public_headers:
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
-
header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}"
# <cassert> has no header guards
@@ -39,9 +36,8 @@
print(f"""\
//--- {header}.compile.pass.cpp
-#include <__config>
-{test_condition_begin}
+{lit_header_restrictions.get(header, '')}
+
#include <{header}>
{checks}
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/modules_include.gen.py b/libcxx/test/libcxx/modules_include.gen.py
index 0b9e67a19d7f5..565def85ee138 100644
--- a/libcxx/test/libcxx/modules_include.gen.py
+++ b/libcxx/test/libcxx/modules_include.gen.py
@@ -14,13 +14,10 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
for header in public_headers:
BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
-
print(f"""\
//--- {header}.compile.pass.cpp
// RUN{BLOCKLIT}: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only
@@ -38,8 +35,7 @@
// TODO: Investigate this failure
// UNSUPPORTED{BLOCKLIT}: LIBCXX-FREEBSD-FIXME
-#include <__config>
-{test_condition_begin}
+{lit_header_restrictions.get(header, '')}
+
#include <{header}>
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/nasty_macros.gen.py b/libcxx/test/libcxx/nasty_macros.gen.py
index 3308b0b649776..3d3868fc7653c 100644
--- a/libcxx/test/libcxx/nasty_macros.gen.py
+++ b/libcxx/test/libcxx/nasty_macros.gen.py
@@ -13,14 +13,13 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
for header in public_headers:
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
-
print(f"""\
//--- {header}.compile.pass.cpp
+{lit_header_restrictions.get(header, '')}
+
#define NASTY_MACRO This should not be expanded!!!
// libc++ does not use single-letter names as a matter of principle.
@@ -150,8 +149,5 @@
#define min NASTY_MACRO
#define max NASTY_MACRO
-#include <__config>
-{test_condition_begin}
#include <{header}>
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/no_assert_include.gen.py b/libcxx/test/libcxx/no_assert_include.gen.py
index 900cf3ec7daba..45152a35f3177 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -13,23 +13,19 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
for header in public_headers:
if header == 'cassert':
continue
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
-
print(f"""\
//--- {header}.compile.pass.cpp
+{lit_header_restrictions.get(header, '')}
-#include <__config>
-{test_condition_begin}
#include <{header}>
+
#ifdef assert
# error "Do not include cassert or assert.h in standard header files"
#endif
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/private_headers.gen.py b/libcxx/test/libcxx/private_headers.gen.py
index 541ce209f2db4..9091e62b4bbd5 100644
--- a/libcxx/test/libcxx/private_headers.gen.py
+++ b/libcxx/test/libcxx/private_headers.gen.py
@@ -13,7 +13,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, private_headers, private_headers_still_public_in_modules
+from libcxx.test.header_information import lit_header_restrictions, private_headers, private_headers_still_public_in_modules
for header in private_headers:
# Skip headers that are not private yet in the modulemap
@@ -32,16 +32,11 @@
if header.startswith('__pstl'):
continue
- test_condition_begin = '#if ' + header_restrictions[header] if header in header_restrictions else ''
- test_condition_end = '#endif' if header in header_restrictions else ''
BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
-
print(f"""\
//--- {header}.verify.cpp
// REQUIRES{BLOCKLIT}: modules-build
+{lit_header_restrictions.get(header, '')}
-#include <__config>
-{test_condition_begin}
#include <{header}> // expected-error@*:* {{{{use of private header from outside its module: '{header}'}}}}
-{test_condition_end}
""")
diff --git a/libcxx/test/libcxx/transitive_includes.gen.py b/libcxx/test/libcxx/transitive_includes.gen.py
index 94ba9a100a150..13f897b07ffb4 100644
--- a/libcxx/test/libcxx/transitive_includes.gen.py
+++ b/libcxx/test/libcxx/transitive_includes.gen.py
@@ -20,7 +20,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.test.header_information import header_restrictions, public_headers
+from libcxx.test.header_information import lit_header_restrictions, public_headers
import re
@@ -61,10 +61,10 @@
print(f"""\
//--- {header}.sh.cpp
+{lit_header_restrictions.get(header, '')}
-// This test doesn't support being run when some headers are not available, since we
-// would need to add significant complexity to make that work.
-// UNSUPPORTED{BLOCKLIT}: no-localization, no-threads, no-wide-characters, no-filesystem
+// TODO: Fix this test to make it work with filesystem, localization or wide characters disabled
+// UNSUPPORTED{BLOCKLIT}: no-filesystem, no-localization, no-wide-characters
// When built with modules, this test doesn't work because --trace-includes doesn't
// report the stack of includes correctly.
diff --git a/libcxx/utils/libcxx/test/header_information.py b/libcxx/utils/libcxx/test/header_information.py
index af182dfa20ecc..6ebfbb8e0d82f 100644
--- a/libcxx/utils/libcxx/test/header_information.py
+++ b/libcxx/utils/libcxx/test/header_information.py
@@ -8,58 +8,6 @@
import os, pathlib
-header_restrictions = {
- "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "stdatomic.h": "__cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)",
- "stop_token": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "filesystem": "!defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)",
- # TODO(LLVM-17): simplify this to __cplusplus >= 202002L
- "coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
- "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)",
- "iomanip": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "iostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "istream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "locale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "ostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "sstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "streambuf": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "strstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "wctype.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "cwctype": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "cwchar": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "experimental/algorithm": "__cplusplus >= 201103L",
- "experimental/deque": "__cplusplus >= 201103L",
- "experimental/forward_list": "__cplusplus >= 201103L",
- "experimental/functional": "__cplusplus >= 201103L",
- "experimental/iterator": "__cplusplus >= 201103L",
- "experimental/list": "__cplusplus >= 201103L",
- "experimental/map": "__cplusplus >= 201103L",
- "experimental/memory_resource": "__cplusplus >= 201103L",
- "experimental/propagate_const": "__cplusplus >= 201103L",
- "experimental/regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L",
- "experimental/set": "__cplusplus >= 201103L",
- "experimental/simd": "__cplusplus >= 201103L",
- "experimental/span": "__cplusplus >= 201103L",
- "experimental/string": "__cplusplus >= 201103L",
- "experimental/type_traits": "__cplusplus >= 201103L",
- "experimental/unordered_map": "__cplusplus >= 201103L",
- "experimental/unordered_set": "__cplusplus >= 201103L",
- "experimental/utility": "__cplusplus >= 201103L",
- "experimental/vector": "__cplusplus >= 201103L",
-}
-
lit_header_restrictions = {
"barrier": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
"stop_token": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
More information about the libcxx-commits
mailing list