mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-11-22 04:36:32 +00:00
Merge pull request #5977 from meilisearch/fix-rust-analyzer-false-positive
Fix error that rust-analyzer reports because it is compiling all code with the `test` cfg
This commit is contained in:
@@ -259,14 +259,23 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create an index scheduler and start its run loop.
|
/// Create an index scheduler and start its run loop.
|
||||||
#[allow(private_interfaces)] // because test_utils is private
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
options: IndexSchedulerOptions,
|
options: IndexSchedulerOptions,
|
||||||
auth_env: Env<WithoutTls>,
|
auth_env: Env<WithoutTls>,
|
||||||
from_db_version: (u32, u32, u32),
|
from_db_version: (u32, u32, u32),
|
||||||
runtime: Option<tokio::runtime::Handle>,
|
runtime: Option<tokio::runtime::Handle>,
|
||||||
#[cfg(test)] test_breakpoint_sdr: crossbeam_channel::Sender<(test_utils::Breakpoint, bool)>,
|
) -> Result<Self> {
|
||||||
#[cfg(test)] planned_failures: Vec<(usize, test_utils::FailureLocation)>,
|
let this = Self::new_without_run(options, auth_env, from_db_version, runtime)?;
|
||||||
|
|
||||||
|
this.run();
|
||||||
|
Ok(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_without_run(
|
||||||
|
options: IndexSchedulerOptions,
|
||||||
|
auth_env: Env<WithoutTls>,
|
||||||
|
from_db_version: (u32, u32, u32),
|
||||||
|
runtime: Option<tokio::runtime::Handle>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
std::fs::create_dir_all(&options.tasks_path)?;
|
std::fs::create_dir_all(&options.tasks_path)?;
|
||||||
std::fs::create_dir_all(&options.update_file_path)?;
|
std::fs::create_dir_all(&options.update_file_path)?;
|
||||||
@@ -321,8 +330,7 @@ impl IndexScheduler {
|
|||||||
|
|
||||||
wtxn.commit()?;
|
wtxn.commit()?;
|
||||||
|
|
||||||
// allow unreachable_code to get rids of the warning in the case of a test build.
|
Ok(Self {
|
||||||
let this = Self {
|
|
||||||
processing_tasks: Arc::new(RwLock::new(ProcessingTasks::new())),
|
processing_tasks: Arc::new(RwLock::new(ProcessingTasks::new())),
|
||||||
version,
|
version,
|
||||||
queue,
|
queue,
|
||||||
@@ -338,16 +346,32 @@ impl IndexScheduler {
|
|||||||
webhooks: Arc::new(webhooks),
|
webhooks: Arc::new(webhooks),
|
||||||
embedders: Default::default(),
|
embedders: Default::default(),
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)] // Will be replaced in `new_tests` in test environments
|
||||||
test_breakpoint_sdr,
|
test_breakpoint_sdr: crossbeam_channel::bounded(0).0,
|
||||||
#[cfg(test)]
|
#[cfg(test)] // Will be replaced in `new_tests` in test environments
|
||||||
planned_failures,
|
planned_failures: Default::default(),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
run_loop_iteration: Arc::new(RwLock::new(0)),
|
run_loop_iteration: Arc::new(RwLock::new(0)),
|
||||||
features,
|
features,
|
||||||
chat_settings,
|
chat_settings,
|
||||||
runtime,
|
runtime,
|
||||||
};
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create an index scheduler and start its run loop.
|
||||||
|
#[cfg(test)]
|
||||||
|
fn new_test(
|
||||||
|
options: IndexSchedulerOptions,
|
||||||
|
auth_env: Env<WithoutTls>,
|
||||||
|
from_db_version: (u32, u32, u32),
|
||||||
|
runtime: Option<tokio::runtime::Handle>,
|
||||||
|
test_breakpoint_sdr: crossbeam_channel::Sender<(test_utils::Breakpoint, bool)>,
|
||||||
|
planned_failures: Vec<(usize, test_utils::FailureLocation)>,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let mut this = Self::new_without_run(options, auth_env, from_db_version, runtime)?;
|
||||||
|
|
||||||
|
this.test_breakpoint_sdr = test_breakpoint_sdr;
|
||||||
|
this.planned_failures = planned_failures;
|
||||||
|
|
||||||
this.run();
|
this.run();
|
||||||
Ok(this)
|
Ok(this)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ impl IndexScheduler {
|
|||||||
std::fs::create_dir_all(&options.auth_path).unwrap();
|
std::fs::create_dir_all(&options.auth_path).unwrap();
|
||||||
let auth_env = open_auth_store_env(&options.auth_path).unwrap();
|
let auth_env = open_auth_store_env(&options.auth_path).unwrap();
|
||||||
let index_scheduler =
|
let index_scheduler =
|
||||||
Self::new(options, auth_env, version, None, sender, planned_failures).unwrap();
|
Self::new_test(options, auth_env, version, None, sender, planned_failures).unwrap();
|
||||||
|
|
||||||
// To be 100% consistent between all test we're going to start the scheduler right now
|
// To be 100% consistent between all test we're going to start the scheduler right now
|
||||||
// and ensure it's in the expected starting state.
|
// and ensure it's in the expected starting state.
|
||||||
|
|||||||
Reference in New Issue
Block a user