diff options
Diffstat (limited to 'subplotlib/src/steplibrary')
-rw-r--r-- | subplotlib/src/steplibrary/files.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs index 1a55f7a..09cde56 100644 --- a/subplotlib/src/steplibrary/files.rs +++ b/subplotlib/src/steplibrary/files.rs @@ -233,6 +233,7 @@ pub fn file_contains(context: &Datadir, filename: &str, data: &str) { let full_path = context.canonicalise_filename(filename)?; let body = fs::read_to_string(full_path)?; if !body.contains(data) { + println!("file {} contains:\n{}", filename, body); throw!("expected file content not found"); } } @@ -248,6 +249,7 @@ pub fn file_doesnt_contain(context: &Datadir, filename: &str, data: &str) { let full_path = context.canonicalise_filename(filename)?; let body = fs::read_to_string(full_path)?; if body.contains(data) { + println!("file {} contains:\n{}", filename, body); throw!("unexpected file content found"); } } @@ -265,6 +267,7 @@ pub fn file_matches_regex(context: &Datadir, filename: &str, regex: &str) { let regex = Regex::new(regex)?; let body = fs::read_to_string(full_path)?; if !regex.is_match(&body) { + println!("file {} contains:\n{}", filename, body); throw!("file content does not match given regex"); } } @@ -281,6 +284,16 @@ pub fn file_match(context: &Datadir, filename1: &str, filename2: &str) { let body1 = fs::read(full_path1)?; let body2 = fs::read(full_path2)?; if body1 != body2 { + println!( + "file {} contains:\n{}", + filename1, + String::from_utf8_lossy(&body1) + ); + println!( + "file {} contains:\n{}", + filename2, + String::from_utf8_lossy(&body2) + ); throw!("file contents do not match each other"); } } |