[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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
""")
|
||||
|
||||
@@ -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 @@ for header in public_headers:
|
||||
// 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}
|
||||
""")
|
||||
|
||||
@@ -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
|
||||
""")
|
||||
|
||||
@@ -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 @@ for header in public_headers:
|
||||
|
||||
print(f"""\
|
||||
//--- {header}.compile.pass.cpp
|
||||
#include <__config>
|
||||
{test_condition_begin}
|
||||
{lit_header_restrictions.get(header, '')}
|
||||
|
||||
#include <{header}>
|
||||
{checks}
|
||||
{test_condition_end}
|
||||
""")
|
||||
|
||||
@@ -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 @@ for header in public_headers:
|
||||
// TODO: Investigate this failure
|
||||
// UNSUPPORTED{BLOCKLIT}: LIBCXX-FREEBSD-FIXME
|
||||
|
||||
#include <__config>
|
||||
{test_condition_begin}
|
||||
{lit_header_restrictions.get(header, '')}
|
||||
|
||||
#include <{header}>
|
||||
{test_condition_end}
|
||||
""")
|
||||
|
||||
@@ -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 @@ for header in public_headers:
|
||||
#define min NASTY_MACRO
|
||||
#define max NASTY_MACRO
|
||||
|
||||
#include <__config>
|
||||
{test_condition_begin}
|
||||
#include <{header}>
|
||||
{test_condition_end}
|
||||
""")
|
||||
|
||||
@@ -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}
|
||||
""")
|
||||
|
||||
@@ -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 @@ for header in private_headers:
|
||||
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}
|
||||
""")
|
||||
|
||||
@@ -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 @@ else:
|
||||
|
||||
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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user