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

tests calling date command set env LC_ALL #1315

Merged

Conversation

jtmoon79
Copy link
Contributor

@jtmoon79 jtmoon79 commented Sep 25, 2023

For tests calling date Unix tool, also set
environment variable LC_ALL=c to make more sure to avoid locality problems.

On systems with environment variable and value LC_ALL=en_US.utf8 set then the test try_verify_against_date_command_format may fail.

$ LC_ALL=en_US.utf8 cargo test
...
test try_verify_against_date_command_format ... FAILED
test try_verify_against_date_command ... ok

failures:

---- try_verify_against_date_command_format stdout ----
LANG: "en_US.UTF-8"
command: "/usr/bin/date" --version
stdout: "date (GNU coreutils) 8.32\nCopyright (C) 2020 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nWritten by David MacKenzie.\n"
stderr: ""
thread 'try_verify_against_date_command_format' panicked at 'assertion failed: `(left == right)`
  left: `"d01 D01/01/70 F1970-01-01 H12 I12 j001 k12 l12 m01 M11 S13 T12:11:13 u4 U00 w4 W00 X12:11:13 PM y70 Y1970 z-08:00\n"`,
 right: `"d01 D01/01/70 F1970-01-01 H12 I12 j001 k12 l12 m01 M11 S13 T12:11:13 u4 U00 w4 W00 X12:11:13 y70 Y1970 z-08:00\n"`', tests/dateutils.rs:144:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This failure occurred on Ubuntu 22.04, rust 1.72.0, date date (GNU coreutils) 8.32.

PR #1090 sets environment variable LANG=c. Apparently that is not always sufficient.

Relates to Issue #1060, PR #1090

For tests calling `date` Unix tool, also set
environment variable `LC_ALL=c` to make more sure to
avoid locality problems.
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #1315 (9087a17) into 0.4.x (a47e0e3) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##            0.4.x    #1315   +/-   ##
=======================================
  Coverage   91.24%   91.24%           
=======================================
  Files          38       38           
  Lines       17062    17062           
=======================================
  Hits        15568    15568           
  Misses       1494     1494           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jtmoon79 jtmoon79 marked this pull request as ready for review September 25, 2023 01:34
@pitdicker
Copy link
Collaborator

I would like to run a quick test locally before approving (later today or tomorrow, when near a Linux pc).

An alternative to setting the locale is to use format_localized and test the unstable-locales feature while at it.

@pitdicker pitdicker merged commit e116f5c into chronotope:0.4.x Sep 26, 2023
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants