TeXitoi / structopt

Parse command line arguments by defining a struct.
Other
2.7k stars 149 forks source link

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

Open cicilzx opened 4 months ago

cicilzx commented 4 months ago

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.
TeXitoi commented 4 months ago

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