Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions tests/testsuite/build.rs

@weihanglo weihanglo Jul 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my previous comment #17203 (comment)

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I misunderstood the main concern.I'll deepseek!

Original file line number Diff line number Diff line change
Expand Up @@ -874,17 +874,9 @@ fn cargo_compile_with_invalid_code_in_deps() {
.build();
p.cargo("build")
.with_status(101)
.with_stderr_data(
str![[r#"
[COMPILING] bar v0.1.0 ([ROOT]/bar)
[COMPILING] baz v0.1.0 ([ROOT]/baz)
[ERROR] could not compile `bar` (lib) due to 1 previous error
[ERROR] could not compile `baz` (lib) due to 1 previous error
...

"#]]
.unordered(),
)
.with_stderr_contains("[COMPILING] bar v0.1.0 [..]")

@weihanglo weihanglo Jul 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

We probably don't want to go back and use contains methods. Please see

//! # Deprecated comparisons
//!
//! Cargo's tests are in transition from internal-only pattern and normalization routines used in
//! asserts like [`crate::Execs::with_stdout_contains`] to [`assert_e2e`] and [`assert_ui`].
//!

and

/// Verifies that stderr contains the given contiguous lines somewhere in
/// its output.
///
/// See [`compare`] for supported patterns.
///
/// <div class="warning">
///
/// Prefer [`Execs::with_stderr_data`] where possible.
/// - `expected` cannot be snapshotted
/// - `expected` can end up being ambiguous, causing the assertion to succeed when it should fail
///
/// </div>
pub fn with_stderr_contains<S: ToString>(&mut self, expected: S) -> &mut Self {
self.expect_stderr_contains.push(expected.to_string());
self
}

Have you reproduced it? Could you find other means to fix it, for example with -j1?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Switched to -j1 to force serial compilation and restored with_stderr_data -- makes the output deterministic without needing partial matches. PTAL.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other way is this:

[COMPILING] ba[..] v0.1.0 ([ROOT]/ba[..])
...
[ERROR] could not compile `ba[..]` (lib) due to 1 previous error
...

It may work even without -j1. I haven't checked why this test needs two dependencies though.

.with_stderr_contains("[COMPILING] baz v0.1.0 [..]")
.with_stderr_contains("[ERROR] could not compile [..]")
.run();
}

Expand Down