Skip to content

Commit 4aa19d3

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Add @OTPVersionDependent tag support for tests
Summary: **The core change is in `main.rs`** There is no need for most snapshots to be generated for 3 different OTP versions. Only `custom.erl` needs it. Add support for tag `OTPVersionDependent`, similarly to `generated`, to toggle this behaviour. Add tag to `custom.erl` (on an existing line so as to not change the lines of error messages). Reviewed By: michalmuskala Differential Revision: D85602616 fbshipit-source-id: 4c85ecb3e2337d60cf83d13b7449e1b20246d9ed
1 parent 719f5e2 commit 4aa19d3

File tree

428 files changed

+25
-29104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+25
-29104
lines changed

crates/elp/src/bin/main.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,30 @@ mod tests {
434434
.unwrap();
435435

436436
let otp_version = OTP_VERSION.as_ref().expect("MISSING OTP VERSION");
437-
let exp_path = expect_file!(format!(
438-
"../resources/test/{}/{}/{}-OTP-{}.pretty",
439-
project,
440-
app,
441-
module.as_str(),
442-
otp_version,
443-
));
437+
let otp_version_regex =
438+
regex::bytes::Regex::new(&format!("{}OTPVersionDependent", "@"))
439+
.unwrap();
440+
let contents = analysis.file_text(file_id).unwrap();
441+
let otp_version_dependent = otp_version_regex
442+
.is_match(&contents.as_bytes()[0..(2001.min(contents.len()))]);
443+
let exp_path = {
444+
if otp_version_dependent {
445+
expect_file!(format!(
446+
"../resources/test/{}/{}/{}-OTP-{}.pretty",
447+
project,
448+
app,
449+
module.as_str(),
450+
otp_version,
451+
))
452+
} else {
453+
expect_file!(format!(
454+
"../resources/test/{}/{}/{}.pretty",
455+
project,
456+
app,
457+
module.as_str(),
458+
))
459+
}
460+
};
444461
let (stdout, _) = cli.to_strings();
445462
assert_normalised_file(exp_path, &stdout, project_path.into(), false);
446463
}

crates/elp/src/resources/test/eqwalizer_tests/check/any_fun_type-OTP-27.pretty

Lines changed: 0 additions & 116 deletions
This file was deleted.

crates/elp/src/resources/test/eqwalizer_tests/check/any_fun_type-OTP-28.pretty

Lines changed: 0 additions & 116 deletions
This file was deleted.

crates/elp/src/resources/test/eqwalizer_tests/check/apply_none-OTP-27.pretty

Lines changed: 0 additions & 24 deletions
This file was deleted.

crates/elp/src/resources/test/eqwalizer_tests/check/apply_none-OTP-28.pretty

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)