Skip to content

Commit

Permalink
test: address test output nondeterminism (#14855)
Browse files Browse the repository at this point in the history
### What does this PR try to resolve?

Some nondeterminism test output was found in other pull requestss

The first one was found in
<#14854>

The second one was found in
#14853

### How should we test and review this PR?

CI passes.
  • Loading branch information
epage authored Nov 23, 2024
2 parents efbb9ab + ddc63f2 commit 9bda880
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
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

0 comments on commit 9bda880

Please sign in to comment.