]> git.lizzy.rs Git - rust.git/commitdiff
Improve error message for missing source/target test file
authorVincent Esche <regexident@gmail.com>
Sun, 30 Apr 2017 21:44:12 +0000 (23:44 +0200)
committerVincent Esche <regexident@gmail.com>
Mon, 1 May 2017 21:34:00 +0000 (23:34 +0200)
tests/system.rs

index 5b128aa6b359c515c12feea895720e698eae4a24..48531d321c83254fa2f1b66e2c398fc691dc31d2 100644 (file)
@@ -332,10 +332,12 @@ fn handle_result(result: HashMap<String, String>,
     for (file_name, fmt_text) in result {
         // If file is in tests/source, compare to file with same name in tests/target.
         let target = get_target(&file_name, target);
-        let mut f = fs::File::open(&target).expect("Couldn't open target");
+        let open_error = format!("Couldn't open target {:?}", &target);
+        let mut f = fs::File::open(&target).expect(&open_error);
 
         let mut text = String::new();
-        f.read_to_string(&mut text).expect("Failed reading target");
+        let read_error = format!("Failed reading target {:?}", &target);
+        f.read_to_string(&mut text).expect(&read_error);
 
         if fmt_text != text {
             let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE);