]> git.lizzy.rs Git - rust.git/commitdiff
assert no errors on formatting test source
authorAndy Russell <arussell123@gmail.com>
Wed, 12 Jul 2017 17:21:36 +0000 (13:21 -0400)
committerAndy Russell <arussell123@gmail.com>
Wed, 12 Jul 2017 17:21:36 +0000 (13:21 -0400)
Fixes #28.

tests/system.rs

index b43bb0819213e5efb0a8ba65c90e9c069869f033..b22a22afd696f29ca452677d99c264e234b482c6 100644 (file)
@@ -35,8 +35,6 @@ fn get_path_string(dir_entry: io::Result<fs::DirEntry>) -> String {
 // to their equivalent in tests/target. The target file and config can be
 // overridden by annotations in the source file. The input and output must match
 // exactly.
-// FIXME(#28) would be good to check for error messages and fail on them, or at
-// least report.
 #[test]
 fn system_tests() {
     // Get all files in the tests/source directory.
@@ -240,10 +238,17 @@ fn read_config(filename: &str) -> Config {
     config
 }
 
-fn format_file<P: Into<PathBuf>>(filename: P, config: &Config) -> (FileMap, FormatReport) {
-    let input = Input::File(filename.into());
-    let (_error_summary, file_map, report) =
+fn format_file<P: Into<PathBuf>>(filepath: P, config: &Config) -> (FileMap, FormatReport) {
+    let filepath = filepath.into();
+    let display_path = filepath.display().to_string();
+    let input = Input::File(filepath);
+    let (error_summary, file_map, report) =
         format_input::<io::Stdout>(input, &config, None).unwrap();
+    assert!(
+        error_summary.has_no_errors(),
+        "Encountered errors formatting {}",
+        display_path
+    );
     return (file_map, report);
 }