Skip to content

Commit

Permalink
Clear working directory for RCC-specific setup
Browse files Browse the repository at this point in the history
This avoids reading deprecated files by mistake, which can mislead the
scheduler into believing that the setup was successful even though it
actually failed.
  • Loading branch information
jherbel committed Nov 8, 2023
1 parent 9c1c6ea commit 20a969a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions v2/robotmk/src/bin/scheduler/setup/rcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ use camino::{Utf8Path, Utf8PathBuf};
use log::{debug, error};
use robotmk::section::WriteSection;
use std::collections::HashMap;
use std::fs::create_dir_all;
use std::fs::{create_dir_all, remove_dir_all};

pub fn setup(global_config: &GlobalConfig, suites: Vec<Suite>) -> Result<Vec<Suite>> {
adjust_rcc_binary_permissions(&global_config.rcc_binary_path)
.context("Failed to adjust permissions of RCC binary")?;
create_dir_all(rcc_setup_working_directory(
clear_rcc_setup_working_directory(&rcc_setup_working_directory(
&global_config.working_directory,
))
.context("Failed to create working directory for RCC setup")?;
))?;

let (rcc_suites, mut surviving_suites): (Vec<Suite>, Vec<Suite>) = suites
.into_iter()
Expand All @@ -35,6 +34,15 @@ fn adjust_rcc_binary_permissions(executable_path: &Utf8Path) -> Result<()> {
))
}

fn clear_rcc_setup_working_directory(working_directory: &Utf8Path) -> Result<()> {
remove_dir_all(working_directory).context(format!(
"Failed to remove working directory for RCC setup: {working_directory}"
))?;
create_dir_all(working_directory).context(format!(
"Failed to create working directory for RCC setup: {working_directory}"
))
}

fn rcc_setup_working_directory(working_directory: &Utf8Path) -> Utf8PathBuf {
working_directory.join("rcc_setup")
}
Expand Down

0 comments on commit 20a969a

Please sign in to comment.