Skip to content

Commit 1b875d3

Browse files
committed
feat(harness): Report the test's name
This is needed for actually sending custom events
1 parent 942f5e0 commit 1b875d3

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

crates/libtest2-harness/src/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub struct TestContext {
55
pub(crate) mode: RunMode,
66
pub(crate) run_ignored: bool,
77
pub(crate) notifier: notify::ArcNotifier,
8+
pub(crate) test_name: String,
89
}
910

1011
impl TestContext {
@@ -36,6 +37,10 @@ impl TestContext {
3637
notify::Elapsed(self.start.elapsed())
3738
}
3839

40+
pub fn test_name(&self) -> &str {
41+
&self.test_name
42+
}
43+
3944
pub(crate) fn notifier(&self) -> &notify::ArcNotifier {
4045
&self.notifier
4146
}
@@ -46,6 +51,7 @@ impl TestContext {
4651
mode: self.mode,
4752
run_ignored: self.run_ignored,
4853
notifier: self.notifier.clone(),
54+
test_name: self.test_name.clone(),
4955
}
5056
}
5157
}

crates/libtest2-harness/src/harness.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ fn run(
335335
mode,
336336
run_ignored,
337337
notifier,
338+
test_name: String::new(),
338339
};
339340

340341
let mut success = true;
@@ -369,7 +370,8 @@ fn run(
369370
let cfg = std::thread::Builder::new().name(name.clone());
370371
let thread_tx = tx.clone();
371372
let thread_case = case.clone();
372-
let thread_context = context.clone();
373+
let mut thread_context = context.clone();
374+
thread_context.test_name = name.clone();
373375
let thread_sync_success = sync_success.clone();
374376
let join_handle = cfg.spawn(move || {
375377
let status = run_case(thread_case.as_ref().as_ref(), &thread_context);

0 commit comments

Comments
 (0)