Skip to content

Commit

Permalink
Flakiness: Introduce a lock to serialise check_type test
Browse files Browse the repository at this point in the history
Summary:
Tests using this function are occasionally failing in CI.
I suspect it is because of running more than one erlang_service instance at the same time.
Protect the function with a lock to check the hypothesis.
It may not help, because other tests using the erlang_service have a static connection.
Dealing with that will be step 2 if this does not help.

Differential Revision: D54631248

fbshipit-source-id: 842f601c815524bfa84957f959a7ac2cc36452bf
  • Loading branch information
alanz authored and facebook-github-bot committed Mar 8, 2024
1 parent 9636560 commit e5a9a9d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/ide/src/codemod_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,16 @@ pub(crate) fn find_call_in_function<T, U>(
#[cfg(test)]
mod tests {

use std::sync::Mutex;

use elp_ide_db::elp_base_db::FileId;
use elp_ide_db::elp_base_db::SourceDatabase;
use elp_syntax::algo::find_node_at_offset;
use elp_syntax::ast;
use hir::FunctionDef;
use hir::InFile;
use hir::Semantic;
use lazy_static::lazy_static;

use super::find_call_in_function;
use super::FunctionMatch;
Expand Down Expand Up @@ -760,6 +763,15 @@ mod tests {

#[track_caller]
fn check_type(fixture: &str) {
// We are seeing flaky tests in CI related to this test
// function. T181455753.
// It is potentially a race condition, where the erlang
// service is not fully re-entrant. Protect against this with a lock, for now
lazy_static! {
static ref CHECK_TYPE_GLOBAL_LOCK: Mutex<()> = Mutex::new(());
}
let _guard = CHECK_TYPE_GLOBAL_LOCK.lock();

let (db, position, _diagnostics_enabled, expected) = fixture::db_annotations(fixture);
let host = AnalysisHost { db };
let sema = Semantic::new(&host.db);
Expand Down

0 comments on commit e5a9a9d

Please sign in to comment.