Skip to content

Fix #2515: Include hidden folders in test discovery on Linux#2693

Draft
nohwnd wants to merge 1 commit intopester:mainfrom
nohwnd:fix-2515-hidden-folders
Draft

Fix #2515: Include hidden folders in test discovery on Linux#2693
nohwnd wants to merge 1 commit intopester:mainfrom
nohwnd:fix-2515-hidden-folders

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented Apr 3, 2026

Fix #2515

Added -Force to Get-ChildItem calls in Find-File so hidden (dot-prefixed) folders like .github are included in test discovery on Linux.

Copilot-generated fix.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented Apr 3, 2026

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.

@nohwnd nohwnd force-pushed the fix-2515-hidden-folders branch from 6b33792 to e11f22b Compare April 3, 2026 10:17
# 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))"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

powershell is slash agnostic, just use "$onepath/$otherpath" join-path is just noise. You onnly need to pay attention when you use .net apis.

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented Apr 3, 2026

I see no test for excluding .git folder, which has lot of files that we are almost 100% sure to not care about.

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented Apr 3, 2026

🤖 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>
@nohwnd nohwnd force-pushed the fix-2515-hidden-folders branch from e11f22b to a47e8c6 Compare April 3, 2026 13:59
$filteredFiles = foreach ($f in $files) {
# normalize backslashes for cross-platform ease of use
$normalizedPath = $f.FullName -replace "/", "\"
$dominated = $false
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test discovery on linux fails to find tests in hidden folders

1 participant