forked from OSchip/llvm-project
[libc++] Make it easier to add new restrictions for feature-test macro tests
This commit is contained in:
parent
a037059577
commit
c2279b262f
|
@ -483,6 +483,18 @@ feature_test_macros = sorted([ add_version_header(x) for x in [
|
|||
},
|
||||
]], key=lambda tc: tc["name"])
|
||||
|
||||
# Map from each header to the Lit annotations that should be used for
|
||||
# tests that include that header.
|
||||
#
|
||||
# For example, when threads are not supported, any feature-test-macro test
|
||||
# that includes <thread> should be marked as UNSUPPORTED, because including
|
||||
# <thread> is a hard error in that case.
|
||||
lit_markup = {
|
||||
"atomic": ["UNSUPPORTED: libcpp-has-no-threads"],
|
||||
"shared_mutex": ["UNSUPPORTED: libcpp-has-no-threads"],
|
||||
"thread": ["UNSUPPORTED: libcpp-has-no-threads"],
|
||||
}
|
||||
|
||||
def get_std_dialects():
|
||||
std_dialects = ['c++14', 'c++17', 'c++2a']
|
||||
return list(std_dialects)
|
||||
|
@ -734,10 +746,6 @@ def generate_synopsis(test_list):
|
|||
result += "*/"
|
||||
return result
|
||||
|
||||
def is_threading_header_unsafe_to_include(h):
|
||||
# NOTE: "<mutex>" does not blow up when included without threads.
|
||||
return h in ['atomic', 'shared_mutex']
|
||||
|
||||
def produce_tests():
|
||||
headers = set([h for tc in feature_test_macros for h in tc["headers"]])
|
||||
for h in headers:
|
||||
|
@ -746,9 +754,7 @@ def produce_tests():
|
|||
for tc in test_list:
|
||||
assert 'unimplemented' in tc.keys()
|
||||
continue
|
||||
test_tags = ""
|
||||
if is_threading_header_unsafe_to_include(h):
|
||||
test_tags += '\n// UNSUPPORTED: libcpp-has-no-threads\n'
|
||||
markup = '\n'.join('// ' + tag for tag in lit_markup.get(h, []))
|
||||
test_body = \
|
||||
"""//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
@ -760,7 +766,7 @@ def produce_tests():
|
|||
//
|
||||
// WARNING: This test was generated by {script_name}
|
||||
// and should not be edited manually.
|
||||
{test_tags}
|
||||
{markup}
|
||||
// <{header}>
|
||||
|
||||
// Test the feature test macros defined by <{header}>
|
||||
|
@ -791,7 +797,7 @@ def produce_tests():
|
|||
int main(int, char**) {{ return 0; }}
|
||||
""".format(script_name=script_name,
|
||||
header=h,
|
||||
test_tags=test_tags,
|
||||
markup=('\n{}\n'.format(markup) if markup else ''),
|
||||
synopsis=generate_synopsis(test_list),
|
||||
cxx11_tests=generate_std_test(test_list, 'c++11').strip(),
|
||||
cxx14_tests=generate_std_test(test_list, 'c++14').strip(),
|
||||
|
|
Loading…
Reference in New Issue