1
- use std:: io:: { self , prelude :: Write } ;
1
+ use std:: io;
2
2
use std:: time:: Duration ;
3
3
4
4
use super :: OutputFormatter ;
5
5
use crate :: {
6
- console:: { ConsoleTestDiscoveryState , ConsoleTestState , OutputLocation } ,
6
+ console:: { ConsoleTestDiscoveryState , ConsoleTestState , Output } ,
7
7
test_result:: TestResult ,
8
8
time,
9
9
types:: { TestDesc , TestType } ,
10
10
} ;
11
11
12
- pub struct JunitFormatter < T > {
13
- out : OutputLocation < T > ,
12
+ pub struct JunitFormatter < ' a > {
13
+ out : & ' a mut dyn Output ,
14
14
results : Vec < ( TestDesc , TestResult , Duration , Vec < u8 > ) > ,
15
15
}
16
16
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 {
19
19
Self { out, results : Vec :: new ( ) }
20
20
}
21
21
22
22
fn write_message ( & mut self , s : & str ) -> io:: Result < ( ) > {
23
23
assert ! ( !s. contains( '\n' ) ) ;
24
24
25
- self . out . write_all ( s . as_ref ( ) )
25
+ self . out . write_plain ( s )
26
26
}
27
27
}
28
28
@@ -38,7 +38,7 @@ fn str_to_cdata(s: &str) -> String {
38
38
format ! ( "<![CDATA[{}]]>" , escaped_output)
39
39
}
40
40
41
- impl < T : Write > OutputFormatter for JunitFormatter < T > {
41
+ impl OutputFormatter for JunitFormatter < ' _ > {
42
42
fn write_discovery_start ( & mut self ) -> io:: Result < ( ) > {
43
43
Err ( io:: Error :: new ( io:: ErrorKind :: NotFound , "Not yet implemented!" ) )
44
44
}
@@ -179,7 +179,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
179
179
self . write_message ( "</testsuite>" ) ?;
180
180
self . write_message ( "</testsuites>" ) ?;
181
181
182
- self . out . write_all ( b "\n ") ?;
182
+ self . out . write_plain ( "\n " ) ?;
183
183
184
184
Ok ( state. failed == 0 )
185
185
}
0 commit comments