Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset locale to "C" after charset test #39648

Merged
merged 1 commit into from
Apr 18, 2020

Conversation

wapcaplet
Copy link
Contributor

Summary

SUMMARY: none

Purpose of change

The catacharset_test includes a call to setlocale( LC_ALL, "" ), which uses the locale from the current environment (which may or may not be English).

Suspect this as a possible cause of #39423, where other test cases are failing due to the use of locale-specific numerical formatting (like "." vs "," for the decimal separator).

Describe the solution

Explicitly setting locale back to "C" after these tests should avoid the problem, because this "is a rather neutral locale with minimal locale information that allows the result of programs to be predictable." setlocale

Describe alternatives you've considered

None

Testing

I tried and failed to reproduce the original issue by modifying my own system locale (and I hesitated to dive deeper due to my own flimsy grasp of non-English languages). So I cannot say whether this change will fix the bug, but I made sure tests/cata_test [catacharset],[tname] and tests/cata_test [catacharset],string_formatter are still passing on my own Ubuntu box with English/US locale.

Even if it doesn't fix the bug, I think it's a worthwhile post-test cleanup.

Additional context

Credit to @jbytheway

These tests include a call to `setlocale( LC_ALL, "" )`, which uses the
locale from the current environment (which may or may not be English).

Suspect this as a possible cause of CleverRaven#39423, where other test cases are
failing due to the use of locale-specific numerical formatting (like "."
vs "," for the decimal separator).

Explicitly setting locale back to "C" after these tests should avoid the
problem, because this "is a rather neutral locale with minimal locale
information that allows the result of programs to be predictable."
(http://www.cplusplus.com/reference/clocale/setlocale/)
@ifreund ifreund added Code: Tests Measurement, self-control, statistics, balancing. <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` labels Apr 17, 2020
@olanti-p
Copy link
Contributor

olanti-p commented Apr 18, 2020

Fixed it for Ubuntu with Russian region

@kevingranade kevingranade merged commit c99527b into CleverRaven:master Apr 18, 2020
@wapcaplet wapcaplet deleted the reset-locale branch April 24, 2020 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants