nextest_runner/config/elements/
report_skip_policy.rs1use nextest_metadata::MismatchReason;
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
13#[cfg_attr(feature = "config-schema", derive(schemars::JsonSchema))]
14#[serde(rename_all = "kebab-case")]
15#[cfg_attr(test, derive(test_strategy::Arbitrary))]
16pub enum ReportSkipPolicy {
17 #[default]
20 None,
21
22 Ignored,
26
27 All,
35}
36
37impl ReportSkipPolicy {
38 pub fn should_report(self, reason: MismatchReason) -> bool {
44 match self {
45 ReportSkipPolicy::None => false,
46 ReportSkipPolicy::Ignored => reason.is_ignore_mismatch(),
47 ReportSkipPolicy::All => reason.is_substantive_skip(),
48 }
49 }
50}
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn should_report_policy_behavior() {
58 assert!(!ReportSkipPolicy::None.should_report(MismatchReason::Ignored));
59 assert!(!ReportSkipPolicy::None.should_report(MismatchReason::DefaultFilter));
60 assert!(!ReportSkipPolicy::None.should_report(MismatchReason::NotBenchmark));
61
62 assert!(ReportSkipPolicy::Ignored.should_report(MismatchReason::Ignored));
63 assert!(!ReportSkipPolicy::Ignored.should_report(MismatchReason::DefaultFilter));
64 assert!(!ReportSkipPolicy::Ignored.should_report(MismatchReason::NotBenchmark));
65
66 assert!(ReportSkipPolicy::All.should_report(MismatchReason::Ignored));
67 assert!(ReportSkipPolicy::All.should_report(MismatchReason::DefaultFilter));
68 assert!(!ReportSkipPolicy::All.should_report(MismatchReason::NotBenchmark));
69 }
70
71 #[test]
72 fn should_report_mirrors_reason_predicates() {
73 for &reason in MismatchReason::ALL_VARIANTS {
74 assert!(
75 !ReportSkipPolicy::None.should_report(reason),
76 "None never reports {reason:?}"
77 );
78 assert_eq!(
79 ReportSkipPolicy::Ignored.should_report(reason),
80 reason.is_ignore_mismatch(),
81 "Ignored policy must mirror is_ignore_mismatch for {reason:?}"
82 );
83 assert_eq!(
84 ReportSkipPolicy::All.should_report(reason),
85 reason.is_substantive_skip(),
86 "All policy must mirror is_substantive_skip for {reason:?}"
87 );
88 }
89 }
90}