Skip to content

Commit 5982959

Browse files
authored
[usdt] add global_slot, group_slot and test_group (#2716)
Useful for test attempt events.
1 parent 8d0c488 commit 5982959

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

nextest-runner/src/config/elements/test_group.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ impl TestGroup {
2323
/// The string `"@global"`, indicating the global test group.
2424
pub const GLOBAL_STR: &'static str = "@global";
2525

26+
/// Returns the custom group name if this is a custom group, or None if this is the global group.
27+
pub fn custom_name(&self) -> Option<&str> {
28+
match self {
29+
TestGroup::Custom(group) => Some(group.as_str()),
30+
TestGroup::Global => None,
31+
}
32+
}
33+
2634
pub(crate) fn make_all_groups(
2735
custom_groups: impl IntoIterator<Item = CustomTestGroup>,
2836
) -> impl Iterator<Item = Self> {

nextest-runner/src/runner/executor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,13 @@ impl<'a> ExecutorContext<'a> {
743743
total_attempts: test.retry_data.total_attempts,
744744
stress_current: test.stress_index.map(|s| s.current),
745745
stress_total: test.stress_index.and_then(|s| s.total.map(|t| t.get())),
746+
global_slot: test.cx.global_slot(),
747+
group_slot: test.cx.group_slot(),
748+
test_group: test
749+
.settings
750+
.test_group()
751+
.custom_name()
752+
.map(|s| s.to_owned()),
746753
});
747754

748755
// If assigning the child to the job fails, ignore this. This can happen if the process has

nextest-runner/src/usdt.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ pub struct UsdtTestAttemptStart {
302302

303303
/// The total number of stress runs, if available.
304304
pub stress_total: Option<u32>,
305+
306+
/// The global slot number (0-indexed).
307+
pub global_slot: u64,
308+
309+
/// The group slot number (0-indexed), if the test is in a custom test group.
310+
pub group_slot: Option<u64>,
311+
312+
/// The test group name, if the test is in a custom test group.
313+
pub test_group: Option<String>,
305314
}
306315

307316
/// Data associated with the `test-attempt-done` probe.

0 commit comments

Comments
 (0)