Open martincostello opened 1 year ago
Good catch! Looks like we currently ignore hidden items for both test files and CC paths, including hidden files when a folder is specified. What would be the desired behavior?
1) Only include hidden items that are explicitly named? 2) Always include hidden items, including hidden files when a folder is specified
Leaning towards option 1 myself as I'd expect there's a reason someone would make items hidden in the first place. 🙂
1 sounds sensible to me.
Hi
I think that Pester should behave consistently across operating systems - I reported in #2515 that we see tests/.github
tests being recognised on windows but not on linux.
A disadvantage or your item 1 suggest is that this means that all test folders following the recommended structure will have to be explicitly named, which makes it more of a chore. For example if I have this structure
.github
foo
tests
\.github
\foo
Then currently, on windows I can either not specify a location at all and all my tests will run or simply Invoke-Pester tests
to get all the tests under tests
to be found.
If the only way I can get my .github
tests to be discovered on linux is to specify them at the command line then either I have to Invoke-Pester tests,tests/.github
in which case they run twice, which is not desirable, or I have to Invoke-Pester tests/foo,tests/.github
which means if I now want to add folder bar
then I have to remember to add this one to the command line explicitly, which is error prone as it relies on prior knowledge of the engineer to "just know" to have to do this.
Workable options for me would include:
tests/.github
whether a folder is specified or not, possibly with an option to disable test discovery in "hidden" folders tests/.github
whether a folder is specified or not if a command line option specifically enables searching in a hidden folder.Invoke-Pester
would not find tests/.github
but Invoke-Pester tests
wouldMy preference is for the first option, but regardless of which one is selected, the behaviour should be consistent across operating systems. Our use case is we are writing scripts which might be run on windows or on linux so we want to test them in both operating systems.
Thanks
Checklist
What is the issue?
I have a project where I'm using pester where I use a dot-prefixed folder to provide a sample in a directory to ensure it sorts first above a sequential list of numbers for other directory names, for example:
If I explicitly add all folders into the
CodeCoverage.Path
setting of the Pester configuration like so, specifying-Force
to ensure hidden folders are returned (because of the.
prefix):Then Pester fails before tests start to run with an error similar to the below:
Expected Behavior
Pester successfully runs code coverage and the tests.
Steps To Reproduce
No response
Describe your environment
From WSL on Windows 11 running Ubuntu 22.04:
This also occurs in a Linux container running Ubuntu in GitHub Actions, which is where I originally found the issue as I have a Windows development machine and the issue was not apparent there due to the different handling of folders with a
.
prefix.Possible Solution?
From a cursory look at the code pointed to by the stack trace, it looks like
-Force
would needed to be passed through to this call toGet-Item
so the directories/files are found?https://github.com/pester/Pester/blob/d81fdbc46318d6c3486c241fa82d9749df5c2031/src/functions/Coverage.ps1#L231