Skip to content

Commit 9df0332

Browse files
committed
Fix diff reporting for failed tests.
1 parent 032e7ae commit 9df0332

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/tests.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ fn write_whole_file(path: &Path, data: &str) -> IoResult<()> {
2828

2929

3030
fn print_json_diff(results: &json::Json, expected: &json::Json) -> IoResult<()> {
31+
use std::io::stdio::stdout;
32+
3133
let temp = try!(TempDir::new("rust-cssparser-tests"));
3234
let results = results.to_pretty_str() + "\n";
3335
let expected = expected.to_pretty_str() + "\n";
@@ -37,13 +39,13 @@ fn print_json_diff(results: &json::Json, expected: &json::Json) -> IoResult<()>
3739
expected_path.push("expected.json");
3840
try!(write_whole_file(&result_path, results.as_slice()));
3941
try!(write_whole_file(&expected_path, expected.as_slice()));
40-
try!(Command::new("colordiff")
42+
stdout().write(try!(Command::new("colordiff")
4143
.arg("-u1000")
4244
.arg(result_path.display().to_string())
4345
.arg(expected_path.display().to_string())
44-
.status()
45-
.map_err(|_| io::standard_error(io::OtherIoError)));
46-
Ok(())
46+
.output()
47+
.map_err(|_| io::standard_error(io::OtherIoError))
48+
).output.as_slice())
4749
}
4850

4951

@@ -69,7 +71,7 @@ fn almost_equals(a: &json::Json, b: &json::Json) -> bool {
6971

7072
fn assert_json_eq(results: json::Json, expected: json::Json, message: String) {
7173
if !almost_equals(&results, &expected) {
72-
let _ = print_json_diff(&results, &expected).unwrap();
74+
print_json_diff(&results, &expected).unwrap();
7375
panic!(message)
7476
}
7577
}

0 commit comments

Comments
 (0)