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

Fix parameter default values leaking to Data in user-provided Container #2362

Merged
merged 3 commits into from
Jun 7, 2023

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Jun 5, 2023

PR Summary

Always create new Container-objects during runtime to avoid mutating reusable input/configuration.

Fix #2357

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)

src/Main.ps1 Outdated
$containers += $c
if (any $PesterPreference.Run.Container.Value) {
# Running through New-BlockContainerObject again to avoid modifying original container and it's Data during runtime
$containers += @($PesterPreference.Run.Container.Value | & $SafeCommands['ForEach-Object'] { New-BlockContainerObject -Container $_ })

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.`.

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.`.
@nohwnd
Copy link
Member

nohwnd commented Jun 7, 2023

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

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

Feel free to ignore the nit if you want and merge.

src/Main.ps1 Outdated Show resolved Hide resolved
@fflaten fflaten merged commit bb175b4 into pester:main Jun 7, 2023
@fflaten fflaten deleted the fix-containerDataLeakv2 branch June 7, 2023 15:44
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.

Pester container data dictionary object gets populated with test parameters after invoke-pester
2 participants