Add BLESS env option

Right now if there is a diff between the actual and expected results,
the expected file will be overwritten. This may be annoying. To make it
controlled we introduce BLESS option.

This means that the expected files won't be regenerated unless this
environment variable is set.

Therefore to regenerate the tests use:

    BLESS=1 cargo test
This commit is contained in:
Sergey Shulepov committed 2021-06-09 19:17:54 +02:00
1 parent d891cddcb3
commit 717aa8f0cb
1 file changed
+5 -3
+5 -3
View File
@@ -66,9 +66,11 @@ fn run_diff_test<F: FnOnce(&[u8]) -> Vec<u8>>(test_dir: &str, name: &str, test:
}
}
dump(&expected_path, actual_wat.as_bytes()).expect("Failed to write to expected");
panic!();
if std::env::var("BLESS").is_ok() {
dump(&expected_path, actual_wat.as_bytes()).expect("Failed to write to expected");
} else {
panic!();
}
}
}