Skip to content

Commit 7e62f94

Browse files
committed
Simplify access to output results in unit test should_sort_failures_before_printing_them.
1 parent 41e7fe3 commit 7e62f94

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

library/test/src/formatters/pretty.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ impl<T: Write> PrettyFormatter<T> {
3232
PrettyFormatter { out, use_color, max_name_len, is_multithreaded, time_options }
3333
}
3434

35-
#[cfg(test)]
36-
pub fn output_location(&self) -> &OutputLocation<T> {
37-
&self.out
38-
}
39-
4035
pub fn write_ok(&mut self) -> io::Result<()> {
4136
self.write_short_result("ok", term::color::GREEN)
4237
}

library/test/src/tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,8 @@ fn should_sort_failures_before_printing_them() {
893893
test_type: TestType::Unknown,
894894
};
895895

896-
let mut out = PrettyFormatter::new(OutputLocation::Raw(Vec::new()), false, 10, false, None);
896+
let mut output = Vec::new();
897+
let mut out = PrettyFormatter::new(OutputLocation::Raw(&mut output), false, 10, false, None);
897898

898899
let st = console::ConsoleTestState {
899900
log_out: None,
@@ -913,11 +914,8 @@ fn should_sort_failures_before_printing_them() {
913914
};
914915

915916
out.write_failures(&st).unwrap();
916-
let s = match out.output_location() {
917-
&OutputLocation::Raw(ref m) => String::from_utf8_lossy(&m[..]),
918-
&OutputLocation::Pretty(_) => unreachable!(),
919-
};
920917

918+
let s = String::from_utf8_lossy(&output[..]);
921919
let apos = s.find("a").unwrap();
922920
let bpos = s.find("b").unwrap();
923921
assert!(apos < bpos);

0 commit comments

Comments
 (0)