From 7714e22d3c72e216c2f239963b494fae999bea50 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 7 Oct 2024 14:56:36 +0200 Subject: [PATCH] Remove global variable --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/status_emitter/text.rs | 12 ++++++------ tests/integrations/basic-bin/Cargo.lock | 2 +- tests/integrations/basic-fail-mode/Cargo.lock | 2 +- tests/integrations/basic-fail/Cargo.lock | 2 +- tests/integrations/basic/Cargo.lock | 2 +- tests/integrations/cargo-run/Cargo.lock | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7266326..e0aa83c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,7 +592,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 357bfcc..82399b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ui_test" -version = "0.27.0" +version = "0.27.1" edition = "2021" license = "MIT OR Apache-2.0" description = "A test framework for testing rustc diagnostics output" diff --git a/src/status_emitter/text.rs b/src/status_emitter/text.rs index d5606a4..8076cc0 100644 --- a/src/status_emitter/text.rs +++ b/src/status_emitter/text.rs @@ -47,6 +47,8 @@ pub struct Text { progress: OutputVerbosity, #[cfg(feature = "indicatif")] handle: Arc, + #[cfg(feature = "indicatif")] + ids: Arc, } #[cfg(feature = "indicatif")] @@ -316,6 +318,7 @@ impl Text { progress, #[cfg(feature = "indicatif")] handle: Arc::new(handle.into()), + ids: Arc::new(AtomicUsize::new(1)), } } @@ -357,9 +360,6 @@ struct TextTest { style: RevisionStyle, } -#[cfg(feature = "indicatif")] -static ID_GENERATOR: AtomicUsize = AtomicUsize::new(1); - impl TestStatus for TextTest { fn done(&self, result: &TestResult, aborted: bool) { #[cfg(feature = "indicatif")] @@ -458,7 +458,7 @@ impl TestStatus for TextTest { #[cfg(feature = "indicatif")] parent: self.id, #[cfg(feature = "indicatif")] - id: ID_GENERATOR.fetch_add(1, Ordering::Relaxed), + id: self.text.ids.fetch_add(1, Ordering::Relaxed), revision: revision.to_owned(), style, }; @@ -485,7 +485,7 @@ impl TestStatus for TextTest { #[cfg(feature = "indicatif")] parent: self.id, #[cfg(feature = "indicatif")] - id: ID_GENERATOR.fetch_add(1, Ordering::Relaxed), + id: self.text.ids.fetch_add(1, Ordering::Relaxed), revision: String::new(), style: RevisionStyle::Show, }; @@ -510,7 +510,7 @@ impl TestStatus for TextTest { impl StatusEmitter for Text { fn register_test(&self, path: PathBuf) -> Box { #[cfg(feature = "indicatif")] - let id = ID_GENERATOR.fetch_add(1, Ordering::Relaxed); + let id = self.ids.fetch_add(1, Ordering::Relaxed); #[cfg(feature = "indicatif")] self.sender .send(Msg::Push { diff --git a/tests/integrations/basic-bin/Cargo.lock b/tests/integrations/basic-bin/Cargo.lock index 95a01d3..1f6db36 100644 --- a/tests/integrations/basic-bin/Cargo.lock +++ b/tests/integrations/basic-bin/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow", diff --git a/tests/integrations/basic-fail-mode/Cargo.lock b/tests/integrations/basic-fail-mode/Cargo.lock index 7edb74d..7257589 100644 --- a/tests/integrations/basic-fail-mode/Cargo.lock +++ b/tests/integrations/basic-fail-mode/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow", diff --git a/tests/integrations/basic-fail/Cargo.lock b/tests/integrations/basic-fail/Cargo.lock index 4943732..eecdcaa 100644 --- a/tests/integrations/basic-fail/Cargo.lock +++ b/tests/integrations/basic-fail/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow", diff --git a/tests/integrations/basic/Cargo.lock b/tests/integrations/basic/Cargo.lock index 402be35..9604e08 100644 --- a/tests/integrations/basic/Cargo.lock +++ b/tests/integrations/basic/Cargo.lock @@ -639,7 +639,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow", diff --git a/tests/integrations/cargo-run/Cargo.lock b/tests/integrations/cargo-run/Cargo.lock index 95a01d3..1f6db36 100644 --- a/tests/integrations/cargo-run/Cargo.lock +++ b/tests/integrations/cargo-run/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.27.0" +version = "0.27.1" dependencies = [ "annotate-snippets", "anyhow",