Idea from D92525.
This script globs include/ directory and updates the tests in test/libcxx.
This patch does not generate module.modulemap nor CMakeLists.txt.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG6fd5a94eeb9a: [libc++] Add a script to automatize updating test for a new header.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/docs/Contributing.rst | ||
---|---|---|
26–31 | That's a drive-by fix. |
Another approach for generating those tests would be to instead insert just the header part between two markers. This would allow writing the new test mostly outside of the script, and only the header part would be inserted (between the markers) by the script. Something like this:
// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Test that we can include each header in two TU's and link them together. // RUN: %{cxx} -c %s -o %t.first.o %{flags} %{compile_flags} // RUN: %{cxx} -c %s -o %t.second.o -DWITH_MAIN %{flags} %{compile_flags} // RUN: %{cxx} -o %t.exe %t.first.o %t.second.o %{flags} %{link_flags} // RUN: %{run} // GCC 5 pretends it supports C++17 features, but some features like static_assert // without a message are not actually supported. This causes some headers to fail // when included. // UNSUPPORTED: gcc-5 && c++17 // Prevent <ext/hash_map> from generating deprecated warnings for this test. #if defined(__DEPRECATED) #undef __DEPRECATED #endif ////////////////////////////////////////////////////////////////////////////// // BEGIN-GENERATED-HEADERS ////////////////////////////////////////////////////////////////////////////// // ... This content is generated ... ////////////////////////////////////////////////////////////////////////////// // END-GENERATED-HEADERS ////////////////////////////////////////////////////////////////////////////// #if defined(WITH_MAIN) int main(int, char**) { return 0; } #endif
The main benefit of doing that is that the script could stay simple as we add more tests, and adding a new test might be only a matter of adding the path of the test in the script.
We'd have to find a way to accommodate stuff like using TEST_MACROS(); after each include, but one way we could do that is by always defining some macro like TEST_POST_INCLUDES in the test file before the generated content. It would always be empty, except when you want to include something after each header.
Do you have thoughts about this?
libcxx/docs/Contributing.rst | ||
---|---|---|
29 | That doesn't seem right -- you don't need to modify <version> yourself, the script does it. Am I misunderstanding what you meant here? | |
38 | I don't think it's necessary to keep the list of tests -- it'll only get out of date. |
Modify files between boundary markers.
I haven't modified the way TEST_MACROS() stuff is done though. I'd be inclined to rethink it if it becomes a problem and we have more tests.
That doesn't seem right -- you don't need to modify <version> yourself, the script does it. Am I misunderstanding what you meant here?