aboutsummaryrefslogtreecommitdiff
path: root/tests/testutils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testutils')
-rw-r--r--tests/testutils/src/lib.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/testutils/src/lib.rs b/tests/testutils/src/lib.rs
index d181e455b..b50e70849 100644
--- a/tests/testutils/src/lib.rs
+++ b/tests/testutils/src/lib.rs
@@ -73,16 +73,24 @@ fn test_from_dir(dir: &Path) -> Vec<PathBuf> {
73 acc 73 acc
74} 74}
75 75
76const REWRITE: bool = false;
77
76fn print_difference(expected: &str, actual: &str, path: &Path) { 78fn print_difference(expected: &str, actual: &str, path: &Path) {
77 let dir = project_dir(); 79 let dir = project_dir();
78 let path = path.strip_prefix(&dir).unwrap_or_else(|_| path); 80 let path = path.strip_prefix(&dir).unwrap_or_else(|_| path);
79 if expected.trim() == actual.trim() { 81 if expected.trim() == actual.trim() {
80 println!("whitespace difference, rewriting"); 82 println!("whitespace difference, rewriting");
83 println!("file: {}\n", path.display());
84 file::put_text(path, actual).unwrap();
85 return;
86 }
87 if REWRITE {
88 println!("rewriting {}", path.display());
81 file::put_text(path, actual).unwrap(); 89 file::put_text(path, actual).unwrap();
82 } else { 90 return;
83 let changeset = Changeset::new(actual, expected, "\n");
84 print!("{}", changeset);
85 } 91 }
92 let changeset = Changeset::new(actual, expected, "\n");
93 print!("{}", changeset);
86 println!("file: {}\n", path.display()); 94 println!("file: {}\n", path.display());
87 panic!("Comparison failed") 95 panic!("Comparison failed")
88} 96}