mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add a warning to cargo clean --dry-run
This makes it more consistent with other `--dry-run` commands, and makes it clearer to the user that cargo did not do anything.
This commit is contained in:
parent
ebee726d8f
commit
f61d42d5ef
@ -417,7 +417,13 @@ impl<'cfg> CleanContext<'cfg> {
|
||||
};
|
||||
self.config
|
||||
.shell()
|
||||
.status(status, format!("{file_count}{byte_count}"))
|
||||
.status(status, format!("{file_count}{byte_count}"))?;
|
||||
if self.dry_run {
|
||||
self.config
|
||||
.shell()
|
||||
.warn("no files deleted due to --dry-run")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Deletes all of the given paths, showing a progress bar as it proceeds.
|
||||
|
@ -817,13 +817,19 @@ fn clean_dry_run() {
|
||||
// Start with no files.
|
||||
p.cargo("clean --dry-run")
|
||||
.with_stdout("")
|
||||
.with_stderr("[SUMMARY] 0 files")
|
||||
.with_stderr(
|
||||
"[SUMMARY] 0 files\n\
|
||||
[WARNING] no files deleted due to --dry-run",
|
||||
)
|
||||
.run();
|
||||
p.cargo("check").run();
|
||||
let before = ls_r();
|
||||
p.cargo("clean --dry-run")
|
||||
.with_stdout("[CWD]/target")
|
||||
.with_stderr("[SUMMARY] [..] files, [..] total")
|
||||
.with_stderr(
|
||||
"[SUMMARY] [..] files, [..] total\n\
|
||||
[WARNING] no files deleted due to --dry-run",
|
||||
)
|
||||
.run();
|
||||
// Verify it didn't delete anything.
|
||||
let after = ls_r();
|
||||
@ -833,7 +839,10 @@ fn clean_dry_run() {
|
||||
// Verify the verbose output.
|
||||
p.cargo("clean --dry-run -v")
|
||||
.with_stdout_unordered(expected)
|
||||
.with_stderr("[SUMMARY] [..] files, [..] total")
|
||||
.with_stderr(
|
||||
"[SUMMARY] [..] files, [..] total\n\
|
||||
[WARNING] no files deleted due to --dry-run",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user