Skip to content

Commit 1f676f9

Browse files
committed
Hide implementation details of OutputLocation<T> from JunitFormatter.
1 parent 1d01cc6 commit 1f676f9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

library/test/src/console.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
336336
Box::new(TerseFormatter::new(output, opts.use_color(), max_name_len, is_multithreaded))
337337
}
338338
OutputFormat::Json => Box::new(JsonFormatter::new(&mut output)),
339-
OutputFormat::Junit => Box::new(JunitFormatter::new(output)),
339+
OutputFormat::Junit => Box::new(JunitFormatter::new(&mut output)),
340340
};
341341
let mut st = ConsoleTestState::new(opts)?;
342342

library/test/src/formatters/junit.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
use std::io::{self, prelude::Write};
1+
use std::io;
22
use std::time::Duration;
33

44
use super::OutputFormatter;
55
use crate::{
6-
console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation},
6+
console::{ConsoleTestDiscoveryState, ConsoleTestState, Output},
77
test_result::TestResult,
88
time,
99
types::{TestDesc, TestType},
1010
};
1111

12-
pub struct JunitFormatter<T> {
13-
out: OutputLocation<T>,
12+
pub struct JunitFormatter<'a> {
13+
out: &'a mut dyn Output,
1414
results: Vec<(TestDesc, TestResult, Duration, Vec<u8>)>,
1515
}
1616

17-
impl<T: Write> JunitFormatter<T> {
18-
pub fn new(out: OutputLocation<T>) -> Self {
17+
impl<'a> JunitFormatter<'a> {
18+
pub fn new(out: &'a mut dyn Output) -> Self {
1919
Self { out, results: Vec::new() }
2020
}
2121

2222
fn write_message(&mut self, s: &str) -> io::Result<()> {
2323
assert!(!s.contains('\n'));
2424

25-
self.out.write_all(s.as_ref())
25+
self.out.write_plain(s)
2626
}
2727
}
2828

@@ -38,7 +38,7 @@ fn str_to_cdata(s: &str) -> String {
3838
format!("<![CDATA[{}]]>", escaped_output)
3939
}
4040

41-
impl<T: Write> OutputFormatter for JunitFormatter<T> {
41+
impl OutputFormatter for JunitFormatter<'_> {
4242
fn write_discovery_start(&mut self) -> io::Result<()> {
4343
Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!"))
4444
}
@@ -179,7 +179,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
179179
self.write_message("</testsuite>")?;
180180
self.write_message("</testsuites>")?;
181181

182-
self.out.write_all(b"\n")?;
182+
self.out.write_plain("\n")?;
183183

184184
Ok(state.failed == 0)
185185
}

0 commit comments

Comments
 (0)