Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: address test output nondeterminism #14855

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 7 additions & 17 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,7 @@ feature on
fn rebuild_tests_if_lib_changes() {
let p = project()
.file("src/lib.rs", "pub fn foo() {}")
.file(
"tests/foo.rs",
r#"
extern crate foo;
#[test]
fn test() { foo::foo(); }
"#,
)
.file("tests/foo-test.rs", "extern crate foo;")
.build();

p.cargo("build").run();
Expand All @@ -617,18 +610,15 @@ fn rebuild_tests_if_lib_changes() {
sleep_ms(1000);
p.change_file("src/lib.rs", "");

p.cargo("build -v").run();
p.cargo("test -v")
.with_status(101)
p.cargo("build").run();
p.cargo("test -v --test foo-test")
.with_stderr_data(str![[r#"
[DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency foo was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[RUNNING] `rustc --crate-name foo [..]
[RUNNING] `rustc --crate-name foo [..]
error[E0425]: cannot find function `foo` in crate `foo`
...
[ERROR] could not compile `foo` (test "foo") due to 1 previous error
...
[RUNNING] `rustc --crate-name foo_test [..]`
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] `[ROOT]/foo/target/debug/deps/foo_test-[HASH][EXE]`
"#]])
.run();
}
Expand Down
24 changes: 7 additions & 17 deletions tests/testsuite/freshness_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,14 +765,7 @@ feature on
fn rebuild_tests_if_lib_changes() {
let p = project()
.file("src/lib.rs", "pub fn foo() {}")
.file(
"tests/foo.rs",
r#"
extern crate foo;
#[test]
fn test() { foo::foo(); }
"#,
)
.file("tests/foo-test.rs", "extern crate foo;")
.build();

p.cargo("build -Zchecksum-freshness")
Expand All @@ -784,21 +777,18 @@ fn rebuild_tests_if_lib_changes() {

p.change_file("src/lib.rs", "");

p.cargo("build -Zchecksum-freshness -v")
p.cargo("build -Zchecksum-freshness")
.masquerade_as_nightly_cargo(&["checksum-freshness"])
.run();
p.cargo("test -Zchecksum-freshness -v")
p.cargo("test -Zchecksum-freshness -v --test foo-test")
.masquerade_as_nightly_cargo(&["checksum-freshness"])
.with_status(101)
.with_stderr_data(str![[r#"
[DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency foo was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[RUNNING] `rustc --crate-name foo [..]
[RUNNING] `rustc --crate-name foo [..]
error[E0425]: cannot find function `foo` in crate `foo`
...
[ERROR] could not compile `foo` (test "foo") due to 1 previous error
...
[RUNNING] `rustc --crate-name foo_test [..]`
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] `[ROOT]/foo/target/debug/deps/foo_test-[HASH][EXE]`

"#]])
.run();
}
Expand Down
7 changes: 5 additions & 2 deletions tests/testsuite/registry_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ fn registry_dep_depends_on_new_local_package() {

p.cargo("check")
.overlay_registry(&reg.index_url(), &alt_path)
.with_stderr_data(str![[r#"
.with_stderr_data(
str![[r#"
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
[LOCKING] 3 packages to latest compatible versions
[ADDING] workspace-package v0.0.1 (available: v0.1.1)
Expand All @@ -257,7 +258,9 @@ fn registry_dep_depends_on_new_local_package() {
[CHECKING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
"#]]
.unordered(),
)
.run();
}

Expand Down