-
-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test discovery on linux fails to find tests in hidden folders #2515
Comments
Hi, thanks for the report. Pester discover files using You should see the same behavior on Windows by marking the folder as hidden, which is implicit for dot-prefixed items in Unix as you know. There's usually a reason something is marked as hidden, so defaulting to including them feels wrong IMO. May I ask why not just rename the dot-prefixed folder in tst to unhide it? Related #2327 |
Hi You'd have to ask github why they use the I am following the convention recommended here: https://pester.dev/docs/usage/file-placement-and-naming to place my tests " in a separate tests directory that follows the same directory structure as the main src directory." I would expect Pester to act consistently on different operating systems - if that means you always exclude folders that are considered "hidden" on one from the other operating system too then I would expect to have the ability to override that behaviour so that I can follow the recommded guidelines for test placement. |
It's a common practice used to hide config, caches etc. from application code. Both to hide clutter and avoid accidental modifications because they're hidden on Unix.
Keep in mind that it's just a generic recommendation, which coincidentally was written while only Windows was supported. Since you're working cross-platform I'd suggest renaming the folder to I'll update the page with a note about dot-prefixed files and folders being hidden on Unix. Will also have to update docs about the behavior of hidden files/folders.
Having a IMO it's a lot easier to use explicit include paths for the very rare exceptions than having to maintain a potentially growing list of |
This is a convention we follow anyway for all of our tests across all of our languages, unless there specifically isn't support for that. I think an
For one of our repos as an example, our Thanks |
I'm gonna have to disagree on this. Pester follows PowerShell's default behavior which adheres to the underlying OS and filesystem so we're consistent with other software on the same machine. Special-casing unix behavior in Windows will only cause confusion and unix can't read NTFS's Hidden attribute at all. Pester is already consistent by excluding hidden items on every platform. Filesystem differences like how hidden is defined is just one of those things users need to be aware of when writing cross-platform PowerShell-code. Just like paths should use relative paths or environment variables for known locations, and forward-slash as directory separator to support both Windows and Unix filesystems.
Using
Having hidden folders are very rare for code meant to be found, so this is likely the only scenario you'll need it. Workaround is simple and explictly including the rare static exceptions is easier than excluding other potentially generated items Personally I'd like to avoid configuration bloat, at least until we get more requests for this. Thoughts @nohwnd ? |
Fair enough about your opinion on consistency - everyone has their own opinion - I favour consistency for the developer, particularly when it becomes a "silent failure" - you have a bunch of tests, some in a
I tried this initially but the
Except if you are writing github actions and reusable workflows, in which case it becomes very common because of the |
I am going to side with OP here. I think it is reasonable to either include hidden folders by default, with exclusion to I am not sure how to best expose this change to users, to me this is a "bug" on our side, so I would not object to fixing it in v5 without special flag to opt out. |
Checklist
What is the issue?
I am writing tests for github actions which are in the
.github
folder so my tests are intests/.github
Invoke-Pester
does not find these tests unless I explicitly specifytests/.github
This works fine in windows powershell core but not in linux powershell core
I am using pester v5.6.0
Expected Behavior
Invoke-Pester
finds all tests in all folders, including hidden folders, without having to explicitly specify the folder nameThis should work in linux and in windows
Steps To Reproduce
Invoke-Pester
from the parent folderObserve that the test is discovered in windows but not in linux
Describe your environment
Working (in windows):
Not working (in WSL2 Ubuntu)
Possible Solution?
No response
The text was updated successfully, but these errors were encountered: