These macros make it easier to log additional information. This is
useful for formatting tests. It also properly disables additional
information when locales are disabled in libc++.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rGf8bed1369421: [libc++][format] Adds new test macros.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
I like where this is going -- we have a few places in the test suite where we want to have nice error messages but we don't have the machinery to. Centralizing this will also make it easier to have good error messages when the platform supports it, and no error message when it doesn't (e.g. when localization or IO are not supported).
libcxx/test/support/test_validation.h | ||
---|---|---|
1 | I would call this assert_macros.h, I think. This would make a parallel with test_macros.h. In fact it would be nice if those test macros could move to test_macros.h, but they can't because they have too many dependencies. I think this is something we should try to address separately. | |
34 | ||
41 | ||
51 | If we dropped the free-form arguments from here and instead expected a string (or a C string), we could drop the dependency on iostream and make this much more widely useful in the test suite. It may also become useful for older tests. You'd probably want to define another helper function that will stringify your arguments and you could use that in your tests. | |
53 | Here and elsewhere. | |
63 | I would make those normal function templates instead. Otherwise one wonders whether there's a reason to define them this way. | |
84 | ||
88 | All of these macros should fully qualify what they call. | |
91 | I think I would name the macros this way: TEST_FAIL(...) TEST_ASSERT(...) TEST_LIBCPP_ASSERT(...) |
libcxx/test/support/test_validation.h | ||
---|---|---|
51 | As discussed I've done so. This still needs an additional include to "stringify" the messages. |
libcxx/test/support/assert_macros.h | ||
---|---|---|
1 ↗ | (On Diff #489038) | We have something different but similar in libcxx/test/support/rapid-cxx-test.h. Have you seen this before? I think it would be nice to unify both. I am not a huge fan of having to use a macro for declaring test cases like we do in rapid-cxx-test.h, however we do already have macros with the same names. I guess my ask here would be to try and avoid introducing a third way of doing assertions in the test suite:
I'd be OK with removing rapid-cxx-test if we can replace its uses by this, or I'd be fine with using rapid-cxx-test.h in the format tests instead. Sorry, I should have thought of rapid-cxx-test.h earlier. |
libcxx/test/support/assert_macros.h | ||
---|---|---|
1 ↗ | (On Diff #489038) | As discussed I wasn't aware of rapid-cxx-test. I had a look and I don't see a way for adding custom messages, which is something I really like to use to make the format errors usable. So my preference would be to remove rapid-cxx-test, if you agree I'll add it to my todo list and pick it up after landing the range patches for LLVM 16. |
libcxx/test/support/assert_macros.h | ||
---|---|---|
1 ↗ | (On Diff #489038) | SGTM. |
I would call this assert_macros.h, I think. This would make a parallel with test_macros.h.
In fact it would be nice if those test macros could move to test_macros.h, but they can't because they have too many dependencies. I think this is something we should try to address separately.