Skip to content

Commit

Permalink
move get_local_executor out of self
Browse files Browse the repository at this point in the history
Summary:
This and few later diffs are just mechanical work of disconnecting functions from self. In other words self.foo(..) => Self::foo(..).
We need it because we will be calling this functions from inside dice and there won't be access to the orchestrator

Reviewed By: blackm00n

Differential Revision: D64111539

fbshipit-source-id: 153ed77490b9c053b2037e3202bb0dc3effb6cde
  • Loading branch information
perehonchuk authored and facebook-github-bot committed Oct 9, 2024
1 parent 4cea6f9 commit d740496
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/buck2_test/src/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl<'a> BuckTestOrchestrator<'a> {
} = test_executable_expanded;
let executor_preference = self.executor_preference(supports_re)?;
let required_resources = if test_executor.is_local_execution_possible(executor_preference) {
let setup_local_resources_executor = self.get_local_executor(&fs).await?;
let setup_local_resources_executor = Self::get_local_executor(&self.dice, &fs).await?;
let simple_stage = match stage.as_ref() {
TestStage::Listing(_) => TestStageSimple::Listing,
TestStage::Testing { .. } => TestStageSimple::Testing,
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<'a> TestOrchestrator for BuckTestOrchestrator<'a> {

// In contrast from actual test execution we do not check if local execution is possible.
// We leave that decision to actual local execution runner that requests local execution preparation.
let setup_local_resources_executor = self.get_local_executor(&fs).await?;
let setup_local_resources_executor = Self::get_local_executor(&self.dice, &fs).await?;
let setup_contexts = {
let executor_fs = setup_local_resources_executor.executor_fs();
required_local_resources_setup_contexts(
Expand Down Expand Up @@ -923,7 +923,10 @@ impl<'b> BuckTestOrchestrator<'b> {
Ok(executor)
}

async fn get_local_executor(&self, fs: &ArtifactFs) -> anyhow::Result<CommandExecutor> {
async fn get_local_executor(
dice: &DiceTransaction,
fs: &ArtifactFs,
) -> anyhow::Result<CommandExecutor> {
let executor_config = CommandExecutorConfig {
executor: Executor::Local(LocalExecutorOptions::default()),
options: CommandGenerationOptions {
Expand All @@ -936,8 +939,7 @@ impl<'b> BuckTestOrchestrator<'b> {
platform,
cache_checker: _,
cache_uploader: _,
} = self
.dice
} = dice
.clone()
.get_command_executor_from_dice(&executor_config)
.await?;
Expand Down

0 comments on commit d740496

Please sign in to comment.