This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: run tests with UTF-8 encoding
ClosedPublic

Authored by thopre on Oct 16 2019, 8:46 AM.

Details

Summary

Click requires to be invoked with a default encoding of UTF-8. If not,
it exists the program with an error. This commit sets the LANG
environment variable for running lit tests to the system locale if it is
a UTF-8 capable one or en_US.UTF-8 as a fallback. This allows the test
to run on systems where en_US.UTF-8 is not installed (such as some
container images) but the default locale is UTF-8 capable.

Event Timeline

thopre created this revision.Oct 16 2019, 8:46 AM

I don't think that this is a clear "win". Users may have UTF-8 capable locales not ending in ".UTF-8" and also not have a usable en_US.UTF-8 locale. It might be nice for some people, but this can actually break others. I don't see an issue with asking users to specify an appropriate value of LANG for their environment.

thopre added a comment.Dec 4 2019, 7:00 AM

I don't think that this is a clear "win". Users may have UTF-8 capable locales not ending in ".UTF-8" and also not have a usable en_US.UTF-8 locale. It might be nice for some people, but this can actually break others. I don't see an issue with asking users to specify an appropriate value of LANG for their environment.

I can't quite remember but I think the problem is that lit starts from a clean environment to have consistent output (if using the user's environment error message might vary accross systems which would fail lots of tests). AFAIK LNT doesn't have localized error message but it fails to run if the locale is not UTF-8 (or perhaps any unicode locale).

[Sorry for the late answer, I missed that feedback.]

I can't quite remember but I think the problem is that lit starts from a clean environment to have consistent output (if using the user's environment error message might vary accross systems which would fail lots of tests). AFAIK LNT doesn't have localized error message but it fails to run if the locale is not UTF-8 (or perhaps any unicode locale).

That's my understanding regarding LNT as well; however, the "clean environment" seems to be what is being adjusted here based on the user's environment. My suggestion is to trust the user's environment by passing it through verbatim (since the patch already trusts the user if the locale name ends with .UTF-8). The user has to specify an appropriate environment anyway when running LNT outside of tests.

thopre updated this revision to Diff 232145.Dec 4 2019, 8:25 AM

Unconditionally set LANG in lit environment to host's LANG

This revision is now accepted and ready to land.Dec 4 2019, 8:30 AM
thopre closed this revision.Dec 5 2019, 4:39 AM