summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-tree/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/tracing-tree/tests
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-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 'vendor/tracing-tree/tests')
-rw-r--r--vendor/tracing-tree/tests/format_time.rs79
-rw-r--r--vendor/tracing-tree/tests/ui.rs23
2 files changed, 0 insertions, 102 deletions
diff --git a/vendor/tracing-tree/tests/format_time.rs b/vendor/tracing-tree/tests/format_time.rs
deleted file mode 100644
index b24b16652..000000000
--- a/vendor/tracing-tree/tests/format_time.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-use std::{
- fmt::Write,
- sync::{
- atomic::{AtomicU64, Ordering},
- Arc,
- },
-};
-
-use tracing::{span, Level};
-use tracing_subscriber::{layer::SubscriberExt, Registry};
-
-use tracing_tree::{time::FormatTime, HierarchicalLayer};
-
-#[derive(Debug)]
-struct FormatTimeCounter(Arc<AtomicU64>);
-
-impl FormatTime for FormatTimeCounter {
- fn format_time(&self, _w: &mut impl Write) -> std::fmt::Result {
- self.0.fetch_add(1, Ordering::Relaxed);
- Ok(())
- }
-}
-
-#[test]
-fn format_time_num_calls() {
- let num_called = Arc::new(AtomicU64::new(0));
- let format_time_counter = FormatTimeCounter(Arc::clone(&num_called));
-
- let layer = HierarchicalLayer::default()
- .with_writer(std::io::stdout)
- .with_indent_lines(true)
- .with_indent_amount(2)
- .with_timer(format_time_counter)
- .with_thread_names(true)
- .with_thread_ids(true)
- .with_verbose_exit(true)
- .with_verbose_entry(true)
- .with_targets(true);
-
- let subscriber = Registry::default().with(layer);
- tracing::subscriber::set_global_default(subscriber).unwrap();
-
- let test_span = span!(Level::TRACE, "format-time-num-calls-test", version = %0.1);
- let _e = test_span.enter();
-
- tracing::info!("first event");
- assert_eq!(num_called.load(Ordering::Relaxed), 1);
-
- std::thread::sleep(std::time::Duration::from_millis(100));
- tracing::info!("second event");
- assert_eq!(num_called.load(Ordering::Relaxed), 2);
-
- let nested_span = span!(Level::TRACE, "nested-span");
- nested_span.in_scope(|| {
- tracing::debug!("nested event");
- assert_eq!(num_called.load(Ordering::Relaxed), 3);
-
- tracing::info!("important nested event");
- assert_eq!(num_called.load(Ordering::Relaxed), 4);
- });
- drop(nested_span);
-
- instrumented_function();
- assert_eq!(num_called.load(Ordering::Relaxed), 6);
-
- tracing::info!("exiting");
- assert_eq!(num_called.load(Ordering::Relaxed), 7);
-}
-
-#[tracing::instrument]
-fn instrumented_function() {
- tracing::info!("instrumented function");
- nested_instrumented_function();
-}
-
-#[tracing::instrument]
-fn nested_instrumented_function() {
- tracing::warn!("nested instrumented function");
-}
diff --git a/vendor/tracing-tree/tests/ui.rs b/vendor/tracing-tree/tests/ui.rs
deleted file mode 100644
index cca8241d1..000000000
--- a/vendor/tracing-tree/tests/ui.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-use ui_test::{color_eyre::Result, run_tests, Config, Mode, OutputConflictHandling};
-
-fn main() -> Result<()> {
- let mut config = Config::default();
- config.root_dir = "examples".into();
- config.dependencies_crate_manifest_path = Some("test_dependencies/Cargo.toml".into());
- config.args.push("--cfg".into());
- config.args.push("feature=\"tracing-log\"".into());
- config.out_dir = Some("target/ui_test".into());
- config.mode = Mode::Run { exit_code: 0 };
- config.stdout_filter("[0-9]{3}(ms|s|m)", " X$1");
- config.stdout_filter("[0-9]{2}(ms|s|m)", " X$1");
- config.stdout_filter("[0-9]{1}(ms|s|m)", "X$1");
- config.stderr_filter("[0-9]{3}(ms|s|m)", " X$1");
- config.stderr_filter("[0-9]{2}(ms|s|m)", " X$1");
- config.stderr_filter("[0-9]{1}(ms|s|m)", "X$1");
- config.output_conflict_handling = if std::env::args().any(|arg| arg == "--bless") {
- OutputConflictHandling::Bless
- } else {
- OutputConflictHandling::Error
- };
- run_tests(config)
-}