This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Improves locale validation.
Needs ReviewPublic

Authored by Mordante on Jan 22 2023, 9:51 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Summary

This makes it possible to query the status of a locale in a test. This
allows to use a locale conditionally instead of disabling an entire test
when a locale is missing.

The change is only applied to tests that were disabled in
https://reviews.llvm.org/rGd819703410c2362cbafb60117dab45b182d8b13d

Diff Detail

Event Timeline

Mordante created this revision.Jan 22 2023, 9:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 22 2023, 9:51 AM
Herald added a subscriber: arichardson. · View Herald Transcript
Mordante requested review of this revision.Jan 22 2023, 9:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 22 2023, 9:51 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

I think this makes sense. However, I would avoid adding new compiler flags since we try to keep our command-lines as minimal as possible in the test suite.

Instead, I would suggest creating a general mechanism for generating a test_config.h header (which would be the test-suite equivalent of __config_site) and defining those macros there. This header would be generated at lit configuration time (not at CMake configuration time like the __config_site header). This mechanism would be a bit more general and I think it could even be used for other purposes, for example glibc-old-ru_RU-decimal-point could probably be removed in favor of a macro, and we'd gain test coverage in libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp.

We don't have a precedent for doing this in our test suite, so we'll have to design a way to do it.

Mordante updated this revision to Diff 492148.Jan 25 2023, 9:12 AM

Try a different approach as discussed during review.

Note this is still a proof-of-concept version not a clean patch.

libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
607

Debug to validate the changes work locally.

libcxx/utils/libcxx/test/dsl.py
524 ↗(On Diff #492148)

This is a bit hacky to add the path to the includes. I don't want to pollute the source directory with this file.

arichardson added inline comments.Jan 26 2023, 12:00 AM
libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h
590

How about generating a header with these macros set to 0/1, then typos could be caught by -Werror=undef?

Mordante added inline comments.Jan 30 2023, 10:56 AM
libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h
590

Typically we use a different way to define these macros

#  ifndef TEST_HAS_NO_LOCALE_fr_FR_UTF_8

I just didn't do that yet to discuss whether this basic approach is feasible.
Then the macro doesn't need 0/1.

Thanks for looking into this! I am not a huge fan of using the config object to keep state around, but I understand why you had to do it. I'll look into alternative solutions, please give me a bit of time -- let's talk about this again after Issaquah.

libcxx/test/support/test_macros.h
25 ↗(On Diff #492148)

I would call the header test_config_site.h.

26–30 ↗(On Diff #492148)

I would include this unconditionally. If our setup is messed up and there's no config_site.h, we want to know about it instead of silently having all these macros be undefined.

libcxx/utils/libcxx/test/dsl.py
508–514 ↗(On Diff #492148)