diff options
author | Aleksey Kladov <[email protected]> | 2020-06-15 10:02:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-06-15 10:02:17 +0100 |
commit | b5c4f2faa2a39bad9af35e7d90e9ed6151a6a0d5 (patch) | |
tree | ded375c0f374b85f7e65f7826a1c1071d6222e81 | |
parent | d739731830d5ad289f1bb779ed58cc1ea3cb5734 (diff) |
Update parser tests with env var
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast | 1 | ||||
-rw-r--r-- | crates/test_utils/src/lib.rs | 12 | ||||
-rw-r--r-- | docs/dev/README.md | 6 |
3 files changed, 11 insertions, 8 deletions
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 @@ [email protected] | |||
56 | [email protected] "}" | 56 | [email protected] "}" |
57 | [email protected] "\n" | 57 | [email protected] "\n" |
58 | error 24..24: attributes are not allowed on BIN_EXPR | 58 | error 24..24: attributes are not allowed on BIN_EXPR |
59 | 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 @@ | |||
10 | pub mod mark; | 10 | pub mod mark; |
11 | 11 | ||
12 | use std::{ | 12 | use std::{ |
13 | fs, | 13 | env, fs, |
14 | path::{Path, PathBuf}, | 14 | path::{Path, PathBuf}, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | pub use ra_cfg::CfgOptions; | 17 | use serde_json::Value; |
18 | use stdx::split1; | 18 | use stdx::split1; |
19 | use text_size::{TextRange, TextSize}; | ||
19 | 20 | ||
21 | pub use ra_cfg::CfgOptions; | ||
20 | pub use relative_path::{RelativePath, RelativePathBuf}; | 22 | pub use relative_path::{RelativePath, RelativePathBuf}; |
21 | pub use rustc_hash::FxHashMap; | 23 | pub use rustc_hash::FxHashMap; |
22 | use serde_json::Value; | ||
23 | use text_size::{TextRange, TextSize}; | ||
24 | 24 | ||
25 | pub use difference::Changeset as __Changeset; | 25 | pub use difference::Changeset as __Changeset; |
26 | 26 | ||
@@ -625,8 +625,6 @@ pub fn skip_slow_tests() -> bool { | |||
625 | should_skip | 625 | should_skip |
626 | } | 626 | } |
627 | 627 | ||
628 | const REWRITE: bool = false; | ||
629 | |||
630 | /// Asserts that `expected` and `actual` strings are equal. If they differ only | 628 | /// Asserts that `expected` and `actual` strings are equal. If they differ only |
631 | /// in trailing or leading whitespace the test won't fail and | 629 | /// in trailing or leading whitespace the test won't fail and |
632 | /// the contents of `actual` will be written to the file located at `path`. | 630 | /// 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) { | |||
642 | fs::write(path, actual).unwrap(); | 640 | fs::write(path, actual).unwrap(); |
643 | return; | 641 | return; |
644 | } | 642 | } |
645 | if REWRITE { | 643 | if env::var("UPDATE_EXPECTATIONS").is_ok() { |
646 | println!("rewriting {}", pretty_path.display()); | 644 | println!("rewriting {}", pretty_path.display()); |
647 | fs::write(path, actual).unwrap(); | 645 | fs::write(path, actual).unwrap(); |
648 | return; | 646 | return; |
diff --git a/docs/dev/README.md b/docs/dev/README.md index 2e4a45998..4cb5dfaa0 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -342,6 +342,12 @@ There are two kinds of tests: | |||
342 | The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for. | 342 | The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for. |
343 | If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test. | 343 | If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test. |
344 | 344 | ||
345 | To update test data, run with `UPDATE_EXPECTATIONS` variable: | ||
346 | |||
347 | ```bash | ||
348 | env UPDATE_EXPECTATIONS=1 cargo qt | ||
349 | ``` | ||
350 | |||
345 | # Logging | 351 | # Logging |
346 | 352 | ||
347 | Logging is done by both rust-analyzer and VS Code, so it might be tricky to | 353 | Logging is done by both rust-analyzer and VS Code, so it might be tricky to |