Skip to content
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

Exclude duplicate files for Run.Path and CodeCoverage.Path #2535

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Jul 8, 2024

PR Summary

Updates Find-File and Get-CodeCoverageFilePaths internal functions to exclude duplicate files when provided overlapping Path values to search in. This affects:

  • Test file paths provided using -Path / Run.Path
  • Code Coverage source file paths provided using -CodeCoverage / CodeCoverage.Path
  • Containers created using New-PesterContainer -Path ..
    • Mulitple containers can still call the same file, e.g. to invoke it with different Data (parameters)

PR also:

  • Refactors Get-CodeCoverageFilePaths to use Get-ChildItem -File -Recurse for increased performance.
  • Refactors New-PesterContainer to avoid multiple filesystem searches when provided array of Data for increased performance.

Fix #2530

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

# Deduplicate files if overlapping -Path values
$uniquePaths = [System.Collections.Generic.HashSet[string]]::new(@($files).Count)
$uniqueFiles = foreach ($f in $files) { if ($uniquePaths.Add($f.FullName)) { $f } }
Filter-Excluded -Files $uniqueFiles -ExcludePath $ExcludePath | & $SafeCommands['Where-Object'] { $_ }

Check notice

Code scanning / PSScriptAnalyzer

The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like foreach/for-keyword etc.`. Note

The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like foreach/for-keyword etc.`.
@fflaten
Copy link
Collaborator Author

fflaten commented Jul 8, 2024

@nohwnd CI disabled in AzDO?

@fflaten
Copy link
Collaborator Author

fflaten commented Jul 8, 2024

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@nohwnd nohwnd merged commit 99760df into pester:main Jul 10, 2024
11 checks passed
@nohwnd
Copy link
Member

nohwnd commented Jul 10, 2024

/backport to rel/5.6.x

Copy link

Started backporting to rel/5.6.x: https://github.com/pester/Pester/actions/runs/9879992903

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.

Deduplicate files provided using Run.Path and -Path?
2 participants