Skip to content

Conversation

AMDmi3
Copy link

@AMDmi3 AMDmi3 commented Sep 18, 2025

Test fail with recent rust:

running 1 test
test multiple_bin_fail ... FAILED

failures:

---- multiple_bin_fail stdout ----

thread 'multiple_bin_fail' (2462685) panicked at /home/marakasov/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/assert_cli-0.6.3/src/assert.rs:441:13:
Assertion failed for `cargo run --quiet -- readme --project-root tests/multiple-bin-fail`
with: Unexpected stderr

with: Didn't match.
diff=
 ``+warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/config/badges.rs:181:26
    |
181 | fn percent_encode(input: &str) -> pe::PercentEncode {
    |                          ^^^^     ^^^^^^^^^^^^^^^^^ the same lifetime is hidden here
    |                          |
    |                          the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
181 | fn percent_encode(input: &str) -> pe::PercentEncode<'_> {
    |                                                    ++++

 Error: Multiple binaries found, choose one: [src/entry1.rs, src/entry2.rs]

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failures:
multiple_bin_fail


This is caused by two problems
- There is compilation warning (addressed in #114)
- `assert_cli` calls `cargo run` instead of calling a real crate binary, which leads to cargo stderr (which contains a warning) prepended to command output. Since `assert_cli` is deprecated, switch to `assert_cmd` everywhere. Because unlike `assert_cli` it does not ignore leading/trailing whitespace in expected stderr/stdout contents, leading newlines had to be removed in inline expected data. If you find it undesirable, it can be fixed by adding `trim_start` or switching to `indoc` (more convenient multiline string literals) or `insta` (snapshot tests - keeps expected data in separate files and assists in updating them).

assert_cli is deprecated and behaves incorrectly - compilation
warnings are mixed up with tested command stderr
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.

1 participant