rustcoreutils / posixutils-rs

Core POSIX command line utilities in safe Rust
MIT License
314 stars 24 forks source link

iconv::iconv_no_flag_data_input test fails on Linux #336

Open jgarzik opened 5 days ago

jgarzik commented 5 days ago

The iconv::iconv_no_flag_data_input test works in CI and on local MacOS, but fails on Ubuntu Linux LTS local testing:

---- iconv::iconv_no_flag_data_input stdout ----
thread 'iconv::iconv_no_flag_data_input' panicked at plib/src/testing.rs:99:5:
assertion `left == right` failed
  left: []
 right: [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
   2: core::panicking::assert_failed_inner
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:410:17
   3: core::panicking::assert_failed
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:365:5
   4: plib::testing::run_test_u8
             at /home/jgarzik/repo/posixutils-rs/plib/src/testing.rs:99:5
   5: i18n_tests::iconv::iconv_test
             at ./tests/iconv/mod.rs:18:5
   6: i18n_tests::iconv::iconv_no_flag_data_input
             at ./tests/iconv/mod.rs:31:5
   7: i18n_tests::iconv::iconv_no_flag_data_input::{{closure}}
             at ./tests/iconv/mod.rs:29:30
   8: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
   9: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

failures:
    iconv::iconv_no_flag_data_input

test result: FAILED. 34 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.18s

cc @rishadbaniya

rishadbaniya commented 5 days ago

thats interesting, i'll take a look into this

rishadbaniya commented 5 days ago

btw @jgarzik what's the default locale in the tested machine?

jgarzik commented 5 days ago

btw @jgarzik what's the default locale in the tested machine?

How to display the default locale? Here's some info, LMK if this is not sufficient,

$ locale -a
C
C.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US
en_US.iso88591
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

$ locale
LANG=en_US
LANGUAGE=
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
rishadbaniya commented 5 days ago

ah..i see that's interesting.. usually this LANG contains the default locale information (including the default encoding as well) in arch machine it looks like this

LANG=en_US.UTF-8
LC_CTYPE=
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

and i used the LANG environment variable to get that encoding in the iconv binary, and in the no flag test the iconv uses that environment variable to get the encoding information

It seems i didn't realize the locale information might not give "encoding" information or i'm missing something..i'll do some research on this...and send a PR fix