|
10 | 10 | //! There are several debugging environment variables for this test that you can set:
|
11 | 11 | //!
|
12 | 12 | //! - `RUST_LOG=parse_and_replace=debug`: Print debug information.
|
| 13 | +//! - `RUSTFIX_TEST_BLESS=test-name.rs`: When given the name of a test, this |
| 14 | +//! will overwrite the `.json` and `.fixed.rs` files with the expected |
| 15 | +//! values. This can be used when adding a new test. |
13 | 16 | //! - `RUSTFIX_TEST_RECORD_JSON=1`: Records the JSON output to
|
14 | 17 | //! `*.recorded.json` files. You can then move that to `.json` or whatever
|
15 | 18 | //! you need.
|
@@ -39,6 +42,7 @@ mod settings {
|
39 | 42 | pub const CHECK_JSON: &str = "RUSTFIX_TEST_CHECK_JSON";
|
40 | 43 | pub const RECORD_JSON: &str = "RUSTFIX_TEST_RECORD_JSON";
|
41 | 44 | pub const RECORD_FIXED_RUST: &str = "RUSTFIX_TEST_RECORD_FIXED_RUST";
|
| 45 | + pub const BLESS: &str = "RUSTFIX_TEST_BLESS"; |
42 | 46 | }
|
43 | 47 |
|
44 | 48 | fn compile(file: &Path) -> Result<Output, Error> {
|
@@ -176,6 +180,13 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
|
176 | 180 | fs::write(file.with_extension("recorded.rs"), &fixed)?;
|
177 | 181 | }
|
178 | 182 |
|
| 183 | + if let Some(bless_name) = std::env::var_os(settings::BLESS) { |
| 184 | + if bless_name == file.file_name().unwrap() { |
| 185 | + std::fs::write(&json_file, &errors)?; |
| 186 | + std::fs::write(&fixed_file, &fixed)?; |
| 187 | + } |
| 188 | + } |
| 189 | + |
179 | 190 | let expected_fixed = fs::read_to_string(&fixed_file)
|
180 | 191 | .context(format!("could read fixed file for {}", file.display()))?;
|
181 | 192 | ensure!(
|
|
0 commit comments