-
Notifications
You must be signed in to change notification settings - Fork 382
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
Allow paths to be pipelined to Invoke-ScriptAnalyzer #1040
Changes from 5 commits
3a3ff48
13310ea
669a1a9
7c8bcc0
b035b4d
6208566
a5c84bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ if (-not (Test-PSEditionCoreCLR)) | |
$null,"Wow6432Node" | ForEach-Object { | ||
try | ||
{ | ||
Set-ItemProperty -Name "DisablePromptToUpdateHelp" -Path "HKLM:\SOFTWARE\$($_)\Microsoft\PowerShell" -Value 1 -Force | ||
Set-ItemProperty -Name "DisablePromptToUpdateHelp" -Path "HKLM:\SOFTWARE\$($_)\Microsoft\PowerShell" -Value 1 -Force -ErrorAction SilentlyContinue | ||
} | ||
catch | ||
{ | ||
|
@@ -66,7 +66,7 @@ Describe "Test importing correct customized rules" { | |
$null,"Wow6432Node" | ForEach-Object { | ||
try | ||
{ | ||
Set-ItemProperty -Name "DisablePromptToUpdateHelp" -Path "HKLM:\SOFTWARE\$($_)\Microsoft\PowerShell" -Value 1 -Force | ||
Set-ItemProperty -Name "DisablePromptToUpdateHelp" -Path "HKLM:\SOFTWARE\$($_)\Microsoft\PowerShell" -Value 1 -Force -EA SilentlyContinue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit: Use |
||
} | ||
catch | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,22 @@ Describe "Test Path" { | |
Remove-PSDrive $freeDriveName | ||
$numFilesResult | Should -Be $numFilesExpected | ||
} | ||
} | ||
} | ||
|
||
Context "When piping in files" { | ||
It "Can be piped in from a string" { | ||
$piped = ("$directory\TestScript.ps1" | Invoke-ScriptAnalyzer) | ||
$explicit = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 | ||
|
||
$piped.Count -eq $explicit.Count | Should -BeTrue | ||
} | ||
|
||
It "Can be piped from Get-ChildItem" { | ||
$piped = ( Get-ChildItem -Path $directory -Filter TestTestPath*.ps1 | Invoke-ScriptAnalyzer) | ||
$explicit = Invoke-ScriptAnalyzer -Path $directory\TestTestPath*.ps1 | ||
$piped.Count -eq $explicit.Count | Should -BeTrue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would result in a much better error message if the test fails: $piped.Count | Should -Be $explicit.Count |
||
} | ||
} | ||
} | ||
|
||
Context "When given a directory" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate on the error that you were getting that led you to apply this change? On which environment (platform and ps version) did you see it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running tests in non-elevated windows powershell on Windows 10. Despite the try/catch errors are shown when this fails to update HKLM key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the info. This does not happen on my machine, I am wondering if this could be caused by some group policy in your environment. Although it seems that this test code should reviewed again and possibly refactored, I think we can still accept your changes to it.