mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Update parser tests with env var
This commit is contained in:
parent
d739731830
commit
b5c4f2faa2
3 changed files with 11 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -342,6 +342,12 @@ There are two kinds of tests:
|
|||
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.
|
||||
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.
|
||||
|
||||
To update test data, run with `UPDATE_EXPECTATIONS` variable:
|
||||
|
||||
```bash
|
||||
env UPDATE_EXPECTATIONS=1 cargo qt
|
||||
```
|
||||
|
||||
# Logging
|
||||
|
||||
Logging is done by both rust-analyzer and VS Code, so it might be tricky to
|
||||
|
|
Loading…
Reference in a new issue