assert no errors on formatting test source

Fixes #28.
This commit is contained in:
Andy Russell 2017-07-12 13:21:36 -04:00
parent 3552595a3b
commit 86d48981ee
No known key found for this signature in database
GPG key ID: 78B13E28497AF2DF

View 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 // 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 // overridden by annotations in the source file. The input and output must match
// exactly. // exactly.
// FIXME(#28) would be good to check for error messages and fail on them, or at
// least report.
#[test] #[test]
fn system_tests() { fn system_tests() {
// Get all files in the tests/source directory. // Get all files in the tests/source directory.
@ -240,10 +238,17 @@ fn read_config(filename: &str) -> Config {
config config
} }
fn format_file<P: Into<PathBuf>>(filename: P, config: &Config) -> (FileMap, FormatReport) { fn format_file<P: Into<PathBuf>>(filepath: P, config: &Config) -> (FileMap, FormatReport) {
let input = Input::File(filename.into()); let filepath = filepath.into();
let (_error_summary, file_map, report) = 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(); format_input::<io::Stdout>(input, &config, None).unwrap();
assert!(
error_summary.has_no_errors(),
"Encountered errors formatting {}",
display_path
);
return (file_map, report); return (file_map, report);
} }