Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move suite working directories to {working_directory}/suites #399

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 20 additions & 9 deletions v2/robotmk/src/setup/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,31 @@ use std::collections::HashSet;
use std::fs::{create_dir_all, remove_file};

pub fn setup(global_config: &GlobalConfig, suites: &[Suite]) -> Result<()> {
create_dir_all(&global_config.working_directory)
.context("Failed to create working directory")?;
create_dir_all(environment_building_stdio_directory(
&global_config.working_directory,
))
.context("Failed to create environment building stdio directory")?;
setup_working_directories(&global_config.working_directory, suites)?;
setup_results_directories(global_config, suites)
}

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)
.context("Failed adjust working directory permissions")
}

fn setup_results_directories(global_config: &GlobalConfig, suites: &[Suite]) -> Result<()> {
create_dir_all(&global_config.results_directory)
.context("Failed to create results directory")?;
create_dir_all(suite_results_directory(&global_config.results_directory))
.context("Failed to create suite results directory")?;
clean_up_results_directory_atomic(global_config, suites)
.context("Failed to clean up results directory")?;
adjust_working_directory_permissions(&global_config.working_directory)
.context("Failed adjust working directory permissions")
.context("Failed to clean up results directory")
}

fn clean_up_results_directory_atomic(global_config: &GlobalConfig, suites: &[Suite]) -> Result<()> {
Expand Down