Add more runner events to the reporter and refine the structure

This commit is contained in:
Omar Abdulla
2025-08-24 20:13:48 +03:00
parent cbb6a11404
commit 4d7d7ed843
6 changed files with 88 additions and 22 deletions
+29 -4
View File
@@ -1,12 +1,11 @@
//! The types associated with the events sent by the runner to the reporter.
use std::path::PathBuf;
#![allow(dead_code)]
use revive_dt_format::corpus::Corpus;
use revive_dt_format::metadata::Metadata;
use tokio::sync::{broadcast, oneshot};
use crate::ReporterEvent;
use crate::{ReporterEvent, common::MetadataFilePath};
macro_rules! keep_if_doc {
(#[doc = $doc:expr]) => {
@@ -91,6 +90,16 @@ macro_rules! define_event {
}
impl [< $ident Reporter >] {
pub fn test_specific_reporter(
&self,
test_specifier: impl Into<std::sync::Arc<crate::common::TestSpecifier>>
) -> [< $ident TestSpecificReporter >] {
[< $ident TestSpecificReporter >] {
reporter: self.clone(),
test_specifier: test_specifier.into(),
}
}
fn report(&self, event: impl Into<$ident>) -> anyhow::Result<()> {
self.0.send(event.into()).map_err(Into::into)
}
@@ -104,6 +113,18 @@ macro_rules! define_event {
}
)*
}
/// A reporter that's tied to a specific test case.
pub struct [< $ident TestSpecificReporter >] {
$vis reporter: [< $ident Reporter >],
$vis test_specifier: std::sync::Arc<crate::common::TestSpecifier>,
}
impl [< $ident TestSpecificReporter >] {
fn report(&self, event: impl Into<$ident>) -> anyhow::Result<()> {
self.reporter.report(event)
}
}
}
};
}
@@ -125,9 +146,13 @@ define_event! {
/// An event emitted by runners when they've discovered a metadata file.
MetadataFileDiscovery {
/// The path of the metadata file discovered.
path: PathBuf,
path: MetadataFilePath,
/// The content of the metadata file.
metadata: Metadata
},
/// An event emitted by the runners when a test case is ignored.
TestIgnored {
},
/// An event emitted by the runners when the execution is completed and the aggregator can
/// stop.