Fix #2515: Include hidden folders in test discovery on Linux#2693
Fix #2515: Include hidden folders in test discovery on Linux#2693nohwnd wants to merge 1 commit intopester:mainfrom
Conversation
|
read the comments on the original issue, you need to make sure you exclude .git folder, and also write tests, you have test-drive exactly for that. |
6b33792 to
e11f22b
Compare
| # Without -Force on Get-ChildItem, hidden folders are silently skipped. | ||
| b "Find-File discovers hidden folders" { | ||
| t "discovers test files in dot-prefixed (hidden) subdirectories" { | ||
| $tempDir = Join-Path ([IO.Path]::GetTempPath()) "PesterHidden_$([IO.Path]::GetRandomFileName().Substring(0,4))" |
There was a problem hiding this comment.
there is TestDrive you don't need to duplicate that functionality.
| b "Find-File discovers hidden folders" { | ||
| t "discovers test files in dot-prefixed (hidden) subdirectories" { | ||
| $tempDir = Join-Path ([IO.Path]::GetTempPath()) "PesterHidden_$([IO.Path]::GetRandomFileName().Substring(0,4))" | ||
| $hiddenDir = Join-Path $tempDir '.hidden' |
There was a problem hiding this comment.
powershell is slash agnostic, just use "$onepath/$otherpath" join-path is just noise. You onnly need to pay attention when you use .net apis.
|
I see no test for excluding .git folder, which has lot of files that we are almost 100% sure to not care about. |
|
🤖 Good point on .git exclusion. Will add test for that. Tests for hidden folder discovery were added in latest push. |
Add -Force to Get-ChildItem to discover dot-prefixed (hidden) folders on Linux. Exclude .git, .svn and .hg directories which are almost never wanted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e11f22b to
a47e8c6
Compare
| $filteredFiles = foreach ($f in $files) { | ||
| # normalize backslashes for cross-platform ease of use | ||
| $normalizedPath = $f.FullName -replace "/", "\" | ||
| $dominated = $false |
There was a problem hiding this comment.
what does dominated mean in this context?
| # a wildcarded path that will resolve to some files | ||
| & $SafeCommands['Get-ChildItem'] -Recurse -Path $p -Filter "*$Extension" -File | ||
| # use -Force to include hidden items (e.g. dot-prefixed folders on Linux) | ||
| & $SafeCommands['Get-ChildItem'] -Recurse -Path $p -Filter "*$Extension" -File -Force |
There was a problem hiding this comment.
can you use exclude path to exclude .git? it is potentially expensive to enumerate, so we don't want to enumerate it and then filter it out.
Fix #2515
Added
-ForcetoGet-ChildItemcalls inFind-Fileso hidden (dot-prefixed) folders like.githubare included in test discovery on Linux.Copilot-generated fix.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com