Skip to content

Commit 9bda880

Browse files
authored
test: address test output nondeterminism (#14855)
### 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.
2 parents efbb9ab + ddc63f2 commit 9bda880

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

tests/testsuite/freshness.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,7 @@ feature on
601601
fn rebuild_tests_if_lib_changes() {
602602
let p = project()
603603
.file("src/lib.rs", "pub fn foo() {}")
604-
.file(
605-
"tests/foo.rs",
606-
r#"
607-
extern crate foo;
608-
#[test]
609-
fn test() { foo::foo(); }
610-
"#,
611-
)
604+
.file("tests/foo-test.rs", "extern crate foo;")
612605
.build();
613606

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

620-
p.cargo("build -v").run();
621-
p.cargo("test -v")
622-
.with_status(101)
613+
p.cargo("build").run();
614+
p.cargo("test -v --test foo-test")
623615
.with_stderr_data(str![[r#"
624616
[DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency foo was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
625617
[COMPILING] foo v0.0.1 ([ROOT]/foo)
626-
[RUNNING] `rustc --crate-name foo [..]
627-
[RUNNING] `rustc --crate-name foo [..]
628-
error[E0425]: cannot find function `foo` in crate `foo`
629-
...
630-
[ERROR] could not compile `foo` (test "foo") due to 1 previous error
631-
...
618+
[RUNNING] `rustc --crate-name foo_test [..]`
619+
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
620+
[RUNNING] `[ROOT]/foo/target/debug/deps/foo_test-[HASH][EXE]`
621+
632622
"#]])
633623
.run();
634624
}

tests/testsuite/freshness_checksum.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -765,14 +765,7 @@ feature on
765765
fn rebuild_tests_if_lib_changes() {
766766
let p = project()
767767
.file("src/lib.rs", "pub fn foo() {}")
768-
.file(
769-
"tests/foo.rs",
770-
r#"
771-
extern crate foo;
772-
#[test]
773-
fn test() { foo::foo(); }
774-
"#,
775-
)
768+
.file("tests/foo-test.rs", "extern crate foo;")
776769
.build();
777770

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

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

787-
p.cargo("build -Zchecksum-freshness -v")
780+
p.cargo("build -Zchecksum-freshness")
788781
.masquerade_as_nightly_cargo(&["checksum-freshness"])
789782
.run();
790-
p.cargo("test -Zchecksum-freshness -v")
783+
p.cargo("test -Zchecksum-freshness -v --test foo-test")
791784
.masquerade_as_nightly_cargo(&["checksum-freshness"])
792-
.with_status(101)
793785
.with_stderr_data(str![[r#"
794786
[DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency foo was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
795787
[COMPILING] foo v0.0.1 ([ROOT]/foo)
796-
[RUNNING] `rustc --crate-name foo [..]
797-
[RUNNING] `rustc --crate-name foo [..]
798-
error[E0425]: cannot find function `foo` in crate `foo`
799-
...
800-
[ERROR] could not compile `foo` (test "foo") due to 1 previous error
801-
...
788+
[RUNNING] `rustc --crate-name foo_test [..]`
789+
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
790+
[RUNNING] `[ROOT]/foo/target/debug/deps/foo_test-[HASH][EXE]`
791+
802792
"#]])
803793
.run();
804794
}

tests/testsuite/registry_overlay.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ fn registry_dep_depends_on_new_local_package() {
243243

244244
p.cargo("check")
245245
.overlay_registry(&reg.index_url(), &alt_path)
246-
.with_stderr_data(str![[r#"
246+
.with_stderr_data(
247+
str![[r#"
247248
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
248249
[LOCKING] 3 packages to latest compatible versions
249250
[ADDING] workspace-package v0.0.1 (available: v0.1.1)
@@ -257,7 +258,9 @@ fn registry_dep_depends_on_new_local_package() {
257258
[CHECKING] foo v0.0.1 ([ROOT]/foo)
258259
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
259260
260-
"#]])
261+
"#]]
262+
.unordered(),
263+
)
261264
.run();
262265
}
263266

0 commit comments

Comments
 (0)