Skip to content

Commit

Permalink
Fix some test output validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Nov 15, 2023
1 parent 6658e1a commit da13ff3
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 66 deletions.
7 changes: 5 additions & 2 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2167,8 +2167,11 @@ fn doc_lib_true() {

p.cargo("doc -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint")
.with_stdout("")
.with_stderr(
"\
[FINISHED] [..]
[GENERATED] [CWD]/target/doc/foo/index.html",
)
.run();

assert!(p.root().join("target/doc").is_dir());
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2959,12 +2959,12 @@ fn freshness_ignores_excluded() {

// Smoke test to make sure it doesn't compile again
println!("first pass");
foo.cargo("build").with_stdout("").run();
foo.cargo("build").with_stderr("[FINISHED] [..]").run();

// Modify an ignored file and make sure we don't rebuild
println!("second pass");
foo.change_file("src/bar.rs", "");
foo.cargo("build").with_stdout("").run();
foo.cargo("build").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down Expand Up @@ -3064,7 +3064,7 @@ fn recompile_space_in_name() {
.build();
foo.cargo("build").run();
foo.root().move_into_the_past();
foo.cargo("build").with_stdout("").run();
foo.cargo("build").with_stderr("[FINISHED] [..]").run();
}

#[cfg(unix)]
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,6 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() {
.run();

p.cargo("build -v")
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint=info")
.with_stderr(
"\
[FRESH] foo v0.5.0 ([..])
Expand Down
15 changes: 10 additions & 5 deletions tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ fn different_dir() {
p.cargo("build").run();
assert!(p.build_dir().is_dir());

p.cargo("clean").cwd("src").with_stdout("").run();
p.cargo("clean")
.cwd("src")
.with_stderr("[REMOVED] [..]")
.run();
assert!(!p.build_dir().is_dir());
}

Expand Down Expand Up @@ -82,7 +85,7 @@ fn clean_multiple_packages() {

p.cargo("clean -p d1 -p d2")
.cwd("src")
.with_stdout("")
.with_stderr("[REMOVED] [..]")
.run();
assert!(p.bin("foo").is_file());
assert!(!d1_path.is_file());
Expand Down Expand Up @@ -227,7 +230,9 @@ fn clean_release() {
p.cargo("build --release").run();

p.cargo("clean -p foo").run();
p.cargo("build --release").with_stdout("").run();
p.cargo("build --release")
.with_stderr("[FINISHED] [..]")
.run();

p.cargo("clean -p foo --release").run();
p.cargo("build --release")
Expand Down Expand Up @@ -355,7 +360,7 @@ fn clean_git() {
.build();

p.cargo("build").run();
p.cargo("clean -p dep").with_stdout("").run();
p.cargo("clean -p dep").with_stderr("[REMOVED] [..]").run();
p.cargo("build").run();
}

Expand All @@ -380,7 +385,7 @@ fn registry() {
Package::new("bar", "0.1.0").publish();

p.cargo("build").run();
p.cargo("clean -p bar").with_stdout("").run();
p.cargo("clean -p bar").with_stderr("[REMOVED] [..]").run();
p.cargo("build").run();
}

Expand Down
18 changes: 15 additions & 3 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ fn doc_twice() {
)
.run();

p.cargo("doc").with_stdout("").run();
p.cargo("doc")
.with_stderr(
"\
[FINISHED] [..]
[GENERATED] [CWD]/target/doc/foo/index.html
",
)
.run();
}

#[cargo_test]
Expand Down Expand Up @@ -118,9 +125,14 @@ fn doc_deps() {
assert_eq!(p.glob("target/debug/**/*.rlib").count(), 0);
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 1);

// Make sure it doesn't recompile.
p.cargo("doc")
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint")
.with_stdout("")
.with_stderr(
"\
[FINISHED] [..]
[GENERATED] [CWD]/target/doc/foo/index.html
",
)
.run();

assert!(p.root().join("target/doc").is_dir());
Expand Down
17 changes: 12 additions & 5 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,14 @@ fn cyclic_feature2() {
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("check").with_stdout("").run();
p.cargo("check")
.with_stderr(
"\
[CHECKING] foo [..]
[FINISHED] [..]
",
)
.run();
}

#[cargo_test]
Expand Down Expand Up @@ -1047,8 +1054,8 @@ fn no_rebuild_when_frobbing_default_feature() {
.build();

p.cargo("check").run();
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down Expand Up @@ -1098,8 +1105,8 @@ fn unions_work_with_no_default_features() {
.build();

p.cargo("check").run();
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn no_deps() {
.file("src/a.rs", "")
.build();

p.cargo("fetch").with_stdout("").run();
p.cargo("fetch").with_stderr("").run();
}

#[cargo_test]
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn modifying_and_moving() {
)
.run();

p.cargo("build").with_stdout("").run();
p.cargo("build").with_stderr("[FINISHED] [..]").run();
p.root().move_into_the_past();
p.root().join("target").move_into_the_past();

Expand Down Expand Up @@ -223,7 +223,7 @@ fn changing_lib_features_caches_targets() {
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
.run();

p.cargo("build").with_stdout("").run();
p.cargo("build").with_stderr("[FINISHED] [..]").run();

p.cargo("build --features foo")
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
Expand Down Expand Up @@ -666,7 +666,7 @@ fn rerun_if_changed_in_dep() {
.build();

p.cargo("build").run();
p.cargo("build").with_stdout("").run();
p.cargo("build").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ fn cargo_update_generate_lockfile() {

let lockfile = p.root().join("Cargo.lock");
assert!(!lockfile.is_file());
p.cargo("update").with_stdout("").run();
p.cargo("update").with_stderr("").run();
assert!(lockfile.is_file());

fs::remove_file(p.root().join("Cargo.lock")).unwrap();

assert!(!lockfile.is_file());
p.cargo("update").with_stdout("").run();
p.cargo("update").with_stderr("").run();
assert!(lockfile.is_file());
}

Expand Down
31 changes: 19 additions & 12 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,12 @@ fn recompilation() {
.run();

// Don't recompile the second time
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();

// Modify a file manually, shouldn't trigger a recompile
git_project.change_file("src/bar.rs", r#"pub fn bar() { println!("hello!"); }"#);

p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();

p.cargo("update")
.with_stderr(&format!(
Expand All @@ -605,7 +605,7 @@ fn recompilation() {
))
.run();

p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();

// Commit the changes and make sure we don't trigger a recompile because the
// lock file says not to change
Expand All @@ -614,7 +614,7 @@ fn recompilation() {
git::commit(&repo);

println!("compile after commit");
p.cargo("check").with_stdout("").run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
p.root().move_into_the_past();

// Update the dependency and carry on!
Expand All @@ -638,7 +638,7 @@ fn recompilation() {
.run();

// Make sure clean only cleans one dep
p.cargo("clean -p foo").with_stdout("").run();
p.cargo("clean -p foo").with_stderr("[REMOVED] [..]").run();
p.cargo("check")
.with_stderr(
"[CHECKING] foo v0.5.0 ([CWD])\n\
Expand Down Expand Up @@ -742,7 +742,14 @@ fn update_with_shared_deps() {

// By default, not transitive updates
println!("dep1 update");
p.cargo("update dep1").with_stdout("").run();
p.cargo("update dep1")
.with_stderr(
"\
[UPDATING] git repository [..]
[UPDATING] bar v0.5.0 [..]
",
)
.run();

// Don't do anything bad on a weird --precise argument
println!("bar bad precise update");
Expand All @@ -766,7 +773,7 @@ Caused by:
println!("bar precise update");
p.cargo("update bar --precise")
.arg(&old_head.to_string())
.with_stdout("")
.with_stderr("[UPDATING] bar v0.5.0 [..]")
.run();

// Updating recursively should, however, update the repo.
Expand Down Expand Up @@ -1496,12 +1503,12 @@ fn git_build_cmd_freshness() {

// Smoke test to make sure it doesn't compile again
println!("first pass");
foo.cargo("check").with_stdout("").run();
foo.cargo("check").with_stderr("[FINISHED] [..]").run();

// Modify an ignored file and make sure we don't rebuild
println!("second pass");
foo.change_file("src/bar.rs", "");
foo.cargo("check").with_stdout("").run();
foo.cargo("check").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down Expand Up @@ -1636,7 +1643,7 @@ fn git_repo_changing_no_rebuild() {

// And now for the real test! Make sure that p1 doesn't get rebuilt
// even though the git repo has changed.
p1.cargo("check").with_stdout("").run();
p1.cargo("check").with_stderr("[FINISHED] [..]").run();
}

#[cargo_test]
Expand Down Expand Up @@ -1741,7 +1748,7 @@ fn fetch_downloads() {
))
.run();

p.cargo("fetch").with_stdout("").run();
p.cargo("fetch").with_stderr("").run();
}

#[cargo_test]
Expand Down Expand Up @@ -1786,7 +1793,7 @@ fn fetch_downloads_with_git2_first_then_with_gitoxide_and_vice_versa() {
.run();

Package::new("bar", "1.0.0").publish(); // trigger a crates-index change.
p.cargo("fetch").with_stdout("").run();
p.cargo("fetch").with_stderr("").run();
}

#[cargo_test]
Expand Down
Loading

0 comments on commit da13ff3

Please sign in to comment.