From 0e5b6a6e94e6df70d26b2622d92a8bd453d424f9 Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Thu, 26 Dec 2024 11:35:37 +0800 Subject: [PATCH] fix progress line overwrite moonc diagnostic --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/progress.rs | 5 +++++ tests/e2e/regen.rs | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88bf757..4bfcc6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,7 +369,7 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "n2" -version = "0.1.4" +version = "0.1.5" dependencies = [ "anyhow", "argh", diff --git a/Cargo.toml b/Cargo.toml index 0c23053..fbd62c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "n2" -version = "0.1.4" +version = "0.1.5" categories = ["development-tools", "development-tools::build-utils"] edition = "2018" exclude = [".github/*", ".vscode/*"] diff --git a/src/progress.rs b/src/progress.rs index 0ab62af..0aa8c16 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -275,6 +275,9 @@ impl FancyState { fn task_finished(&mut self, id: BuildId, build: &Build, result: &TaskResult) { self.tasks .remove(self.tasks.iter().position(|t| t.id == id).unwrap()); + + self.clear_progress(); + match result.termination { Termination::Success => { // Common case: don't show anything. @@ -298,6 +301,8 @@ impl FancyState { std::io::stdout().write_all(&result.output).unwrap(); } } + + // mark as dirty to trigger progress update self.dirty(); } diff --git a/tests/e2e/regen.rs b/tests/e2e/regen.rs index 49a8b05..573435e 100644 --- a/tests/e2e/regen.rs +++ b/tests/e2e/regen.rs @@ -128,7 +128,8 @@ fn restat() -> anyhow::Result<()> { let out = space.run_expect(&mut n2_command(vec!["build.ninja"]))?; assert_output_not_contains(&out, "touch build.ninja"); - // But modifying the input should cause it to be up to date. + std::thread::sleep(std::time::Duration::from_millis(100)); + space.write("in", "")?; let out = space.run_expect(&mut n2_command(vec!["build.ninja"]))?; assert_output_contains(&out, "touch build.ninja");