From e811a20ab4757f444784e9fa6aa4d7d029cb2d4f Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 13 May 2024 12:40:09 -0400 Subject: [PATCH] Start testing default action. --- src/workflow.rs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/src/workflow.rs b/src/workflow.rs index 9747fdb..90d0c22 100644 --- a/src/workflow.rs +++ b/src/workflow.rs @@ -1331,6 +1331,20 @@ command = "c" assert_eq!(submit_options.partition, Some("i".to_string())); } + #[test] + #[parallel] + fn default_action_from() { + let temp = TempDir::new().unwrap(); + let workflow = r#" +[default.action] +from = "a" +"#; + let result = Workflow::open_str(temp.path(), workflow); + assert!(result.is_err()); + + assert!(result.unwrap_err().to_string().contains("asdf")); + } + #[test] #[parallel] fn empty_action_default() { @@ -1358,7 +1372,64 @@ command = "c" assert_eq!(action.from, None); } -// TODO: Test action default all keys + #[test] + #[parallel] + fn action_default() { + let temp = TempDir::new().unwrap(); + let workflow = r#" +[default.action] +name = "a" +command = "b" +launchers = ["c"] +previous_actions = ["d"] +products = ["e"] + +[default.action.resources] +processes.per_directory = 2 +threads_per_process = 3 +gpus_per_process = 4 +walltime.per_submission = "00:00:01" + +# submit_options is tested above + +[default.action.group] +include = [["/f", "equal_to", 5]] +sort_by = ["/g"] +split_by_sort_key = true +reverse_sort = true +maximum_size = 6 +submit_whole = true + +[[action]] + +[[action]] +name = "d" +"#; + + let workflow = Workflow::open_str(temp.path(), workflow).unwrap(); + + assert_eq!(workflow.action.len(), 2); + + let action = workflow.action.first().unwrap(); + assert_eq!(action.name(), "a"); + assert_eq!(action.command(), "b"); + assert_eq!(action.launchers(), vec!["c"]); + assert_eq!(action.previous_actions(), vec!["d"]); + assert_eq!(action.products(), vec!["e"]); + assert_eq!(action.resources.processes(), Processes::PerDirectory(2)); + assert_eq!(action.resources.threads_per_process, Some(3)); + assert_eq!(action.resources.gpus_per_process, Some(4)); + assert_eq!(action.resources.walltime(), Walltime::PerSubmission(Duration::new(true, 0, 1, 0).unwrap())); + assert!(action.submit_options.is_empty()); + assert_eq!(action.group.include, vec![("/f".into(), Comparison::EqualTo, serde_json::Value::from(5))]); + assert_eq!(action.group.sort_by, vec!["/g"]); + assert!(action.group.split_by_sort_key); + assert!(action.group.reverse_sort); + assert_eq!(action.group.maximum_size, Some(6)); + assert!(action.group.submit_whole); + assert_eq!(action.from, None); + } + // TODO: Test action from all keys // TODO: Test action override from // TODO: Test action override default