Skip to content

Commit 79c3348

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Support for OTP version specific tests
Summary: Remove the tag `OTPVersionDependent` which created one expected result per OTP version per snapshot. Instead, use `OTPXXOnly` (where `XX` is a version number), that skips checks for OTP versions that are not `XX`. In practice, it's used as `OTP27Only` for now. Reviewed By: michalmuskala, TD5 Differential Revision: D89378687 fbshipit-source-id: 0421622d825ac4e8f393d32529c01eb17577b5e5
1 parent 7057624 commit 79c3348

File tree

9 files changed

+26
-5158
lines changed

9 files changed

+26
-5158
lines changed

crates/elp/src/bin/main.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -443,33 +443,34 @@ mod tests {
443443
})
444444
.unwrap();
445445

446+
let exp_path = expect_file!(format!(
447+
"../resources/test/{}/{}/{}.pretty",
448+
project,
449+
app,
450+
module.as_str(),
451+
));
452+
let (stdout, _) = cli.to_strings();
453+
446454
let otp_version = OTP_VERSION.as_ref().expect("MISSING OTP VERSION");
447455
let otp_version_regex =
448-
regex::bytes::Regex::new(&format!("{}OTPVersionDependent", "@"))
449-
.unwrap();
456+
regex::bytes::Regex::new(&format!("{}OTP([0-9]+)Only", "@")).unwrap();
450457
let contents = analysis.file_text(file_id).unwrap();
451-
let otp_version_dependent = otp_version_regex
452-
.is_match(&contents.as_bytes()[0..(2001.min(contents.len()))]);
453-
let exp_path = {
454-
if otp_version_dependent {
455-
expect_file!(format!(
456-
"../resources/test/{}/{}/{}-OTP-{}.pretty",
457-
project,
458-
app,
459-
module.as_str(),
460-
otp_version,
461-
))
462-
} else {
463-
expect_file!(format!(
464-
"../resources/test/{}/{}/{}.pretty",
465-
project,
466-
app,
467-
module.as_str(),
468-
))
458+
let otp_version_capture = otp_version_regex
459+
.captures(&contents.as_bytes()[0..(2001.min(contents.len()))]);
460+
if let Some((_, [otp_version_only])) =
461+
otp_version_capture.map(|cap| cap.extract())
462+
{
463+
if otp_version_only == otp_version.as_bytes() {
464+
assert_normalised_file(
465+
exp_path,
466+
&stdout,
467+
project_path.into(),
468+
false,
469+
);
469470
}
470-
};
471-
let (stdout, _) = cli.to_strings();
472-
assert_normalised_file(exp_path, &stdout, project_path.into(), false);
471+
} else {
472+
assert_normalised_file(exp_path, &stdout, project_path.into(), false);
473+
}
473474
}
474475
}
475476
EqwalizerDiagnostics::NoAst { module } => {

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

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

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

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

crates/elp/src/resources/test/eqwalizer_tests/check/callbacks3_neg-OTP-26.pretty renamed to crates/elp/src/resources/test/eqwalizer_tests/check/callbacks3_neg.pretty

File renamed without changes.

0 commit comments

Comments
 (0)