FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add tests for #1504 PSUseUsingScopeModifierInNewRunspaces by o-l-a-v · Pull Request #2005 · PowerShell/PSScriptAnalyzer · GitHub

Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ps1  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ Describe "UseUsingScopeModifierInNewRunspaces" {
}

Context "Should not detect anything" {

It "should not emit anything for: <Description>" {
[System.Array] $warnings = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptBlock -Settings $settings
$warnings.Count | Should -Be 0
Expand Down Expand Up @@ -278,20 +277,41 @@ Describe "UseUsingScopeModifierInNewRunspaces" {
# Issue 1492: https://github.com/PowerShell/PSScriptAnalyzer/issues/1492
@{
Description = 'Does not throw when the same variable name is used in two different sessions'
ScriptBlock = @'
function Get-One{
Invoke-Command -Session $sourceRemoteSession {
$a = $sccmModule
foo $a
}
}
function Get-Two{
Invoke-Command -Session $sourceRemoteSession {
$a = $sccmModule
foo $a
}
}
'@
ScriptBlock = '{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

thanks for making it more readable :-)

function Get-One {
Invoke-Command -Session -ScriptBlock $sourceRemoteSession {
$a = $sccmModule
foo $a
}
}
function Get-Two {
Invoke-Command -Session -ScriptBlock $sourceRemoteSession {
$a = $sccmModule
foo $a
}
}
}'
}
# ScriptBlock with variables in params(), issue #1504: https://github.com/PowerShell/PSScriptAnalyzer/issues/1504
## Microsoft.PowerShell.Core \ Start-Job
@{
Description = 'Does not warn when variable is defined inside param() - Start-Job'
ScriptBlock = '{
Start-Job -ScriptBlock {
Param($Foo)
$Foo
} -ArgumentList "Bar" | Receive-Job -Wait -AutoRemoveJob
}'
}
## Microsoft.PowerShell.ThreadJob \ Start-ThreadJob
@{
Description = 'Does not warn when variable is defined inside param() - Start-Job'
ScriptBlock = '{
Start-ThreadJob -ScriptBlock {
Param($Foo)
$Foo
} -ArgumentList "Bar" | Receive-Job -Wait -AutoRemoveJob
}'
}
)
}
Expand Down

Back | FazBrowse Home | New Git URL