diff --git a/nextest-runner/src/list/test_list.rs b/nextest-runner/src/list/test_list.rs index fc86b2c3f97..60216075251 100644 --- a/nextest-runner/src/list/test_list.rs +++ b/nextest-runner/src/list/test_list.rs @@ -987,10 +987,14 @@ impl<'a> TestInstance<'a> { } } - /// Return a reasonable key for sorting. This is (binary ID, test name). + /// Return an identifier for test instances, including being able to sort + /// them. #[inline] - pub(crate) fn sort_key(&self) -> (&'a str, &'a str) { - ((self.suite_info.binary_id.as_str()), self.name) + pub(crate) fn id(&self) -> TestInstanceId<'a> { + TestInstanceId { + binary_id: &self.suite_info.binary_id, + test_name: self.name, + } } /// Returns the corresponding [`TestQuery`] for this `TestInstance`. @@ -1052,6 +1056,18 @@ impl<'a> TestInstance<'a> { } } +/// A key for identifying and sorting test instances. +/// +/// Returned by [`TestInstance::id`]. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +pub struct TestInstanceId<'a> { + /// The binary ID. + pub binary_id: &'a RustBinaryId, + + /// The name of the test. + pub test_name: &'a str, +} + /// Context required for test execution. #[derive(Clone, Debug)] pub struct TestExecuteContext<'a> { diff --git a/nextest-runner/src/reporter/displayer.rs b/nextest-runner/src/reporter/displayer.rs index a621aa814c1..ae2e525df1b 100644 --- a/nextest-runner/src/reporter/displayer.rs +++ b/nextest-runner/src/reporter/displayer.rs @@ -1012,10 +1012,11 @@ impl<'a> TestReporterImpl<'a> { // Sort the final outputs for a friendlier experience. self.final_outputs .sort_by_key(|(test_instance, final_output)| { - // Use the final status level, reversed (i.e. failing tests are printed at the very end). + // Use the final status level, reversed (i.e. + // failing tests are printed at the very end). ( Reverse(final_output.final_status_level()), - test_instance.sort_key(), + test_instance.id(), ) });