diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /src/tools/cargo/tests/testsuite/clean.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/clean.rs')
-rw-r--r-- | src/tools/cargo/tests/testsuite/clean.rs | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/src/tools/cargo/tests/testsuite/clean.rs b/src/tools/cargo/tests/testsuite/clean.rs index fbb4d3e5b..913bf19cb 100644 --- a/src/tools/cargo/tests/testsuite/clean.rs +++ b/src/tools/cargo/tests/testsuite/clean.rs @@ -1,5 +1,6 @@ //! Tests for the `cargo clean` command. +use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::Package; use cargo_test_support::{ basic_bin_manifest, basic_manifest, git, main_file, project, project_in, rustc_host, @@ -33,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()); } @@ -81,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()); @@ -226,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") @@ -354,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(); } @@ -379,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(); } @@ -805,15 +811,6 @@ fn clean_dry_run() { .file("src/lib.rs", "") .build(); - let ls_r = || -> Vec<_> { - let mut file_list: Vec<_> = walkdir::WalkDir::new(p.build_dir()) - .into_iter() - .filter_map(|e| e.map(|e| e.path().to_owned()).ok()) - .collect(); - file_list.sort(); - file_list - }; - // Start with no files. p.cargo("clean --dry-run") .with_stdout("") @@ -823,7 +820,7 @@ fn clean_dry_run() { ) .run(); p.cargo("check").run(); - let before = ls_r(); + let before = p.build_dir().ls_r(); p.cargo("clean --dry-run") .with_stderr( "[SUMMARY] [..] files, [..] total\n\ @@ -831,7 +828,7 @@ fn clean_dry_run() { ) .run(); // Verify it didn't delete anything. - let after = ls_r(); + let after = p.build_dir().ls_r(); assert_eq!(before, after); let expected = cargo::util::iter_join(before.iter().map(|p| p.to_str().unwrap()), "\n"); eprintln!("{expected}"); @@ -854,3 +851,29 @@ fn doc_with_package_selection() { .with_stderr("error: --doc cannot be used with -p") .run(); } + +#[cargo_test] +fn quiet_does_not_show_summary() { + // Checks that --quiet works with `cargo clean`, since there was a + // subtle issue with how the flag is defined as a global flag. + let p = project() + .file("Cargo.toml", &basic_manifest("foo", "0.1.0")) + .file("src/lib.rs", "") + .build(); + + p.cargo("check").run(); + p.cargo("clean --quiet --dry-run") + .with_stdout("") + .with_stderr("") + .run(); + // Verify exact same command without -q would actually display something. + p.cargo("clean --dry-run") + .with_stdout("") + .with_stderr( + "\ +[SUMMARY] [..] files, [..] total +[WARNING] no files deleted due to --dry-run +", + ) + .run(); +} |