nextest_runner/config/elements/
junit.rs1use camino::{Utf8Path, Utf8PathBuf};
5use serde::Deserialize;
6
7#[derive(Clone, Debug)]
11pub struct JunitConfig<'cfg> {
12 path: Utf8PathBuf,
13 report_name: &'cfg str,
14 store_success_output: bool,
15 store_failure_output: bool,
16}
17
18impl<'cfg> JunitConfig<'cfg> {
19 pub(in crate::config) fn new(
20 store_dir: &Utf8Path,
21 settings: JunitSettings<'cfg>,
22 ) -> Option<Self> {
23 let path = settings.path?;
24 Some(Self {
25 path: store_dir.join(path),
26 report_name: settings.report_name,
27 store_success_output: settings.store_success_output,
28 store_failure_output: settings.store_failure_output,
29 })
30 }
31
32 pub fn path(&self) -> &Utf8Path {
34 &self.path
35 }
36
37 pub fn report_name(&self) -> &'cfg str {
39 self.report_name
40 }
41
42 pub fn store_success_output(&self) -> bool {
44 self.store_success_output
45 }
46
47 pub fn store_failure_output(&self) -> bool {
49 self.store_failure_output
50 }
51}
52
53#[derive(Clone, Debug)]
55pub(in crate::config) struct JunitSettings<'cfg> {
56 pub(in crate::config) path: Option<&'cfg Utf8Path>,
57 pub(in crate::config) report_name: &'cfg str,
58 pub(in crate::config) store_success_output: bool,
59 pub(in crate::config) store_failure_output: bool,
60}
61
62#[derive(Clone, Debug)]
63pub(in crate::config) struct DefaultJunitImpl {
64 pub(in crate::config) path: Option<Utf8PathBuf>,
65 pub(in crate::config) report_name: String,
66 pub(in crate::config) store_success_output: bool,
67 pub(in crate::config) store_failure_output: bool,
68}
69
70impl DefaultJunitImpl {
71 pub(crate) fn for_default_profile(data: JunitImpl) -> Self {
73 DefaultJunitImpl {
74 path: data.path,
75 report_name: data
76 .report_name
77 .expect("junit.report present in default profile"),
78 store_success_output: data
79 .store_success_output
80 .expect("junit.store-success-output present in default profile"),
81 store_failure_output: data
82 .store_failure_output
83 .expect("junit.store-failure-output present in default profile"),
84 }
85 }
86}
87
88#[derive(Clone, Debug, Default, Deserialize)]
89#[serde(rename_all = "kebab-case")]
90pub(in crate::config) struct JunitImpl {
91 #[serde(default)]
92 pub(in crate::config) path: Option<Utf8PathBuf>,
93 #[serde(default)]
94 pub(in crate::config) report_name: Option<String>,
95 #[serde(default)]
96 pub(in crate::config) store_success_output: Option<bool>,
97 #[serde(default)]
98 pub(in crate::config) store_failure_output: Option<bool>,
99}