Add before_each_task and after_each_task support#1127
Add before_each_task and after_each_task support#1127SamuelMarks wants to merge 8 commits intosagiegurari:masterfrom
before_each_task and after_each_task support#1127Conversation
…onfigSection` `struct` ; [src/lib/execution_plan.rs] Implement `before_each_task` and `after_each_task` via interspersal of steps
…er_each` in `cli::descriptor::load` ; [src/lib/execution_plan.rs] Return to using the already parsed out before|after each
…or the before_each and after_each tasks
| for (name, _) in config.tasks.iter() { | ||
| match name.as_str() { | ||
| "before_each" => config.config.before_each_task = Some(name.to_string()), | ||
| "after_each" => config.config.after_each_task = Some(name.to_string()), | ||
| _ => {} | ||
| } |
There was a problem hiding this comment.
what does this loop actually do? what does it mutate?
meaning are you setting config.before_each_task="before_each"? if so why loop? why not just configure it? why the naming magic?
There was a problem hiding this comment.
I couldn't figure out how to else get the before_each_task and after_each_task to be populated. Tried a bunch of solutions, this is the only one that seemed to make it accessible to future locations (specifically src/lib/execution_plan.rs).
src/lib/execution_plan.rs
Outdated
| let end_special = HashSet::from(["end", "end_task"]); | ||
| interspersed_steps.extend(steps.into_iter().flat_map(|e| -> Vec<Step> { | ||
| let mut _steps = Vec::<Step>::with_capacity(before_and_after_each_len + 1); | ||
| if before_special.contains(e.name.as_str()) { |
There was a problem hiding this comment.
maybe i'm not following this right but you are only pushing an additional task for the init/end tasks but not for other tasks instead of the opposite?
There was a problem hiding this comment.
The logic is:
- add a
before_each(if exists) before each task; followed by anafter_each(if exists) after each task
With two addenda:
- if the task is the
inittask and thebefore_eachtask exists, don't prepend thebefore_each - else if the task is the
endtask and theafter_eachtask exists, don't append theafter_each
# Conflicts: # Cargo.lock
…r_each` tasks ; [src/lib/execution_plan_test.rs] Add tests for `before_each` and `after_each`
|
Is this ready to be committed? I recommend calling it |
WiP (works but needs tests)
Use cases this facilitates:
cargo-makeas library: task exection in asynchronous persistent queues #1110)beforeEachandafterEachin your test-frameworks)