From b5c4f2faa2a39bad9af35e7d90e9ed6151a6a0d5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Jun 2020 11:02:17 +0200 Subject: Update parser tests with env var --- .../parser/inline/err/0009_attr_on_expr_not_allowed.rast | 1 - crates/test_utils/src/lib.rs | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast index 0656fdf73..4e3fa704e 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast @@ -56,4 +56,3 @@ SOURCE_FILE@0..48 R_CURLY@46..47 "}" WHITESPACE@47..48 "\n" error 24..24: attributes are not allowed on BIN_EXPR -error 44..44: attributes are not allowed on IF_EXPR diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 2141bfc20..981565cd7 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -10,17 +10,17 @@ pub mod mark; use std::{ - fs, + env, fs, path::{Path, PathBuf}, }; -pub use ra_cfg::CfgOptions; +use serde_json::Value; use stdx::split1; +use text_size::{TextRange, TextSize}; +pub use ra_cfg::CfgOptions; pub use relative_path::{RelativePath, RelativePathBuf}; pub use rustc_hash::FxHashMap; -use serde_json::Value; -use text_size::{TextRange, TextSize}; pub use difference::Changeset as __Changeset; @@ -625,8 +625,6 @@ pub fn skip_slow_tests() -> bool { should_skip } -const REWRITE: bool = false; - /// Asserts that `expected` and `actual` strings are equal. If they differ only /// in trailing or leading whitespace the test won't fail and /// the contents of `actual` will be written to the file located at `path`. @@ -642,7 +640,7 @@ fn assert_equal_text(expected: &str, actual: &str, path: &Path) { fs::write(path, actual).unwrap(); return; } - if REWRITE { + if env::var("UPDATE_EXPECTATIONS").is_ok() { println!("rewriting {}", pretty_path.display()); fs::write(path, actual).unwrap(); return; -- cgit v1.2.3