Report which Pester.BeforeContainer.ps1 files applied to a container - #3028
Merged
Conversation
Run.SkipRun returns the discovered tree without executing anything, which is the path the VS Code Test Explorer uses to populate. It goes through Discover-Test, a batch discovery over all containers, and that function never took the BeforeContainer map, so it called Invoke-ContainerDiscovery without -BeforeContainerFile. A file whose discovery depends on the setup discovered fine in a normal run and came back empty when only discovery was requested. Discover-Test now takes the same map the interleaved discover -> run path gets, and resolves it per container, because which files apply depends on where the container is after #2993. Find-Test forwards it too. The per container lookup was written inline in Invoke-Test and is now a function that both paths call, so they cannot drift apart again. That also removes the case-insensitive variable name trap the inline version needed a comment to explain. Fix #3008 🤖
…recontainer # Conflicts: # docs/NEXT-RELEASE.md
See #3026. This PR appending to the shared list is what causes the conflicts. 🤖
A container's setup comes from every Pester.BeforeContainer.ps1 between Run.RepoRoot and the test file's own folder, and nothing in the result said which ones were used. That makes "where did this function come from" unanswerable from the outside: opening tests/unit/Foo.Tests.ps1 shows no BeforeAll and gives no sign that two folder setups ran before it. Reading the directory tree is not enough either, because #pester:no-inherit can cut the chain short. The applied files are on the container now, outermost first, matching the order they ran in. On the container rather than the block, because it is a property of the file being run, and post-processors already walk containers. Fix #3007
…ed-setup-files # Conflicts: # tst/Pester.RSpec.Parallel.ts.ps1
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.
Fix #3007
A container's setup comes from every
Pester.BeforeContainer.ps1betweenRun.RepoRootand the test file's own folder, and nothing in the result said which ones were used. Openingtests/unit/Foo.Tests.ps1shows noBeforeAlland gives no sign that two folder setups ran before it. Reading the directory tree does not answer it either, because#pester:no-inheritcan cut the chain short.The applied files are on the container now, outermost first, in the order they ran:
D.Tests.ps1sits under a folder marked#pester:no-inherit, so it reports only its own file. That is the case the folder tree cannot tell you.On the container rather than the block, as the issue suggested. It is a property of the file being run, post-processors already walk containers, and it leaves the block model unchanged.
Verification
tst/Pester.RSpec.Parallel.ts.ps147/47,tst/Pester.RSpec.ts.ps1128/128.Two tests added next to the other cascade tests, one for the full chain and one for the
#pester:no-inherittruncation.I checked that
Remove-RSpecNonPublicPropertiesdoes not drop the new property. Its property lists are commented out, it only nulls the plugin fields, so the property survives toPassThru.🤖