Skip to content

Commit

Permalink
Move suite working directories to {working_directory}/suites
Browse files Browse the repository at this point in the history
This avoids potential conflicts with other folders in the working
directory.
  • Loading branch information
jherbel committed Oct 30, 2023
1 parent 794b9b7 commit f333443
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions v2/robotmk/src/config/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ pub fn from_external_config(
.into_iter()
.map(|(suite_name, suite_config)| Suite {
name: suite_name.clone(),
working_directory: external_config.working_directory.join(&suite_name),
working_directory: external_config
.working_directory
.join("suites")
.join(&suite_name),
results_file: suite_results_directory(&external_config.results_directory)
.join(format!("{}.json", suite_name)),
execution_config: suite_config.execution_config,
Expand Down Expand Up @@ -139,7 +142,7 @@ mod tests {
assert_eq!(global_config.rcc_binary_path, "/bin/rcc");
assert_eq!(suites.len(), 2);
assert_eq!(suites[0].name, "rcc");
assert_eq!(suites[0].working_directory, "/working/rcc");
assert_eq!(suites[0].working_directory, "/working/suites/rcc");
assert_eq!(suites[0].results_file, "/results/suites/rcc.json");
assert_eq!(
suites[0].execution_config,
Expand Down Expand Up @@ -175,7 +178,7 @@ mod tests {
})
);
assert_eq!(suites[1].name, "system");
assert_eq!(suites[1].working_directory, "/working/system");
assert_eq!(suites[1].working_directory, "/working/suites/system");
assert_eq!(suites[1].results_file, "/results/suites/system.json");
assert_eq!(
suites[1].execution_config,
Expand Down
10 changes: 8 additions & 2 deletions v2/robotmk/src/setup/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ use std::collections::HashSet;
use std::fs::{create_dir_all, remove_file};

pub fn setup(global_config: &GlobalConfig, suites: &[Suite]) -> Result<()> {
setup_working_directories(&global_config.working_directory)?;
setup_working_directories(&global_config.working_directory, suites)?;
setup_results_directories(global_config, suites)
}

fn setup_working_directories(working_directory: &Utf8Path) -> Result<()> {
fn setup_working_directories(working_directory: &Utf8Path, suites: &[Suite]) -> Result<()> {
create_dir_all(working_directory).context("Failed to create working directory")?;
for suite in suites {
create_dir_all(&suite.working_directory).context(format!(
"Failed to create working directory {} of suite {}",
suite.working_directory, suite.name
))?;
}
create_dir_all(environment_building_stdio_directory(working_directory))
.context("Failed to create environment building stdio directory")?;
adjust_working_directory_permissions(working_directory)
Expand Down

0 comments on commit f333443

Please sign in to comment.