From 4f5bb462683dea730535d89da3cdde174300d987 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 18:36:47 +0000 Subject: [PATCH 01/35] Remove BOM, insert newline at EOF --- .../powershell/Language/Scripting/DeserializedMethods.Tests.ps1 | 2 +- test/powershell/Language/Scripting/TestsOnWinFullOnly.ps1 | 2 +- .../Microsoft.PowerShell.Security/AmsiInterface.Tests.ps1 | 2 +- .../ConstrainedLanguageDebugger.Tests.ps1 | 2 +- .../ConstrainedLanguageModules.Tests.ps1 | 2 +- .../ConstrainedLanguageValidation.Tests.ps1 | 2 +- .../Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 2 +- test/powershell/Modules/ThreadJob/ThreadJob.Tests.ps1 | 2 +- .../engine/Remoting/ImplicitRemotingBatching.Tests.ps1 | 2 +- test/powershell/engine/Security/UntrustedDataMode.Tests.ps1 | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1 b/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1 index 4677c92cc2..2bb454d131 100644 --- a/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1 +++ b/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1 @@ -18,4 +18,4 @@ Describe "DeserializedMethods" -Tags "CI" { $d | Get-Member -MemberType *Method* Add | Should -BeNullOrEmpty } -} \ No newline at end of file +} diff --git a/test/powershell/Language/Scripting/TestsOnWinFullOnly.ps1 b/test/powershell/Language/Scripting/TestsOnWinFullOnly.ps1 index 3a273c02b8..9c7954a9cc 100644 --- a/test/powershell/Language/Scripting/TestsOnWinFullOnly.ps1 +++ b/test/powershell/Language/Scripting/TestsOnWinFullOnly.ps1 @@ -29,4 +29,4 @@ function Run-TestOnWinFull } } -} \ No newline at end of file +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/AmsiInterface.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/AmsiInterface.Tests.ps1 index ebff106cbf..6c2bd3bbc1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/AmsiInterface.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/AmsiInterface.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. try diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageDebugger.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageDebugger.Tests.ps1 index 80781ca218..29a67919c1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageDebugger.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageDebugger.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. ## diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 index 865f43f3db..f71ca5e102 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. ## diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageValidation.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageValidation.Tests.ps1 index f148b2fb72..68b55bc0ea 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageValidation.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageValidation.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. ## diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index dc7c63a448..b60c3d1b46 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # This is a Pester test suite which validate the Web cmdlets. diff --git a/test/powershell/Modules/ThreadJob/ThreadJob.Tests.ps1 b/test/powershell/Modules/ThreadJob/ThreadJob.Tests.ps1 index ba1087e4d7..fa582ca877 100644 --- a/test/powershell/Modules/ThreadJob/ThreadJob.Tests.ps1 +++ b/test/powershell/Modules/ThreadJob/ThreadJob.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Helper function to wait for job to reach a running or completed state diff --git a/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 b/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 index ba094ba12c..0b9ed14f3c 100644 --- a/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 +++ b/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. Describe "TestImplicitRemotingBatching hook should correctly batch simple remote command pipelines" -Tag 'Feature','RequireAdminOnWindows' { diff --git a/test/powershell/engine/Security/UntrustedDataMode.Tests.ps1 b/test/powershell/engine/Security/UntrustedDataMode.Tests.ps1 index e6e766ba70..8ae3e1012e 100644 --- a/test/powershell/engine/Security/UntrustedDataMode.Tests.ps1 +++ b/test/powershell/engine/Security/UntrustedDataMode.Tests.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. Describe "UntrustedDataMode tests for variable assignments" -Tags 'CI' { From d58e1ff13b2d470b6d812d9f57d561c96afb1056 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:04:32 +0000 Subject: [PATCH 02/35] Correct case of $MyInvocation special variable --- .../Parser/LanguageAndParser.TestFollowup.Tests.ps1 | 2 +- test/powershell/Language/Scripting/Delegates.Tests.ps1 | 2 +- .../Implicit.Remoting.Tests.ps1 | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/powershell/Language/Parser/LanguageAndParser.TestFollowup.Tests.ps1 b/test/powershell/Language/Parser/LanguageAndParser.TestFollowup.Tests.ps1 index 4095477871..949cc6a15a 100644 --- a/test/powershell/Language/Parser/LanguageAndParser.TestFollowup.Tests.ps1 +++ b/test/powershell/Language/Parser/LanguageAndParser.TestFollowup.Tests.ps1 @@ -137,7 +137,7 @@ Describe "Assign automatic variables" -Tags "CI" { & { [object]$this = 1; $this } | Should -Be 1 & { [object]$input = 1; $input } | Should -Be 1 # Can't test PSCmdlet or PSBoundParameters, they use an internal type - & { [System.Management.Automation.InvocationInfo]$myInvocation = $myInvocation; $myInvocation.Line } | Should -Match Automation.InvocationInfo + & { [System.Management.Automation.InvocationInfo]$MyInvocation = $MyInvocation; $MyInvocation.Line } | Should -Match Automation.InvocationInfo & { [string]$PSScriptRoot = 'abc'; $PSScriptRoot } | Should -BeExactly 'abc' & { [string]$PSCommandPath = 'abc'; $PSCommandPath } | Should -BeExactly 'abc' } diff --git a/test/powershell/Language/Scripting/Delegates.Tests.ps1 b/test/powershell/Language/Scripting/Delegates.Tests.ps1 index 1b3b2e6e4c..6f3919dde9 100644 --- a/test/powershell/Language/Scripting/Delegates.Tests.ps1 +++ b/test/powershell/Language/Scripting/Delegates.Tests.ps1 @@ -4,7 +4,7 @@ Describe 'Test for conversion b/w script block and delegate' -Tags "CI" { BeforeAll { function lineno { - $myInvocation.ScriptLineNumber + $MyInvocation.ScriptLineNumber } function Generate-ArgumentTypesAndParameters diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 index 620ee95dde..3280b11936 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 @@ -857,7 +857,7 @@ try $ipaddress ) - "Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)" + "Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)" } } @@ -898,7 +898,7 @@ try $ipaddress ) - "Bound parameter: $($myInvocation.BoundParameters.Keys)" + "Bound parameter: $($MyInvocation.BoundParameters.Keys)" } } @@ -939,7 +939,7 @@ try $ipaddress ) - "Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)" + "Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)" } } @@ -990,7 +990,7 @@ try $PriorityClass ) - "Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)" + "Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)" } } @@ -1036,7 +1036,7 @@ try $ipaddress ) - "Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)" + "Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)" } } From fbe459d480677099ef0d68038ae9c065b685f817 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:05:05 +0000 Subject: [PATCH 03/35] Correct case of $OFS special variable --- .../Join-String.Tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Join-String.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Join-String.Tests.ps1 index 20829d621d..4f4bdedf9e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Join-String.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Join-String.Tests.ps1 @@ -25,13 +25,13 @@ Describe "Join-String" -Tags "CI" { } It "Should join property values with default separator" { - $expected = $testObject.Name -join $ofs + $expected = $testObject.Name -join $OFS $actual = $testObject | Join-String -Property Name $actual | Should -BeExactly $expected } It "Should join property values positionally with default separator" { - $expected = $testObject.Name -join $ofs + $expected = $testObject.Name -join $OFS $actual = $testObject | Join-String Name $actual | Should -BeExactly $expected } @@ -69,7 +69,7 @@ Describe "Join-String" -Tags "CI" { It "Should join script block results with default separator" { $sb = {$_.Name + $_.Length} - $expected = ($testObject | ForEach-Object $sb) -join $ofs + $expected = ($testObject | ForEach-Object $sb) -join $OFS $actual = $testObject | Join-String -Property $sb $actual | Should -BeExactly $expected } @@ -83,13 +83,13 @@ Describe "Join-String" -Tags "CI" { It "Should join script block results SingleQuoted" { $sb = {$_.Name + $_.Length} - $expected = ($testObject | ForEach-Object $sb).ForEach{"'$_'"} -join $ofs + $expected = ($testObject | ForEach-Object $sb).ForEach{"'$_'"} -join $OFS $actual = $testObject | Join-String -Property $sb -SingleQuote $actual | Should -BeExactly $expected } It "Should join script block results DoubleQuoted" { $sb = {$_.Name + $_.Length} - $expected = ($testObject | ForEach-Object $sb).ForEach{"""$_"""} -join $ofs + $expected = ($testObject | ForEach-Object $sb).ForEach{"""$_"""} -join $OFS $actual = $testObject | Join-String -Property $sb -DoubleQuote $actual | Should -BeExactly $expected } @@ -102,7 +102,7 @@ Describe "Join-String" -Tags "CI" { } It "Should Handle OutputPrefix and OutputSuffix" { - $ofs = ',' + $OFS = ',' $expected = "A 1,2,3 B" $actual = 1..3 | Join-String -OutputPrefix "A " -OutputSuffix " B" $actual | Should -BeExactly $expected From f86f30cf64c2198014844b3ce63e934efb96b975 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:13:53 +0000 Subject: [PATCH 04/35] Correct case of $NestedPromptLevel special variable --- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index def8e0ca6b..a95f294682 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -571,7 +571,7 @@ foo } It "Redirected input w/ nested prompt" -Pending:($IsWindows) { - $si = NewProcessStartInfo "-noprofile -noexit -c ""`$function:prompt = { 'PS' + ('>'*(`$nestedPromptLevel+1)) + ' ' }""" -RedirectStdIn + $si = NewProcessStartInfo "-noprofile -noexit -c ""`$function:prompt = { 'PS' + ('>'*(`$NestedPromptLevel+1)) + ' ' }""" -RedirectStdIn $process = RunPowerShell $si $process.StandardInput.Write("`$host.EnterNestedPrompt()`n") $process.StandardOutput.ReadLine() | Should -Be "PS> `$host.EnterNestedPrompt()" From 89e33f577255543aaaf52ba192ebbb98201469c8 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:15:17 +0000 Subject: [PATCH 05/35] Correct case of $Matches special variable --- build.psm1 | 4 ++-- demos/rest/rest.ps1 | 2 +- .../Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 | 2 +- .../Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1 | 4 ++-- .../CompatiblePSEditions.Module.Tests.ps1 | 2 +- test/tools/Modules/HttpListener/HttpListener.psm1 | 4 ++-- .../azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1 | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.psm1 b/build.psm1 index c9bdf4c689..913fbe35bc 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2385,7 +2385,7 @@ function Copy-PSGalleryModules $cache = dotnet nuget locals global-packages -l if ($cache -match "info : global-packages: (.*)") { - $nugetCache = $matches[1] + $nugetCache = $Matches[1] } else { throw "Can't find nuget global cache" @@ -2400,7 +2400,7 @@ function Copy-PSGalleryModules # Remove the build revision from the src (nuget drops it). $srcVer = if ($version -match "(\d+.\d+.\d+).0") { - $matches[1] + $Matches[1] } elseif ($version -match "^\d+.\d+$") { # Two digit versions are stored as three digit versions "$version.0" diff --git a/demos/rest/rest.ps1 b/demos/rest/rest.ps1 index db9867e8d2..3f2364f950 100644 --- a/demos/rest/rest.ps1 +++ b/demos/rest/rest.ps1 @@ -24,7 +24,7 @@ function Get-Issue { if ($link -match '\s*<(.*)>;\s+rel="next"') { - $uri = $matches[1] + $uri = $Matches[1] } } } diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 3b3dbd6481..7bb841711e 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -228,7 +228,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" { $lastexitcode '111' -Match '1' $Matches - $mAtches + $Matches $Error[0] $error $pwd diff --git a/test/powershell/Language/Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1 b/test/powershell/Language/Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1 index e6d313e5cb..5176056fe5 100644 --- a/test/powershell/Language/Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1 +++ b/test/powershell/Language/Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1 @@ -50,9 +50,9 @@ Describe 'Native UNIX globbing tests' -tags "CI" { } # Test globbing with absolute paths - it shouldn't turn absolute paths into relative paths (#7089) It 'Should not normalize absolute paths' { - $matches = /bin/echo /etc/* + $Matches = /bin/echo /etc/* # Matched path should start with '/etc/' not '../..' - $matches.substring(0,5) | Should -Be '/etc/' + $Matches.substring(0,5) | Should -Be '/etc/' } It 'Globbing should not happen with quoted expressions' { $v = "$TESTDRIVE/abc*" diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 4954bcff04..2047337c84 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -515,7 +515,7 @@ Describe "PSModulePath changes interacting with other PowerShell processes" -Tag It "Does not duplicate the System32 module path in subprocesses" { $sys32ModPathCount = & $pwsh -C { - & "$PSHOME/pwsh" -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count' + & "$PSHOME/pwsh" -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $Matches.Count' } $sys32ModPathCount | Should -Be 1 diff --git a/test/tools/Modules/HttpListener/HttpListener.psm1 b/test/tools/Modules/HttpListener/HttpListener.psm1 index 3c8dc4bb32..a3e83ce45d 100644 --- a/test/tools/Modules/HttpListener/HttpListener.psm1 +++ b/test/tools/Modules/HttpListener/HttpListener.psm1 @@ -69,8 +69,8 @@ Function Start-HTTPListener { { if ($segment -match "\??(?\w*)(=(?.*?))?$") { - $name = $matches["name"] - $value = $matches["value"] + $name = $Matches["name"] + $value = $Matches["value"] if ($null -ne $value) { $value = [System.Web.HttpUtility]::UrlDecode($value) diff --git a/tools/releaseBuild/azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1 b/tools/releaseBuild/azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1 index b5d932d5c3..8a2d98f473 100644 --- a/tools/releaseBuild/azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1 +++ b/tools/releaseBuild/azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1 @@ -124,7 +124,7 @@ function NormalizeVersion { param ([string] $version) $sVer = if ($version -match "(\d+.\d+.\d+).0") { - $matches[1] + $Matches[1] } elseif ($version -match "^\d+.\d+$") { # Two digit versions are stored as three digit versions "$version.0" From 04b292ab3b5c5830b2bfc1969638e6d0a6e3c4cc Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:15:45 +0000 Subject: [PATCH 06/35] Correct case of $LASTEXITCODE special variable --- demos/crontab/CronTab/CronTab.psm1 | 2 +- .../Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/crontab/CronTab/CronTab.psm1 b/demos/crontab/CronTab/CronTab.psm1 index 15fedb5207..617641518e 100644 --- a/demos/crontab/CronTab/CronTab.psm1 +++ b/demos/crontab/CronTab/CronTab.psm1 @@ -56,7 +56,7 @@ function Invoke-CronTab ([String] $user, [String[]] $arguments, [Switch] $noThro Write-Verbose "Running: $crontabcmd $arguments" $output = & $crontabcmd @arguments 2>&1 - if ($LastExitCode -ne 0 -and -not $noThrow) { + if ($LASTEXITCODE -ne 0 -and -not $noThrow) { $e = New-Object System.InvalidOperationException -ArgumentList $output.Exception.Message throw $e } else { diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 7bb841711e..2ddf23804a 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -225,7 +225,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" { [void] m() { $LASTEXITCODE - $lastexitcode + $LASTEXITCODE '111' -Match '1' $Matches $Matches From 7dd922abe514a6fd7b47eb715516200cc07741ed Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:16:45 +0000 Subject: [PATCH 07/35] Correct case of $StackTrace special variable --- build.psm1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index 913fbe35bc..1efc15b05e 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1398,14 +1398,14 @@ function Show-PSPesterError $description = $testFailure.description $name = $testFailure.name $message = $testFailure.failure.message - $stackTrace = $testFailure.failure."stack-trace" + $StackTrace = $testFailure.failure."stack-trace" } elseif ($PSCmdLet.ParameterSetName -eq 'object') { $description = $testFailureObject.Describe + '/' + $testFailureObject.Context $name = $testFailureObject.Name $message = $testFailureObject.FailureMessage - $stackTrace = $testFailureObject.StackTrace + $StackTrace = $testFailureObject.StackTrace } else { @@ -1417,7 +1417,7 @@ function Show-PSPesterError Write-Log -Error "message:" Write-Log -Error $message Write-Log -Error "stack-trace:" - Write-Log -Error $stackTrace + Write-Log -Error $StackTrace } @@ -1455,14 +1455,14 @@ function Test-XUnitTestResults $description = $failure.test.type $name = $failure.test.method $message = $failure.test.failure.message.'#cdata-section' - $stackTrace = $failure.test.failure.'stack-trace'.'#cdata-section' + $StackTrace = $failure.test.failure.'stack-trace'.'#cdata-section' Write-Log -Error ("Description: " + $description) Write-Log -Error ("Name: " + $name) Write-Log -Error "message:" Write-Log -Error $message Write-Log -Error "stack-trace:" - Write-Log -Error $stackTrace + Write-Log -Error $StackTrace } throw "$($failedTests.failed) tests failed" From 6663261238158a58b95f593c9f02982efc05299b Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:17:48 +0000 Subject: [PATCH 08/35] Correct case of $args special variable --- .../ConstrainedLanguageRestriction.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index a8b0fb4fe8..9c369798a5 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -470,7 +470,7 @@ try BeforeAll { - function VulnerableFunctionFromFullLanguage { Invoke-Expression $Args[0] } + function VulnerableFunctionFromFullLanguage { Invoke-Expression $args[0] } $TestCasesIEX = @( @{testName = "Verifies direct Invoke-Expression does not bypass constrained language mode"; From 66e0f08ec2f673e4aba20a1e82ac9a0b792b4d52 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:18:14 +0000 Subject: [PATCH 09/35] Correct case of $this special variable --- test/tools/Modules/WebListener/WebListener.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/Modules/WebListener/WebListener.psm1 b/test/tools/Modules/WebListener/WebListener.psm1 index a411282902..7e0c5807d4 100644 --- a/test/tools/Modules/WebListener/WebListener.psm1 +++ b/test/tools/Modules/WebListener/WebListener.psm1 @@ -13,7 +13,7 @@ Class WebListener [String] GetStatus() { - return $This.Job.JobStateInfo.State + return $this.Job.JobStateInfo.State } } From a051666baf32c1405f8893936e3719ad10f2fbf0 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:18:44 +0000 Subject: [PATCH 10/35] Correct case of $input special variable --- .../Operators/PipelineChainOperator.Tests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/powershell/Language/Operators/PipelineChainOperator.Tests.ps1 b/test/powershell/Language/Operators/PipelineChainOperator.Tests.ps1 index 1447837bc3..dfac35d1bb 100644 --- a/test/powershell/Language/Operators/PipelineChainOperator.Tests.ps1 +++ b/test/powershell/Language/Operators/PipelineChainOperator.Tests.ps1 @@ -14,12 +14,12 @@ Describe "Experimental Feature: && and || operators - Feature-Enabled" -Tag CI { param( [Parameter(ValueFromPipeline)] [object[]] - $Input + $input ) - if ($Input -ne 2) + if ($input -ne 2) { - return $Input + return $input } $exception = [System.Exception]::new("NTERROR") @@ -222,12 +222,12 @@ filter Test-NonTerminatingError param( [Parameter(ValueFromPipeline)] [object[]] - $Input + $input ) - if ($Input -ne 2) + if ($input -ne 2) { - return $Input + return $input } $exception = [System.Exception]::new("NTERROR") @@ -241,11 +241,11 @@ filter Test-NonTerminatingError filter Test-PipelineTerminatingError { [CmdletBinding()] - param([Parameter(ValueFromPipeline)][int[]]$Input) + param([Parameter(ValueFromPipeline)][int[]]$input) - if ($Input -ne 4) + if ($input -ne 4) { - return $Input + return $input } $exception = [System.Exception]::new("PIPELINE") From 42d50434f89d19fc96c9412cf2a6889338c1b63c Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:19:12 +0000 Subject: [PATCH 11/35] Correct case of $PSCmdlet special variable --- build.psm1 | 10 +++++----- demos/crontab/CronTab/CronTab.psm1 | 2 +- test/packaging/windows/msi.tests.ps1 | 2 +- .../Scripting/CommonParameters.Tests.ps1 | 12 ++++++------ .../Scripting/OutErrorVariable.Tests.ps1 | 14 +++++++------- test/tools/Modules/PSSysLog/PSSysLog.psm1 | 4 ++-- tools/WindowsCI.psm1 | 2 +- tools/packaging/packaging.psm1 | 16 ++++++++-------- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build.psm1 b/build.psm1 index 1efc15b05e..7565e369c6 100644 --- a/build.psm1 +++ b/build.psm1 @@ -289,7 +289,7 @@ function Start-PSBuild { [switch]$Detailed ) - if ($PsCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore) + if ($PSCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore) { $PSModuleRestore = $true } @@ -1393,14 +1393,14 @@ function Show-PSPesterError [PSCustomObject]$testFailureObject ) - if ($PSCmdLet.ParameterSetName -eq 'xml') + if ($PSCmdlet.ParameterSetName -eq 'xml') { $description = $testFailure.description $name = $testFailure.name $message = $testFailure.failure.message $StackTrace = $testFailure.failure."stack-trace" } - elseif ($PSCmdLet.ParameterSetName -eq 'object') + elseif ($PSCmdlet.ParameterSetName -eq 'object') { $description = $testFailureObject.Describe + '/' + $testFailureObject.Context $name = $testFailureObject.Name @@ -1488,7 +1488,7 @@ function Test-PSPesterResults [switch] $CanHaveNoResult ) - if($PSCmdLet.ParameterSetName -eq 'file') + if($PSCmdlet.ParameterSetName -eq 'file') { if(!(Test-Path $TestResultsFile)) { @@ -1515,7 +1515,7 @@ function Test-PSPesterResults throw "$($x.'test-results'.failures) tests in $TestArea failed" } } - elseif ($PSCmdLet.ParameterSetName -eq 'PesterPassThruObject') + elseif ($PSCmdlet.ParameterSetName -eq 'PesterPassThruObject') { if ($ResultObject.TotalCount -le 0 -and -not $CanHaveNoResult) { diff --git a/demos/crontab/CronTab/CronTab.psm1 b/demos/crontab/CronTab/CronTab.psm1 index 617641518e..1b5bcfb2b7 100644 --- a/demos/crontab/CronTab/CronTab.psm1 +++ b/demos/crontab/CronTab/CronTab.psm1 @@ -125,7 +125,7 @@ function Remove-CronJob { $e = New-Object System.Exception -ArgumentList "Job not found" throw $e } - if ($Force -or $pscmdlet.ShouldProcess($Job.Command,"Remove")) { + if ($Force -or $PSCmdlet.ShouldProcess($Job.Command,"Remove")) { Import-CronTab -user $UserName -crontab $newcrontab } } diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 4ffb73a08d..b61153bf39 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -28,7 +28,7 @@ function Invoke-Msiexec { [HashTable] $Properties ) - $action = "$($PsCmdlet.ParameterSetName)ing" + $action = "$($PSCmdlet.ParameterSetName)ing" if ($Install.IsPresent) { $switch = '/I' } else { diff --git a/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 b/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 index 374c128a3e..414de3637d 100644 --- a/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 +++ b/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 @@ -154,7 +154,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding(SupportsShouldProcess=$true)] param() - if($pscmdlet.shouldprocess("foo", "foo action")) + if($PSCmdlet.shouldprocess("foo", "foo action")) { write-output "foo action" } @@ -205,7 +205,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding(supportsshouldprocess=$true, ConfirmImpact="none")] param() - if($pscmdlet.shouldprocess("foo", "foo action")) + if($PSCmdlet.shouldprocess("foo", "foo action")) { write-output "foo action" } @@ -239,7 +239,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="low")] param() - if($pscmdlet.shouldprocess("foo", "foo action")) + if($PSCmdlet.shouldprocess("foo", "foo action")) { write-output "foo action" } @@ -274,7 +274,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="medium")] param() - if($pscmdlet.shouldprocess("foo", "foo action")) + if($PSCmdlet.shouldprocess("foo", "foo action")) { write-output "foo action" } @@ -310,7 +310,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="high")] param() - if($pscmdlet.shouldprocess("foo", "foo action")) + if($PSCmdlet.shouldprocess("foo", "foo action")) { write-output "foo action" } @@ -346,7 +346,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" { [CmdletBinding()] param() - if($pscmdlet.shouldcontinue("foo", "foo action")) + if($PSCmdlet.shouldcontinue("foo", "foo action")) { write-output "foo action" } diff --git a/test/powershell/Language/Scripting/OutErrorVariable.Tests.ps1 b/test/powershell/Language/Scripting/OutErrorVariable.Tests.ps1 index 78289b9cac..cda7f2eec9 100644 --- a/test/powershell/Language/Scripting/OutErrorVariable.Tests.ps1 +++ b/test/powershell/Language/Scripting/OutErrorVariable.Tests.ps1 @@ -16,7 +16,7 @@ Describe "Tests OutVariable only" -Tags "CI" { [CmdletBinding()] param() - $pscmdlet.writeobject("foo") + $PSCmdlet.writeobject("foo") } function get-bar @@ -35,7 +35,7 @@ Describe "Tests OutVariable only" -Tags "CI" { OutVariable = 'a'; Expected = 'foo' }, - @{ Name = 'Updating OutVariable Case 2: $pscmdlet.writeobject'; + @{ Name = 'Updating OutVariable Case 2: $PSCmdlet.writeobject'; Command = "get-foo2"; OutVariable = 'a'; Expected = 'foo' @@ -46,7 +46,7 @@ Describe "Tests OutVariable only" -Tags "CI" { PreSet = 'a','b'; Expected = @("a", "b", "foo") }, - @{ Name = 'Appending OutVariable Case 2: $pscmdlet.writeobject'; + @{ Name = 'Appending OutVariable Case 2: $PSCmdlet.writeobject'; Command = "get-foo2"; OutVariable = 'a'; PreSet = 'a','b'; @@ -92,7 +92,7 @@ Describe "Test ErrorVariable only" -Tags "CI" { [CmdletBinding()] param() - $pscmdlet.WriteError($script:foo[0]) + $PSCmdlet.WriteError($script:foo[0]) } function get-bar @@ -111,7 +111,7 @@ Describe "Test ErrorVariable only" -Tags "CI" { ErrorVariable = 'a'; Expected = 'foo' }, - @{ Name = 'Updating ErrorVariable Case 2: $pscmdlet.WriteError'; + @{ Name = 'Updating ErrorVariable Case 2: $PSCmdlet.WriteError'; Command = "get-foo1"; ErrorVariable = 'a'; Expected = 'foo' @@ -140,7 +140,7 @@ Describe "Test ErrorVariable only" -Tags "CI" { $a | Should -BeExactly $Expected } - It 'Appending ErrorVariable Case 2: $pscmdlet.writeerror' { + It 'Appending ErrorVariable Case 2: $PSCmdlet.writeerror' { write-error "foo" -errorVariable script:foo 2> $null $a = 'a','b' @@ -193,7 +193,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" { [CmdletBinding()] param() - $pscmdlet.WriteError($script:foo[0]) + $PSCmdlet.WriteError($script:foo[0]) } function get-bar diff --git a/test/tools/Modules/PSSysLog/PSSysLog.psm1 b/test/tools/Modules/PSSysLog/PSSysLog.psm1 index ba4b88a5ac..287ae8511f 100644 --- a/test/tools/Modules/PSSysLog/PSSysLog.psm1 +++ b/test/tools/Modules/PSSysLog/PSSysLog.psm1 @@ -1079,7 +1079,7 @@ function Wait-PSWinEvent         foreach ($thisRecord in (get-winevent -FilterHashtable $filterHashtable -Oldest 2> $null))         { - if($PsCmdlet.ParameterSetName -eq "ByPropertyName") + if($PSCmdlet.ParameterSetName -eq "ByPropertyName") { if ($thisRecord."$propertyName" -like "*$propertyValue*") { @@ -1094,7 +1094,7 @@ function Wait-PSWinEvent } } - if($PsCmdlet.ParameterSetName -eq "ByPropertyIndex") + if($PSCmdlet.ParameterSetName -eq "ByPropertyIndex") { if ($thisRecord.Properties[$propertyIndex].Value -eq $propertyValue) { diff --git a/tools/WindowsCI.psm1 b/tools/WindowsCI.psm1 index 7c0c02265e..8450f3e74e 100644 --- a/tools/WindowsCI.psm1 +++ b/tools/WindowsCI.psm1 @@ -65,7 +65,7 @@ function Add-UserToGroup $userAD = [ADSI] "WinNT://$env:computername/${username},user" - if($PsCmdlet.ParameterSetName -eq "SID") + if($PSCmdlet.ParameterSetName -eq "SID") { $ntAccount=ConvertTo-NtAccount $groupSid $group =$ntAccount.Split("\\")[1] diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 19f8882bc7..e973159897 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -774,7 +774,7 @@ function New-UnixPackage { # Setup staging directory so we don't change the original source directory $Staging = "$PSScriptRoot/staging" - if ($pscmdlet.ShouldProcess("Create staging folder")) { + if ($PSCmdlet.ShouldProcess("Create staging folder")) { New-StagingFolder -StagingPath $Staging } @@ -793,7 +793,7 @@ function New-UnixPackage { } $linkSource = "/tmp/pwsh" - if ($pscmdlet.ShouldProcess("Create package file system")) + if ($PSCmdlet.ShouldProcess("Create package file system")) { # refers to executable, does not vary by channel New-Item -Force -ItemType SymbolicLink -Path $linkSource -Target "$Destination/pwsh" > $null @@ -833,7 +833,7 @@ function New-UnixPackage { if ($Type -eq "osxpkg") { Write-Log "Adding macOS launch application..." - if ($pscmdlet.ShouldProcess("Add macOS launch application")) + if ($PSCmdlet.ShouldProcess("Add macOS launch application")) { # Generate launcher app folder $AppsFolder = New-MacOSLauncher -Version $Version @@ -870,14 +870,14 @@ function New-UnixPackage { # Build package try { - if ($pscmdlet.ShouldProcess("Create $type package")) { + if ($PSCmdlet.ShouldProcess("Create $type package")) { Write-Log "Creating package with fpm..." $Output = Start-NativeExecution { fpm $Arguments } } } finally { if ($Environment.IsMacOS) { Write-Log "Starting Cleanup for mac packaging..." - if ($pscmdlet.ShouldProcess("Cleanup macOS launcher")) + if ($PSCmdlet.ShouldProcess("Cleanup macOS launcher")) { Clear-MacOSLauncher } @@ -901,7 +901,7 @@ function New-UnixPackage { $createdPackage = Get-Item (Join-Path $PWD (($Output[-1] -split ":path=>")[-1] -replace '["{}]')) if ($Environment.IsMacOS) { - if ($pscmdlet.ShouldProcess("Add distribution information and Fix PackageName")) + if ($PSCmdlet.ShouldProcess("Add distribution information and Fix PackageName")) { $createdPackage = New-MacOsDistributionPackage -FpmPackage $createdPackage -IsPreview:$IsPreview } @@ -1469,7 +1469,7 @@ function New-ZipPackage if (Get-Command Compress-Archive -ErrorAction Ignore) { - if ($pscmdlet.ShouldProcess("Create zip package")) + if ($PSCmdlet.ShouldProcess("Create zip package")) { Compress-Archive -Path $PackageSourcePath\* -DestinationPath $zipLocationPath } @@ -2270,7 +2270,7 @@ function New-NugetContentPackage # Setup staging directory so we don't change the original source directory $stagingRoot = New-SubFolder -Path $PSScriptRoot -ChildPath 'nugetStaging' -Clean $contentFolder = Join-Path -path $stagingRoot -ChildPath 'content' - if ($pscmdlet.ShouldProcess("Create staging folder")) { + if ($PSCmdlet.ShouldProcess("Create staging folder")) { New-StagingFolder -StagingPath $contentFolder } From b6a687bf2164ce3222b3d0169a345c9f14d73f8f Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:19:39 +0000 Subject: [PATCH 12/35] Correct case of $error special variable --- test/packaging/windows/msi.tests.ps1 | 4 ++-- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- .../Classes/Scripting.Classes.BasicParsing.Tests.ps1 | 2 +- .../PSSessionConfiguration.Tests.ps1 | 2 +- .../FileSystem.Tests.ps1 | 12 ++++++------ .../Test-Connection.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 | 4 ++-- .../Write-Stream.Tests.ps1 | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index b61153bf39..20b6c4f220 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -70,10 +70,10 @@ Describe -Name "Windows MSI" -Fixture { $uploadedLog = $false } BeforeEach { - $Error.Clear() + $error.Clear() } AfterEach { - if ($Error.Count -ne 0 -and !$uploadedLog) { + if ($error.Count -ne 0 -and !$uploadedLog) { Copy-Item -Path $msiLog -Destination $env:temp -Force Write-Verbose "MSI log is at $env:temp\msilog.txt" -Verbose $uploadedLog = $true diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index a95f294682..1e60dac41d 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -88,7 +88,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" { } AfterEach { - $Error.Clear() + $error.Clear() } It "Clear-Host does not injects data into PowerShell output stream" { diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 2ddf23804a..1687abf605 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -229,7 +229,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" { '111' -Match '1' $Matches $Matches - $Error[0] + $error[0] $error $pwd foreach ($i in 1..10) {$foreach} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index 4559109e82..fde3abc7e8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -255,7 +255,7 @@ try It "$Description" { $Result = [PSObject] @{Output = $true ; Error = $null} - $Error.Clear() + $error.Clear() try { $null = Unregister-PSSessionConfiguration -name $SessionConfigName -ErrorAction stop diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index dc8fc2bd8d..b97012d6fb 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -104,7 +104,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { It "Verify Rename-Item will not rename to an existing name" { { Rename-Item -Path $testFile -NewName $testDir -ErrorAction Stop } | Should -Throw -ErrorId "RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand" - $Error[0].Exception | Should -BeOfType System.IO.IOException + $error[0].Exception | Should -BeOfType System.IO.IOException $testFile | Should -Exist } @@ -133,7 +133,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { It "Verify Move-Item will not move to an existing file" { { Move-Item -Path $testDir -Destination $testFile -ErrorAction Stop } | Should -Throw -ErrorId "MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand" - $Error[0].Exception | Should -BeOfType System.IO.IOException + $error[0].Exception | Should -BeOfType System.IO.IOException $testDir | Should -Exist } @@ -748,8 +748,8 @@ Describe "Copy-Item can avoid copying an item onto itself" -Tags "CI", "RequireA else { { Copy-Item -Path $sourcePath -Destination $destinationPath -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand" - $Error[0].Exception | Should -BeOfType System.IO.IOException - $Error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty + $error[0].Exception | Should -BeOfType System.IO.IOException + $error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty } } } @@ -811,8 +811,8 @@ Describe "Copy-Item can avoid copying an item onto itself" -Tags "CI", "RequireA ) { Copy-Item -Path $Source -Destination $Destination -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand" - $Error[0].Exception | Should -BeOfType System.IO.IOException - $Error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty + $error[0].Exception | Should -BeOfType System.IO.IOException + $error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 index b7e90b9383..5061c82a62 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -65,9 +65,9 @@ Describe "Test-Connection" -tags "CI" { Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand" # Error code = 11001 - Host not found. if (!$isWindows) { - $Error[0].Exception.InnerException.ErrorCode | Should -Be -131073 + $error[0].Exception.InnerException.ErrorCode | Should -Be -131073 } else { - $Error[0].Exception.InnerException.ErrorCode | Should -Be 11001 + $error[0].Exception.InnerException.ErrorCode | Should -Be 11001 } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 index de3459c93b..e3cf51beef 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 @@ -2,7 +2,7 @@ # Licensed under the MIT License. Describe 'Get-Error tests' -Tag CI { - It 'Get-Error resolves $Error[0] and includes InnerException' { + It 'Get-Error resolves $error[0] and includes InnerException' { try { 1/0 } @@ -103,7 +103,7 @@ Describe 'Get-Error tests' -Tag CI { $null = Get-Error - $Error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object + $error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object } It 'Get-Error adds ExceptionType for Exceptions' { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 index 8f61a92108..45973d431c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 @@ -47,10 +47,10 @@ Describe "Stream writer tests" -Tags "CI" { } Context "Error automatic variable" { - It "Should write error messages to the `$Error automatic variable" { + It "Should write error messages to the `$error automatic variable" { Write-Error "Test Error Message" -ErrorAction SilentlyContinue - $Error[0] | Should -Match "Test Error Message" + $error[0] | Should -Match "Test Error Message" } } From 679702ba05ac797e075867b792502ad72103f868 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:21:25 +0000 Subject: [PATCH 13/35] Correct case of $PSDefaultParameterValues special variable --- .../Language/Parser/RedirectionOperator.Tests.ps1 | 10 +++++----- .../Clear-EventLog.Tests.ps1 | 2 +- .../Clipboard.Tests.ps1 | 2 +- .../Get-EventLog.Tests.ps1 | 2 +- .../New-EventLog.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Management/Registry.Tests.ps1 | 2 +- .../Remove-EventLog.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Management/TimeZone.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 | 4 ++-- .../FileCatalog.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Utility/New-Object.Tests.ps1 | 2 +- test/powershell/engine/COM/COM.Basic.Tests.ps1 | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 b/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 index be81c381cd..2702aaeb99 100644 --- a/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 +++ b/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 @@ -14,8 +14,8 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" { # If Out-File -Encoding happens to have a default, be sure to # save it away $SavedValue = $null - $oldDefaultParameterValues = $psDefaultParameterValues.Clone() - $psDefaultParameterValues = @{} + $oldDefaultParameterValues = $PSDefaultParameterValues.Clone() + $PSDefaultParameterValues = @{} } AfterAll { # be sure to tidy up afterwards @@ -23,11 +23,11 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" { } BeforeEach { # start each test with a clean plate! - $psdefaultParameterValues.Remove("Out-File:Encoding") + $PSDefaultParameterValues.Remove("Out-File:Encoding") } AfterEach { # end each test with a clean plate! - $psdefaultParameterValues.Remove("Out-File:Encoding") + $PSDefaultParameterValues.Remove("Out-File:Encoding") } It "If encoding is unset, redirection should be UTF8 without bom" { @@ -70,7 +70,7 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" { $TXT = $enc.GetBytes($asciiString) $CR = $enc.GetBytes($asciiCR) $expectedBytes = .{ $BOM; $TXT; $CR } - $psdefaultparameterValues["Out-File:Encoding"] = "$encoding" + $PSDefaultParameterValues["Out-File:Encoding"] = "$encoding" $asciiString > TESTDRIVE:/file.txt $observedBytes = Get-Content -AsByteStream TESTDRIVE:/file.txt # THE TEST diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 index 28a9e374f0..860025beac 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') { BeforeAll { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Clipboard.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Clipboard.Tests.ps1 index 42b1d76cc3..c6d878fd4b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Clipboard.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Clipboard.Tests.ps1 @@ -8,7 +8,7 @@ Describe 'Clipboard cmdlet tests' -Tag CI { Context 'Text' { BeforeAll { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = ($IsWindows -and $env:PROCESSOR_ARCHITECTURE.Contains("arm")) -or ($IsLinux -and $xclip -eq $null) } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 index d69986c141..c8eb9642dd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') { BeforeAll { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 index c0af78122c..2b9da09502 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 @@ -3,7 +3,7 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') { BeforeAll { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $IsNotSkipped = ($IsWindows -and !$IsCoreCLR) $PSDefaultParameterValues["it:skip"] = !$IsNotSkipped } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Registry.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Registry.Tests.ps1 index 1e3a141a1b..fdbdadd986 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Registry.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Registry.Tests.ps1 @@ -2,7 +2,7 @@ # Licensed under the MIT License. try { #skip all tests on non-windows platform - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = !$IsWindows Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows") { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 index 92ef62f931..c9bbf5a72f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 @@ -3,7 +3,7 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') { BeforeAll { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $IsNotSkipped = ($IsWindows -and !$IsCoreCLR) $PSDefaultParameterValues["it:skip"] = !$IsNotSkipped } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 index 0029dc56bf..cc1652ecd0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 @@ -30,7 +30,7 @@ Describe "Get-Timezone test cases" -Tags "CI" { BeforeAll { $TimeZonesAvailable = [System.TimeZoneInfo]::GetSystemTimeZones() - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = ($TimeZonesAvailable.Count -eq 0) } @@ -127,7 +127,7 @@ Describe "Get-Timezone test cases" -Tags "CI" { } try { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = !$IsWindows Describe "Set-Timezone test case: call by single Id" -Tags @('CI', 'RequireAdminOnWindows') { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 index 7dc805be35..62dc82c0cd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 @@ -86,8 +86,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { else { # Skip for non-Windows platforms - $defaultParamValues = $PSdefaultParameterValues.Clone() - $PSdefaultParameterValues = @{ "it:skip" = $true } + $defaultParamValues = $PSDefaultParameterValues.Clone() + $PSDefaultParameterValues = @{ "it:skip" = $true } } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 index b86caafe64..6911532ac9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 @@ -5,7 +5,7 @@ try { #skip all tests on non-windows platform - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = !$IsWindows $script:catalogPath = "" diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/New-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/New-Object.Tests.ps1 index a66854d071..48e7d40c54 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/New-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/New-Object.Tests.ps1 @@ -133,7 +133,7 @@ Describe "New-Object DRT basic functionality" -Tags "CI" { try { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop Describe "New-Object COM functionality" -Tags "CI" { diff --git a/test/powershell/engine/COM/COM.Basic.Tests.ps1 b/test/powershell/engine/COM/COM.Basic.Tests.ps1 index 832b95c53e..7b1599a5d9 100644 --- a/test/powershell/engine/COM/COM.Basic.Tests.ps1 +++ b/test/powershell/engine/COM/COM.Basic.Tests.ps1 @@ -2,7 +2,7 @@ # Licensed under the MIT License. try { - $defaultParamValues = $PSdefaultParameterValues.Clone() + $defaultParamValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop Describe 'Basic COM Tests' -Tags "CI" { From 62aee9356a63fd897f4d89087c4994b5269f3a36 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:21:53 +0000 Subject: [PATCH 14/35] Correct case of $PSScriptRoot special variable --- build.psm1 | 2 +- docker/tests/containerTestCommon.psm1 | 4 ++-- .../engine/ResourceValidation/CimCmdletsResources.Tests.ps1 | 2 +- .../engine/ResourceValidation/ConsoleHostResources.Tests.ps1 | 2 +- .../ResourceValidation/DotNetEventingResources.Tests.ps1 | 2 +- .../ResourceValidation/ManagementCommandsResources.Tests.ps1 | 2 +- .../engine/ResourceValidation/SMAResources.Tests.ps1 | 2 +- .../engine/ResourceValidation/SecurityResources.Tests.ps1 | 2 +- test/powershell/engine/ResourceValidation/TestRunner.ps1 | 2 +- .../engine/ResourceValidation/UtilityResources.Tests.ps1 | 2 +- .../engine/ResourceValidation/WSManResources.Tests.ps1 | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.psm1 b/build.psm1 index 7565e369c6..d1b75818ac 100644 --- a/build.psm1 +++ b/build.psm1 @@ -498,7 +498,7 @@ Fix steps: $psVersion = $ReleaseTag } else { - $psVersion = git --git-dir="$PSSCriptRoot/.git" describe + $psVersion = git --git-dir="$PSScriptRoot/.git" describe } if ($Environment.IsRedHatFamily -or $Environment.IsDebian) { diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 4816812b64..4e93263ea8 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -72,7 +72,7 @@ function Get-LinuxContainer { Write-Output @{ Name = $os - Path = "$psscriptroot/../release/$os" + Path = "$PSScriptRoot/../release/$os" } } } @@ -84,7 +84,7 @@ function Get-WindowsContainer { Write-Output @{ Name = $os - Path = "$psscriptroot/../release/$os" + Path = "$PSScriptRoot/../release/$os" } } } diff --git a/test/powershell/engine/ResourceValidation/CimCmdletsResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/CimCmdletsResources.Tests.ps1 index e7e849b06c..c60985d511 100644 --- a/test/powershell/engine/ResourceValidation/CimCmdletsResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/CimCmdletsResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $assemblyName = "Microsoft.Management.Infrastructure.CimCmdlets" diff --git a/test/powershell/engine/ResourceValidation/ConsoleHostResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/ConsoleHostResources.Tests.ps1 index 0f6c3367f8..3c8eecdd34 100644 --- a/test/powershell/engine/ResourceValidation/ConsoleHostResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/ConsoleHostResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $AssemblyName = "Microsoft.PowerShell.ConsoleHost" diff --git a/test/powershell/engine/ResourceValidation/DotNetEventingResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/DotNetEventingResources.Tests.ps1 index 9bd8992c3d..d53858ba3e 100644 --- a/test/powershell/engine/ResourceValidation/DotNetEventingResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/DotNetEventingResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $assemblyName = "Microsoft.PowerShell.CoreCLR.Eventing" diff --git a/test/powershell/engine/ResourceValidation/ManagementCommandsResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/ManagementCommandsResources.Tests.ps1 index ae242d3712..ea6b1576fd 100644 --- a/test/powershell/engine/ResourceValidation/ManagementCommandsResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/ManagementCommandsResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $AssemblyName = "Microsoft.PowerShell.Commands.Management" # excluded resources, taken from the 'EmbeddedResource Remove' diff --git a/test/powershell/engine/ResourceValidation/SMAResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/SMAResources.Tests.ps1 index d03788a4d5..e8d7cf8bcf 100644 --- a/test/powershell/engine/ResourceValidation/SMAResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/SMAResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $AssemblyName = "System.Management.Automation" # excluded resources, taken from the 'EmbeddedResource Remove' diff --git a/test/powershell/engine/ResourceValidation/SecurityResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/SecurityResources.Tests.ps1 index d58bf385fc..227d17bd4f 100644 --- a/test/powershell/engine/ResourceValidation/SecurityResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/SecurityResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $assemblyName = "Microsoft.PowerShell.Security" diff --git a/test/powershell/engine/ResourceValidation/TestRunner.ps1 b/test/powershell/engine/ResourceValidation/TestRunner.ps1 index 05bbf6107c..e3c6cb5264 100644 --- a/test/powershell/engine/ResourceValidation/TestRunner.ps1 +++ b/test/powershell/engine/ResourceValidation/TestRunner.ps1 @@ -6,7 +6,7 @@ function Test-ResourceStrings # determine the needed resource directory. If these tests are moved # this logic will need to change - $repoBase = (Resolve-Path (Join-Path $psScriptRoot ../../../..)).Path + $repoBase = (Resolve-Path (Join-Path $PSScriptRoot ../../../..)).Path $asmBase = Join-Path $repoBase "src/$AssemblyName" $resourceDir = Join-Path $asmBase resources $resourceFiles = Get-ChildItem $resourceDir -Filter *.resx -ErrorAction stop | diff --git a/test/powershell/engine/ResourceValidation/UtilityResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/UtilityResources.Tests.ps1 index a50245439d..5633584bcb 100644 --- a/test/powershell/engine/ResourceValidation/UtilityResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/UtilityResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $AssemblyName = "Microsoft.PowerShell.Commands.Utility" # excluded resources, taken from the 'EmbeddedResource Remove' diff --git a/test/powershell/engine/ResourceValidation/WSManResources.Tests.ps1 b/test/powershell/engine/ResourceValidation/WSManResources.Tests.ps1 index c2154dc46d..c4741f1e12 100644 --- a/test/powershell/engine/ResourceValidation/WSManResources.Tests.ps1 +++ b/test/powershell/engine/ResourceValidation/WSManResources.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -. "$psscriptroot/TestRunner.ps1" +. "$PSScriptRoot/TestRunner.ps1" $assemblyName = "Microsoft.WSMan.Management" From 4a9d70fdcda61f3d8862dede95380ef1aeadf5d0 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:24:10 +0000 Subject: [PATCH 15/35] Correct case of $PWD special variable --- build.psm1 | 8 +++---- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- .../Scripting.Classes.BasicParsing.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Core/Job.Tests.ps1 | 2 +- .../Set-Location.Tests.ps1 | 4 ++-- .../Foreach-Object-Parallel.Tests.ps1 | 8 +++---- .../Select-String.Tests.ps1 | 2 +- test/powershell/engine/Job/Jobs.Tests.ps1 | 10 ++++----- .../Modules/HelpersCommon/HelpersCommon.psm1 | 2 +- test/tools/OpenCover/OpenCover.psm1 | 2 +- tools/Sign-Package.ps1 | 4 ++-- tools/ci.psm1 | 22 +++++++++---------- tools/packaging/packaging.psm1 | 4 ++-- .../PowerShellPackage.ps1 | 2 +- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/build.psm1 b/build.psm1 index d1b75818ac..78070180e3 100644 --- a/build.psm1 +++ b/build.psm1 @@ -438,7 +438,7 @@ Fix steps: $Arguments += "/property:SDKToUse=Microsoft.NET.Sdk.WindowsDesktop" } - Write-Log "Run dotnet $Arguments from $pwd" + Write-Log "Run dotnet $Arguments from $PWD" Start-NativeExecution { dotnet $Arguments } Write-Log "PowerShell output: $($Options.Output)" @@ -456,14 +456,14 @@ Fix steps: $Arguments += "/property:SDKToUse=Microsoft.NET.Sdk.WindowsDesktop" } - Write-Log "Run dotnet $Arguments from $pwd" + Write-Log "Run dotnet $Arguments from $PWD" Start-NativeExecution { dotnet $Arguments } Write-Log "PowerShell output: $($Options.Output)" try { Push-Location $globalToolSrcFolder $Arguments += "--output", $publishPath - Write-Log "Run dotnet $Arguments from $pwd to build global tool entry point" + Write-Log "Run dotnet $Arguments from $PWD to build global tool entry point" Start-NativeExecution { dotnet $Arguments } } finally { @@ -1646,7 +1646,7 @@ function Install-Dotnet { } else { # dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell $fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe" - $fullDotnetInstallPath = Join-Path -Path $pwd.Path -ChildPath $installScript + $fullDotnetInstallPath = Join-Path -Path $PWD.Path -ChildPath $installScript Start-NativeExecution { & $fullPSPath -NoLogo -NoProfile -File $fullDotnetInstallPath -Channel $Channel -Version $Version } } } diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 1e60dac41d..9dc9f62bfe 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -706,7 +706,7 @@ namespace StackTest { @{ parameter = '-wo' } ) { param($parameter) - $output = & $powershell -NoProfile $parameter ~ -Command "`$pwd.Path" + $output = & $powershell -NoProfile $parameter ~ -Command "`$PWD.Path" $output | Should -BeExactly $((Get-Item ~).FullName) } diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 1687abf605..a0ab1e08d2 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -231,7 +231,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" { $Matches $error[0] $error - $pwd + $PWD foreach ($i in 1..10) {$foreach} switch ($i) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 index 6954513716..da1f21ba1c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 @@ -216,7 +216,7 @@ Describe "Ampersand background test" -tag "CI","Slow" { } It "starts in the current directory" { $j = Get-Location | Foreach-Object -MemberName Path & - Receive-Job -Wait $j | Should -Be ($pwd.Path) + Receive-Job -Wait $j | Should -Be ($PWD.Path) } It "Test that output redirection is done in the background job" { $j = Write-Output hello > $TESTDRIVE/hello.txt & diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 index 262a7db440..2c009b3f27 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 @@ -202,7 +202,7 @@ Describe "Set-Location" -Tags "CI" { } It 'The LocationChangedAction should fire when changing location' { - $initialPath = $pwd + $initialPath = $PWD $oldPath = $null $newPath = $null $eventSessionState = $null @@ -214,7 +214,7 @@ Describe "Set-Location" -Tags "CI" { (Get-Variable newPath).Value = $_.newPath } Set-Location .. - $newPath.Path | Should -Be $pwd.Path + $newPath.Path | Should -Be $PWD.Path $oldPath.Path | Should -Be $initialPath.Path $eventSessionState | Should -Be $ExecutionContext.SessionState $eventRunspace | Should -Be ([runspace]::DefaultRunspace) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Foreach-Object-Parallel.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Foreach-Object-Parallel.Tests.ps1 index fa1c3adea7..9593f875e3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Foreach-Object-Parallel.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Foreach-Object-Parallel.Tests.ps1 @@ -101,8 +101,8 @@ Describe 'ForEach-Object -Parallel Basic Tests' -Tags 'CI' { } It 'Verifies that the current working directory is preserved' { - $parallelScriptLocation = 1..1 | ForEach-Object -Parallel { $pwd } - $parallelScriptLocation.Path | Should -BeExactly $pwd.Path + $parallelScriptLocation = 1..1 | ForEach-Object -Parallel { $PWD } + $parallelScriptLocation.Path | Should -BeExactly $PWD.Path } } @@ -307,10 +307,10 @@ Describe 'ForEach-Object -Parallel -AsJob Basic Tests' -Tags 'CI' { } It 'Verifies that the current working directory is preserved' { - $job = 1..1 | ForEach-Object -AsJob -Parallel { $pwd } + $job = 1..1 | ForEach-Object -AsJob -Parallel { $PWD } $parallelScriptLocation = $job | Wait-Job | Receive-Job $job | Remove-Job - $parallelScriptLocation.Path | Should -BeExactly $pwd.Path + $parallelScriptLocation.Path | Should -BeExactly $PWD.Path } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1 index 7f99835f48..9c674c1aba 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1 @@ -4,7 +4,7 @@ Describe "Select-String" -Tags "CI" { BeforeAll { $nl = [Environment]::NewLine - $currentDirectory = $pwd.Path + $currentDirectory = $PWD.Path } AfterAll { diff --git a/test/powershell/engine/Job/Jobs.Tests.ps1 b/test/powershell/engine/Job/Jobs.Tests.ps1 index 395eaa94d9..df7363b5cd 100644 --- a/test/powershell/engine/Job/Jobs.Tests.ps1 +++ b/test/powershell/engine/Job/Jobs.Tests.ps1 @@ -81,7 +81,7 @@ Describe 'Basic Job Tests' -Tags 'Feature' { It 'Can use the user specified working directory parameter with whitespace' { $path = Join-Path -Path $TestDrive -ChildPath "My Dir" $null = New-Item -ItemType Directory -Path "$path" - $job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job + $job = Start-Job -ScriptBlock { $PWD } -WorkingDirectory $path | Wait-Job $jobOutput = Receive-Job $job $jobOutput | Should -BeExactly $path.ToString() } @@ -89,13 +89,13 @@ Describe 'Basic Job Tests' -Tags 'Feature' { It 'Can use the user specified working directory parameter with quote' -Skip:($IsWindows) { $path = Join-Path -Path $TestDrive -ChildPath "My ""Dir" $null = New-Item -ItemType Directory -Path "$path" - $job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job + $job = Start-Job -ScriptBlock { $PWD } -WorkingDirectory $path | Wait-Job $jobOutput = Receive-Job $job $jobOutput | Should -BeExactly $path.ToString() } It 'Verifies the working directory parameter path with trailing backslash' -Skip:(! $IsWindows) { - $job = Start-Job { $pwd } -WorkingDirectory '\' | Wait-Job + $job = Start-Job { $PWD } -WorkingDirectory '\' | Wait-Job $job.JobStateInfo.State | Should -BeExactly 'Completed' } @@ -106,10 +106,10 @@ Describe 'Basic Job Tests' -Tags 'Feature' { } It 'Verifies that the current working directory is preserved' { - $job = Start-Job -ScriptBlock { $pwd } + $job = Start-Job -ScriptBlock { $PWD } $location = $job | Wait-Job | Receive-Job $job | Remove-Job - $location.Path | Should -BeExactly $pwd.Path + $location.Path | Should -BeExactly $PWD.Path } It "Create job with native command" { diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index 42bd6548df..6a81e20293 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -209,7 +209,7 @@ function Send-VstsLogFile { $Path ) - $logFolder = Join-Path -path $pwd -ChildPath 'logfile' + $logFolder = Join-Path -path $PWD -ChildPath 'logfile' if(!(Test-Path -Path $logFolder)) { $null = New-Item -Path $logFolder -ItemType Directory diff --git a/test/tools/OpenCover/OpenCover.psm1 b/test/tools/OpenCover/OpenCover.psm1 index d00996a88e..3c8953a885 100644 --- a/test/tools/OpenCover/OpenCover.psm1 +++ b/test/tools/OpenCover/OpenCover.psm1 @@ -615,7 +615,7 @@ function Install-OpenCover .Description Invoke-OpenCover runs tests under OpenCover by executing tests on PowerShell located at $PowerShellExeDirectory. .EXAMPLE - Invoke-OpenCover -TestPath $pwd/test/powershell -PowerShellExeDirectory $pwd/src/powershell-win-core/bin/CodeCoverage/netcoreapp1.0/win7-x64 + Invoke-OpenCover -TestPath $PWD/test/powershell -PowerShellExeDirectory $PWD/src/powershell-win-core/bin/CodeCoverage/netcoreapp1.0/win7-x64 #> function Invoke-OpenCover { diff --git a/tools/Sign-Package.ps1 b/tools/Sign-Package.ps1 index a72db5a358..9393f35886 100644 --- a/tools/Sign-Package.ps1 +++ b/tools/Sign-Package.ps1 @@ -21,7 +21,7 @@ function New-SelfSignedCertificate #Path to save generated Certificate [ValidateNotNullOrEmpty()] - [string] $CertificateFilePath = "$pwd\PowerShell.cer", + [string] $CertificateFilePath = "$PWD\PowerShell.cer", #Path to save generated pvk file [ValidateNotNullOrEmpty()] @@ -55,7 +55,7 @@ function ConvertTo-Pfx #Path to Certificate file [ValidateNotNullOrEmpty()] - [string] $CertificateFilePath = "$pwd\PowerShell.cer", + [string] $CertificateFilePath = "$PWD\PowerShell.cer", #Path to pvk file [ValidateNotNullOrEmpty()] diff --git a/tools/ci.psm1 b/tools/ci.psm1 index d4a6ffc131..f76eacdf7d 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -190,7 +190,7 @@ function Invoke-CIxUnit throw "CoreCLR pwsh.exe was not built" } - $xUnitTestResultsFile = Join-Path -Path $pwd -childpath "xUnitTestResults.xml" + $xUnitTestResultsFile = Join-Path -Path $PWD -childpath "xUnitTestResults.xml" Start-PSxUnit -xUnitTestResultsFile $xUnitTestResultsFile Push-Artifact -Path $xUnitTestResultsFile -name xunit @@ -239,8 +239,8 @@ function Invoke-CITest $env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (Get-PSOptions)) Write-Host -Foreground Green 'Run CoreCLR tests' - $testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin-$TagSet.xml" - $testResultsAdminFile = "$pwd\TestsResultsAdmin-$TagSet.xml" + $testResultsNonAdminFile = "$PWD\TestsResultsNonAdmin-$TagSet.xml" + $testResultsAdminFile = "$PWD\TestsResultsAdmin-$TagSet.xml" if(!(Test-Path "$env:CoreOutput\pwsh.exe")) { throw "CoreCLR pwsh.exe was not built" @@ -269,7 +269,7 @@ function Invoke-CITest $featureName = $entry.Key $testFiles = $entry.Value - $expFeatureTestResultFile = "$pwd\TestsResultsNonAdmin.$featureName.xml" + $expFeatureTestResultFile = "$PWD\TestsResultsNonAdmin.$featureName.xml" $arguments['OutputFile'] = $expFeatureTestResultFile $arguments['ExperimentalFeatureName'] = $featureName if ($testFiles.Count -eq 0) { @@ -308,7 +308,7 @@ function Invoke-CITest $featureName = $entry.Key $testFiles = $entry.Value - $expFeatureTestResultFile = "$pwd\TestsResultsAdmin.$featureName.xml" + $expFeatureTestResultFile = "$PWD\TestsResultsAdmin.$featureName.xml" $arguments['OutputFile'] = $expFeatureTestResultFile $arguments['ExperimentalFeatureName'] = $featureName if ($testFiles.Count -eq 0) @@ -407,11 +407,11 @@ function Compress-CoverageArtifacts Add-Type -AssemblyName System.IO.Compression.FileSystem $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $PSScriptRoot '..\test\tools\OpenCover')) - $zipOpenCoverPath = Join-Path $pwd 'OpenCover.zip' + $zipOpenCoverPath = Join-Path $PWD 'OpenCover.zip' [System.IO.Compression.ZipFile]::CreateFromDirectory($resolvedPath, $zipOpenCoverPath) $null = $artifacts.Add($zipOpenCoverPath) - $zipCodeCoveragePath = Join-Path $pwd "CodeCoverage.zip" + $zipCodeCoveragePath = Join-Path $PWD "CodeCoverage.zip" Write-Verbose "Zipping ${CodeCoverageOutput} into $zipCodeCoveragePath" -verbose [System.IO.Compression.ZipFile]::CreateFromDirectory($CodeCoverageOutput, $zipCodeCoveragePath) $null = $artifacts.Add($zipCodeCoveragePath) @@ -576,8 +576,8 @@ function Invoke-LinuxTestsCore ) $output = Split-Path -Parent (Get-PSOutput -Options (Get-PSOptions)) - $testResultsNoSudo = "$pwd/TestResultsNoSudo.xml" - $testResultsSudo = "$pwd/TestResultsSudo.xml" + $testResultsNoSudo = "$PWD/TestResultsNoSudo.xml" + $testResultsSudo = "$PWD/TestResultsSudo.xml" $testExcludeTag = $ExcludeTag + 'RequireSudoOnUnix' $noSudoPesterParam = @{ @@ -603,7 +603,7 @@ function Invoke-LinuxTestsCore $featureName = $entry.Key $testFiles = $entry.Value - $expFeatureTestResultFile = "$pwd\TestResultsNoSudo.$featureName.xml" + $expFeatureTestResultFile = "$PWD\TestResultsNoSudo.$featureName.xml" $noSudoPesterParam['OutputFile'] = $expFeatureTestResultFile $noSudoPesterParam['ExperimentalFeatureName'] = $featureName if ($testFiles.Count -eq 0) { @@ -638,7 +638,7 @@ function Invoke-LinuxTestsCore $featureName = $entry.Key $testFiles = $entry.Value - $expFeatureTestResultFile = "$pwd\TestResultsSudo.$featureName.xml" + $expFeatureTestResultFile = "$PWD\TestResultsSudo.$featureName.xml" $sudoPesterParam['OutputFile'] = $expFeatureTestResultFile $sudoPesterParam['ExperimentalFeatureName'] = $featureName if ($testFiles.Count -eq 0) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index e973159897..bee0dea4c6 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -2756,8 +2756,8 @@ function New-MSIPackage if ($ProductNameSuffix) { $packageName += "-$ProductNameSuffix" } - $msiLocationPath = Join-Path $pwd "$packageName.msi" - $msiPdbLocationPath = Join-Path $pwd "$packageName.wixpdb" + $msiLocationPath = Join-Path $PWD "$packageName.msi" + $msiPdbLocationPath = Join-Path $PWD "$packageName.wixpdb" if (!$Force.IsPresent -and (Test-Path -Path $msiLocationPath)) { diff --git a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 b/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 index 41f52956df..285b41d90a 100644 --- a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 +++ b/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 @@ -7,7 +7,7 @@ param ( [string] $branch = 'master', - [string] $location = "$pwd\powershell", + [string] $location = "$PWD\powershell", [string] $destination = "$env:WORKSPACE", From 6014f4bac347f57bcdfcf16ba80d97dc6d147155 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:24:42 +0000 Subject: [PATCH 16/35] Correct case of $null special variable --- test/powershell/Language/Scripting/Indexer.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Management/Set-Service.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/powershell/Language/Scripting/Indexer.Tests.ps1 b/test/powershell/Language/Scripting/Indexer.Tests.ps1 index 378f2b3cee..5467c53de8 100644 --- a/test/powershell/Language/Scripting/Indexer.Tests.ps1 +++ b/test/powershell/Language/Scripting/Indexer.Tests.ps1 @@ -7,7 +7,7 @@ Describe 'Tests for indexers' -Tags "CI" { $hashtable["Hello"] | Should -BeExactly "There" } - It 'Accessing a Indexed property of a dictionary that does not exist should return $NULL' { + It 'Accessing a Indexed property of a dictionary that does not exist should return $null' { $hashtable = @{ "Hello"="There" } $hashtable["Hello There"] | Should -BeNullOrEmpty } @@ -19,7 +19,7 @@ Describe 'Tests for indexers' -Tags "CI" { $service.CimClassProperties["DisplayName"].Name | Should -BeExactly 'DisplayName' } - It 'Accessing a Indexed property of a CimClass that does not exist should return $NULL' -Skip:(-not $IsWindows) { + It 'Accessing a Indexed property of a CimClass that does not exist should return $null' -Skip:(-not $IsWindows) { $service = Get-CimClass -ClassName Win32_Service $service.CimClassProperties["Hello There"] | Should -BeNullOrEmpty diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Service.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Service.Tests.ps1 index 44eba212da..9065741910 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Service.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Service.Tests.ps1 @@ -82,7 +82,7 @@ Describe "Set/New/Remove-Service cmdlet tests" -Tags "Feature", "RequireAdminOnW param($parameter, $value, $script, $expectedNull) $setServiceCommand = [Microsoft.PowerShell.Commands.SetServiceCommand]::new() - if ($script -ne $Null) { + if ($script -ne $null) { $value = & $script } $setServiceCommand.$parameter = $value diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 index 45973d431c..d08fa455da 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 @@ -115,7 +115,7 @@ Describe "Stream writer tests" -Tags "CI" { (Compare-Object $result $returnValue -SyncWindow 0).length | Should -Be 0 } - It "Write-Information accepts `$Null" { + It "Write-Information accepts `$null" { $streamPath = Join-Path $testdrive information.txt $null | Write-Information -Tags myTag -ErrorAction Stop -InformationAction SilentlyContinue -InformationVariable i $i.Tags | Should -BeExactly "myTag" From 47a3b4e2934d81e59a868a1657c7517867ef3150 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:25:09 +0000 Subject: [PATCH 17/35] Correct case of $true special variable --- test/powershell/Host/ConsoleHost.Tests.ps1 | 6 ++-- .../Language/Parser/Parser.Tests.ps1 | 30 +++++++++---------- .../Clear-EventLog.Tests.ps1 | 6 ++-- .../Get-EventLog.Tests.ps1 | 14 ++++----- .../New-EventLog.Tests.ps1 | 10 +++---- .../Remove-EventLog.Tests.ps1 | 4 +-- .../Unblock-File.Tests.ps1 | 2 +- .../Start-Transcript.Tests.ps1 | 4 +-- .../Pester.AutomountedDrives.Tests.ps1 | 2 +- .../Basic/GroupPolicySettings.Tests.ps1 | 2 +- .../BooleanParameterDCR.Tests.ps1 | 2 +- .../engine/Remoting/SessionOption.Tests.ps1 | 2 +- .../HelpersLanguage/HelpersLanguage.psm1 | 4 +-- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 9dc9f62bfe..739e6816e2 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -185,7 +185,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" { It "-File should be able to pass bool string values as string to parameters: " -TestCases @( # validates case is preserved - @{BoolString = '$truE'}, + @{BoolString = '$true'}, @{BoolString = '$falSe'}, @{BoolString = 'trUe'}, @{BoolString = 'faLse'} @@ -198,7 +198,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" { It "-File should be able to pass bool string values as string to positional parameters: " -TestCases @( # validates case is preserved - @{BoolString = '$tRue'}, + @{BoolString = '$true'}, @{BoolString = '$falSe'}, @{BoolString = 'tRUe'}, @{BoolString = 'fALse'} @@ -210,7 +210,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" { } It "-File should be able to pass bool string values as bool to switches: " -TestCases @( - @{BoolString = '$tRue'; BoolValue = 'True'}, + @{BoolString = '$true'; BoolValue = 'True'}, @{BoolString = '$faLse'; BoolValue = 'False'}, @{BoolString = 'tRue'; BoolValue = 'True'}, @{BoolString = 'fAlse'; BoolValue = 'False'} diff --git a/test/powershell/Language/Parser/Parser.Tests.ps1 b/test/powershell/Language/Parser/Parser.Tests.ps1 index 3c731fee98..6aa7dd5aa2 100644 --- a/test/powershell/Language/Parser/Parser.Tests.ps1 +++ b/test/powershell/Language/Parser/Parser.Tests.ps1 @@ -741,28 +741,28 @@ foo``u{2195}abc @{ Script = 'if (0 -or 1) { $true } else { $false }'; Expected = $true } @{ Script = 'if (0 -or 0) { $true } else { $false }'; Expected = $false } #-eq - @{ Script = 'if ($False -eq $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -eq $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -eq $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -eq $False) { $true } else { $false }'; Expected = $false } #-ieq - @{ Script = 'if ($False -ieq $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -ieq $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -ieq $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -ieq $False) { $true } else { $false }'; Expected = $false } #-le - @{ Script = 'if ($False -le $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -le $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -le $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -le $False) { $true } else { $false }'; Expected = $false } #-ile - @{ Script = 'if ($False -ile $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -ile $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -ile $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -ile $False) { $true } else { $false }'; Expected = $false } #-ge - @{ Script = 'if ($False -ge $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -ge $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -ge $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -ge $False) { $true } else { $false }'; Expected = $false } #-ige - @{ Script = 'if ($False -ige $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -ige $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -ige $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -ige $False) { $true } else { $false }'; Expected = $false } #-like - @{ Script = 'if ($False -like $True -and $False) { $true } else { $false }'; Expected = $false } - @{ Script = 'if ($False -and $True -like $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -like $true -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if ($False -and $true -like $False) { $true } else { $false }'; Expected = $false } #! - @{ Script = 'if (!$True -and $False) { $true } else { $false }'; Expected = $false } + @{ Script = 'if (!$true -and $False) { $true } else { $false }'; Expected = $false } ) It "