structopt icon indicating copy to clipboard operation
structopt copied to clipboard

Execution of a test case in `flatten.rs` at a particular compilation optimization level appears to be failed

Open cicilzx opened this issue 1 year ago • 3 comments

I find that when using -C opt-level=0 as the compilation optimization level, all of the test cases can pass. However, if we use -C opt-level=1/2/3/s/z, an error would be triggered.

For example, using the command:

RUSTFLAGS="-Z mir-opt-level=0 -C opt-level=1" cargo test

The output is as below:

Running tests/flatten.rs (target/debug/deps/flatten-01ee475df42d1a15)

running 6 tests
error: The argument '<arg>' was provided more than once, but cannot be used multiple times

USAGE:
    test <arg>

For more information try --help
error: test failed, to rerun pass `--test flatten`

Caused by:
  process didn't exit successfully: `/local/home/zixliu/crates/structopt/target/debug/deps/flatten-01ee475df42d1a15` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.

cicilzx avatar May 05 '24 09:05 cicilzx

Looks like a rust test bug. The test is should_panic, it panics, but the test fails in release.

Can be reproduced on stable with cargo test --release -- --test flatten_twice

TeXitoi avatar May 05 '24 10:05 TeXitoi

This isn't a bug. The panic comes from clap here and only happens when debug assertions are enabled. When they aren't enabled, the code proceeds to the alternative error path which calls std::process::exit.

tamird avatar Sep 30 '24 19:09 tamird

#542 fixes this.

tamird avatar Oct 13 '24 12:10 tamird