Add per-file discovery and run mode (fixes #2723)#2725
Draft
nohwnd wants to merge 1 commit into
Draft
Conversation
Adds Run.PerFileDiscovery option (default true) that discovers and runs each test container one at a time instead of discovering all first. This improves container isolation and reduces peak memory usage by releasing block trees after each container completes. The original batch behavior is preserved as a fallback when PerFileDiscovery is set to false. Refactored Invoke-Test into three functions: - Invoke-Test: dispatches based on PerFileDiscovery setting - Invoke-TestBatch: original discover-all-then-run-all flow - Invoke-TestPerFile: per-container discover-then-run loop - Invoke-ContainerDiscovery: single-container discovery helper Global plugin hooks (DiscoveryStart/End, RunStart/End) fire once around the full run. Per-container hooks (ContainerDiscoveryStart/End, ContainerRunStart/End) fire as before. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| $steps = $state.Plugin.RunStart | ||
| if ($null -ne $steps -and 0 -lt @($steps).Count) { | ||
| Invoke-PluginStep -Plugins $state.Plugin -Step RunStart -Context @{ | ||
| Blocks = @($allDiscovered | & $SafeCommands['ForEach-Object'] { $_.Block }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
Run.PerFileDiscoveryoption (defaulttrue) that discovers and runs each test container one at a time instead of discovering all containers first, then running all.Why: The current batch model (discover all → run all) accumulates module state and scope pollution across containers during discovery. Per-file mode isolates each container: discover it, run it, release it, move to the next.
What changed:
Run.PerFileDiscoveryboolean option (defaulttrue)Invoke-TestintoInvoke-TestBatch(original flow) andInvoke-TestPerFile(new flow)Invoke-ContainerDiscoveryextracted as a single-container discovery helperDiscoveryStart/End,RunStart/End) fire once around the full runFallback: Set
Run.PerFileDiscovery = $falseto revert to the original batch behavior.All 2285 tests pass in both modes.