Skip to content

Commit

Permalink
Linter to suggest stdlib->assert for test assertions
Browse files Browse the repository at this point in the history
Summary: The `assert` library provides more powerful assertions, which are compatible with the `stdlib` ones.

Reviewed By: alanz

Differential Revision: D51981040

fbshipit-source-id: 1dba0cd82cd6f32ffc09673d05caee432977b504
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Dec 14, 2023
1 parent d4300bc commit 4fc1cbd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion crates/ide/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,29 @@ use crate::NavigationTarget;

#[track_caller]
pub(crate) fn check_ct_fix(fixture_before: &str, fixture_after: &str) {
let config = DiagnosticsConfig::new(
true,
FxHashSet::default(),
vec![],
Arc::new(LintsFromConfig::default()),
)
.disable(DiagnosticCode::MissingCompileWarnMissingSpec)
.disable(DiagnosticCode::UndefinedFunction);
check_ct_fix_with_config(fixture_before, fixture_after, config);
}

#[track_caller]
pub(crate) fn check_ct_fix_with_config(
fixture_before: &str,
fixture_after: &str,
config: DiagnosticsConfig,
) {
let after = trim_indent(fixture_after);
let (analysis, pos) = fixture::position(fixture_before);
let project_id = analysis.project_id(pos.file_id).unwrap().unwrap();
let _ = analysis.db.ensure_erlang_service(project_id);

check_no_parse_errors(&analysis, pos.file_id);
check_no_parse_errors_with_config(&analysis, pos.file_id, config);

let diagnostic = diagnostics::ct_diagnostics(&analysis.db, pos.file_id)
.iter()
Expand Down Expand Up @@ -263,6 +280,15 @@ pub fn check_no_parse_errors(analysis: &Analysis, file_id: FileId) {
)
.disable(DiagnosticCode::MissingCompileWarnMissingSpec)
.disable(DiagnosticCode::UndefinedFunction);
check_no_parse_errors_with_config(analysis, file_id, config);
}

#[track_caller]
pub fn check_no_parse_errors_with_config(
analysis: &Analysis,
file_id: FileId,
config: DiagnosticsConfig,
) {
let diags = analysis.diagnostics(&config, file_id, true).unwrap();
assert!(
diags.is_empty(),
Expand Down

0 comments on commit 4fc1cbd

Please sign in to comment.