diff --git a/build.psm1 b/build.psm1 index c9bdf4c689..78070180e3 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 } @@ -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 { @@ -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) { @@ -1393,19 +1393,19 @@ 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" + $StackTrace = $testFailure.failure."stack-trace" } - elseif ($PSCmdLet.ParameterSetName -eq 'object') + 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" @@ -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) { @@ -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 } } } @@ -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/crontab/CronTab/CronTab.psm1 b/demos/crontab/CronTab/CronTab.psm1 index 15fedb5207..1b5bcfb2b7 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 { @@ -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/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/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 4816812b64..b34f097b95 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" } } } @@ -183,7 +183,7 @@ function Get-ContainerPowerShellVersion $runParams = @() $localVolumeName = $testContext.resolvedTestDrive $runParams += '--rm' - if($TestContext.Type -ne 'Windows' -and $isWindows) + if($TestContext.Type -ne 'Windows' -and $IsWindows) { # use a container volume on windows because host volumes are not automatic $volumeName = "test-volume-" + (Get-Random -Minimum 100 -Maximum 999) @@ -204,7 +204,7 @@ function Get-ContainerPowerShellVersion $runParams += ('$PSVersionTable.PSVersion.ToString() | out-string | out-file -encoding ascii -FilePath '+$testContext.containerLogPath) $null = Invoke-Docker -Command run -Params $runParams -SuppressHostOutput - if($TestContext.Type -ne 'Windows' -and $isWindows) + if($TestContext.Type -ne 'Windows' -and $IsWindows) { $null = Invoke-Docker -Command cp -Params "${volumeName}:$($testContext.containerLogPath)", $TestContext.ResolvedLogPath $null = Invoke-Docker -Command container, rm -Params $volumeName, '--force' -SuppressHostOutput diff --git a/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 b/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 index 478e8e6977..ecfdb1364d 100644 --- a/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 +++ b/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 @@ -172,17 +172,17 @@ function Enable-PSWSManCombinedTrace $traceFileName = [string][Guid]::NewGuid() if ($DoNotOverwriteExistingTrace) { $fileName = [string][guid]::newguid() - $logfile = $pshome + "\\Traces\\PSTrace_$fileName.etl" + $logfile = $PSHOME + "\\Traces\\PSTrace_$fileName.etl" } else { - $logfile = $pshome + "\\Traces\\PSTrace.etl" + $logfile = $PSHOME + "\\Traces\\PSTrace.etl" } "Microsoft-Windows-PowerShell 0 5" | out-file $provfile -encoding ascii "Microsoft-Windows-WinRM 0 5" | out-file $provfile -encoding ascii -append - if (!(Test-Path $pshome\Traces)) + if (!(Test-Path $PSHOME\Traces)) { - New-Item -ItemType Directory -Force $pshome\Traces | out-null + New-Item -ItemType Directory -Force $PSHOME\Traces | out-null } if (Test-Path $logfile) diff --git a/test/docker/networktest/DockerRemoting.Tests.ps1 b/test/docker/networktest/DockerRemoting.Tests.ps1 index 60d844ad14..ae9db267d6 100644 --- a/test/docker/networktest/DockerRemoting.Tests.ps1 +++ b/test/docker/networktest/DockerRemoting.Tests.ps1 @@ -41,7 +41,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){ # capture the versions of full and core PowerShell write-verbose -verbose "getting powershell full version" - $fullVersion = docker exec $client powershell -c "`$psversiontable.psversion.tostring()" + $fullVersion = docker exec $client powershell -c "`$PSVersionTable.psversion.tostring()" if ( ! $fullVersion ) { $pending = $true @@ -50,7 +50,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){ } write-verbose -verbose "getting powershell version" - $coreVersion = docker exec $client "$powershellcorepath" -c "`$psversiontable.psversion.tostring()" + $coreVersion = docker exec $client "$powershellcorepath" -c "`$PSVersionTable.psversion.tostring()" if ( ! $coreVersion ) { $pending = $true @@ -68,22 +68,22 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){ } It "Full powershell can get correct remote powershell version" -pending:$pending { - $result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }" + $result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }" $result | Should -Be $coreVersion } It "Full powershell can get correct remote powershell full version" -pending:$pending { - $result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }" + $result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }" $result | Should -Be $fullVersion } It "Core powershell can get correct remote powershell version" -pending:$pending { - $result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }" + $result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }" $result | Should -Be $coreVersion } It "Core powershell can get correct remote powershell full version" -pending:$pending { - $result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }" + $result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }" $result | Should -Be $fullVersion } } diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 4ffb73a08d..20b6c4f220 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 { @@ -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/Base-Directory.Tests.ps1 b/test/powershell/Host/Base-Directory.Tests.ps1 index cb45291c78..71f6e682ed 100644 --- a/test/powershell/Host/Base-Directory.Tests.ps1 +++ b/test/powershell/Host/Base-Directory.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Configuration file locations" -tags "CI","Slow" { BeforeAll { - $powershell = Join-Path -Path $PsHome -ChildPath "pwsh" + $powershell = Join-Path -Path $PSHOME -ChildPath "pwsh" $profileName = "Microsoft.PowerShell_profile.ps1" } diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index def8e0ca6b..5a71d41f52 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -11,7 +11,7 @@ using namespace System.Diagnostics Describe 'minishell for native executables' -Tag 'CI' { BeforeAll { - $powershell = Join-Path -Path $PsHome -ChildPath "pwsh" + $powershell = Join-Path -Path $PSHOME -ChildPath "pwsh" } Context 'Streams from minishell' { @@ -53,7 +53,7 @@ Describe 'minishell for native executables' -Tag 'CI' { Describe "ConsoleHost unit tests" -tags "Feature" { BeforeAll { - $powershell = Join-Path -Path $PsHome -ChildPath "pwsh" + $powershell = Join-Path -Path $PSHOME -ChildPath "pwsh" $ExitCodeBadCommandLineParameter = 64 function NewProcessStartInfo([string]$CommandLine, [switch]$RedirectStdIn) @@ -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" { @@ -571,10 +571,10 @@ 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()" + $process.StandardInput.Write("`$Host.EnterNestedPrompt()`n") + $process.StandardOutput.ReadLine() | Should -Be "PS> `$Host.EnterNestedPrompt()" $process.StandardInput.Write("exit`n") $process.StandardOutput.ReadLine() | Should -Be "PS>> exit" $process.StandardInput.Close() @@ -655,7 +655,7 @@ namespace StackTest { Context "PATH environment variable" { It "`$PSHOME should be in front so that pwsh.exe starts current running PowerShell" { - & $powershell -v | Should -Match $psversiontable.GitCommitId + & $powershell -v | Should -Match $PSVersionTable.GitCommitId } It "powershell starts if PATH is not set" -Skip:($IsWindows) { @@ -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) } @@ -761,7 +761,7 @@ namespace StackTest { # Generate a string that is larger than the max pipe name length. $longPipeName = [string]::new("A", 200) - "`$pid" | & $powershell -CustomPipeName $longPipeName -c - + "`$PID" | & $powershell -CustomPipeName $longPipeName -c - $LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter } } @@ -909,7 +909,7 @@ Describe "Console host api tests" -Tag CI { @{InputObject = "${esc}abc"; Length = 4; Name = "Malformed escape - no csi"}, @{InputObject = "[31mabc"; Length = 7; Name = "Malformed escape - no escape"} - $testCases += if ($host.UI.SupportsVirtualTerminal) + $testCases += if ($Host.UI.SupportsVirtualTerminal) { @{InputObject = "$esc[31mabc"; Length = 3; Name = "Escape at start"} @{InputObject = "$esc[31mabc$esc[0m"; Length = 3; Name = "Escape at start and end"} @@ -940,7 +940,7 @@ Describe "Console host api tests" -Tag CI { It "Should properly calculate buffer cell width of ''" -TestCases $testCases { param($InputObject, $Length) - $host.UI.RawUI.LengthInBufferCells($InputObject) | Should -Be $Length + $Host.UI.RawUI.LengthInBufferCells($InputObject) | Should -Be $Length } } } @@ -960,13 +960,13 @@ Describe "Pwsh exe resources tests" -Tag CI { It "Manifest contains compatibility section" -Skip:(!$IsWindows) { $osversion = [System.Environment]::OSVersion.Version - $psversiontable.os | Should -MatchExactly "$($osversion.Major).$($osversion.Minor)" + $PSVersionTable.os | Should -MatchExactly "$($osversion.Major).$($osversion.Minor)" } } Describe 'Pwsh startup in directories that contain wild cards' -Tag CI { BeforeAll { - $powershell = Join-Path -Path $PsHome -ChildPath "pwsh" + $powershell = Join-Path -Path $PSHOME -ChildPath "pwsh" $dirnames = "[T]est","[Test","T][est","Test" $testcases = @() foreach ( $d in $dirnames ) { diff --git a/test/powershell/Host/HostUtilities.Tests.ps1 b/test/powershell/Host/HostUtilities.Tests.ps1 index 937e167c60..278c5e1110 100644 --- a/test/powershell/Host/HostUtilities.Tests.ps1 +++ b/test/powershell/Host/HostUtilities.Tests.ps1 @@ -4,7 +4,7 @@ Describe "InvokeOnRunspace method argument error handling" -tags "Feature" { BeforeAll { $command = [System.Management.Automation.PSCommand]::new() - $localRunspace = $host.Runspace + $localRunspace = $Host.Runspace } It "Null argument exception should be thrown for null PSCommand argument" { @@ -24,7 +24,7 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" { $command = [System.Management.Automation.PSCommand]::new() $command.AddScript('"Hello!"') - $currentRunspace = $host.Runspace + $currentRunspace = $Host.Runspace $results = [System.Management.Automation.HostUtilities]::InvokeOnRunspace($command, $currentRunspace) diff --git a/test/powershell/Host/Logging.Tests.ps1 b/test/powershell/Host/Logging.Tests.ps1 index b55ff6bd56..36ff5feb52 100644 --- a/test/powershell/Host/Logging.Tests.ps1 +++ b/test/powershell/Host/Logging.Tests.ps1 @@ -155,7 +155,7 @@ Describe 'Basic SysLog tests on Linux' -Tag @('CI','RequireSudoOnUnix') { Write-Warning -Message 'Unsupported Linux syslog configuration.' $IsSupportedEnvironment = $false } - [string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh' + [string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh' $scriptBlockCreatedRegExTemplate = @" Creating Scriptblock text \(1 of 1\):#012{0}(⏎|#012)*ScriptBlock ID: [0-9a-z\-]*#012Path:.* "@ @@ -191,7 +191,7 @@ Creating Scriptblock text \(1 of 1\):#012{0}(⏎|#012)*ScriptBlock ID: [0-9a-z\- It 'Verifies scriptblock logging' -Skip:(!$IsSupportedEnvironment) { $configFile = WriteLogSettings -LogId $logId -ScriptBlockLogging -LogLevel Verbose $script = @' -$pid +$PID & ([scriptblock]::create("Write-Verbose 'testheader123' ;Write-verbose 'after'")) '@ $testFileName = 'test01.ps1' @@ -220,7 +220,7 @@ $pid It 'Verifies scriptblock logging with null character' -Skip:(!$IsSupportedEnvironment) { $configFile = WriteLogSettings -LogId $logId -ScriptBlockLogging -LogLevel Verbose $script = @' -$pid +$PID & ([scriptblock]::create("Write-Verbose 'testheader123$([char]0x0000)' ;Write-verbose 'after'")) '@ $testFileName = 'test01.ps1' @@ -273,7 +273,7 @@ Describe 'Basic os_log tests on MacOS' -Tag @('CI','RequireSudoOnUnix') { Set-OsLogPersistence -Enable } } - [string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh' + [string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh' $scriptBlockCreatedRegExTemplate = @' Creating Scriptblock text \(1 of 1\): {0} @@ -338,7 +338,7 @@ Path:.* It 'Verifies scriptblock logging' -Skip:(!$IsSupportedEnvironment) { try { $script = @' -$pid +$PID & ([scriptblock]::create("Write-Verbose 'testheader123' ;Write-verbose 'after'")) '@ $configFile = WriteLogSettings -ScriptBlockLogging -LogId $logId -LogLevel Verbose @@ -376,7 +376,7 @@ $pid It 'Verifies scriptblock logging with null character' -Skip:(!$IsSupportedEnvironment) { try { $script = @' -$pid +$PID & ([scriptblock]::create("Write-Verbose 'testheader123$([char]0x0000)' ;Write-verbose 'after'")) '@ $configFile = WriteLogSettings -ScriptBlockLogging -LogId $logId -LogLevel Verbose @@ -436,7 +436,7 @@ $pid Describe 'Basic EventLog tests on Windows' -Tag @('CI','RequireAdminOnWindows') { BeforeAll { [bool] $IsSupportedEnvironment = $IsWindows - [string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh' + [string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh' $scriptBlockLoggingCases = @( @{ name = 'normal script block' @@ -452,7 +452,7 @@ Describe 'Basic EventLog tests on Windows' -Tag @('CI','RequireAdminOnWindows') if ($IsSupportedEnvironment) { - & "$PSHome\RegisterManifest.ps1" + & "$PSHOME\RegisterManifest.ps1" } } diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index 8806d8ebf2..5615cbe813 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -3,7 +3,7 @@ Describe "PSVersionTable" -Tags "CI" { BeforeAll { - $sma = Get-Item (Join-Path $PSHome "System.Management.Automation.dll") + $sma = Get-Item (Join-Path $PSHOME "System.Management.Automation.dll") $formattedVersion = $sma.VersionInfo.ProductVersion $mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?" @@ -78,7 +78,7 @@ Describe "PSVersionTable" -Tags "CI" { } It "Verify `$PSVersionTable.PSEdition" { - if ($isCoreCLR) { + if ($IsCoreCLR) { $edition = "Core" } else diff --git a/test/powershell/Host/Read-Host.Tests.ps1 b/test/powershell/Host/Read-Host.Tests.ps1 index b85338ea48..0980965970 100644 --- a/test/powershell/Host/Read-Host.Tests.ps1 +++ b/test/powershell/Host/Read-Host.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Read-Host" -Tags "Slow","Feature" { Context "[Console]::ReadKey() implementation on non-Windows" { BeforeAll { - $powershell = Join-Path -Path $PsHome -ChildPath "pwsh" + $powershell = Join-Path -Path $PSHOME -ChildPath "pwsh" $assetsDir = Join-Path -Path $PSScriptRoot -ChildPath assets if ($IsWindows) { $ItArgs = @{ skip = $true } diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index 3092b17122..b97516406f 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -612,8 +612,8 @@ Describe "TabCompletion" -Tags CI { @{ inputStr = "get-childitem -Fil"; expected = "-Filter"; setup = $null } @{ inputStr = '$arg'; expected = '$args'; setup = $null } @{ inputStr = '$args.'; expected = 'Count'; setup = $null } - @{ inputStr = '$host.UI.Ra'; expected = 'RawUI'; setup = $null } - @{ inputStr = '$host.UI.WriteD'; expected = 'WriteDebugLine('; setup = $null } + @{ inputStr = '$Host.UI.Ra'; expected = 'RawUI'; setup = $null } + @{ inputStr = '$Host.UI.WriteD'; expected = 'WriteDebugLine('; setup = $null } @{ inputStr = '$MaximumHistoryCount.'; expected = 'CompareTo('; setup = $null } @{ inputStr = '$A=[datetime]::now;$A.'; expected = 'Date'; setup = $null } @{ inputStr = '$e=$null;try { 1/0 } catch {$e=$_};$e.'; expected = 'CategoryInfo'; setup = $null } @@ -697,8 +697,8 @@ Describe "TabCompletion" -Tags CI { @{ inputStr = '$PSMod'; expected = '$PSModuleAutoLoadingPreference'; setup = $null } ## tab completion for variable in path ## if $PSHOME contains a space tabcompletion adds ' around the path - @{ inputStr = 'cd $pshome\Modu'; expected = if($PSHOME.Contains(' ')) { "'$(Join-Path $PSHOME 'Modules')'" } else { Join-Path $PSHOME 'Modules' }; setup = $null } - @{ inputStr = 'cd "$pshome\Modu"'; expected = "`"$(Join-Path $PSHOME 'Modules')`""; setup = $null } + @{ inputStr = 'cd $PSHOME\Modu'; expected = if($PSHOME.Contains(' ')) { "'$(Join-Path $PSHOME 'Modules')'" } else { Join-Path $PSHOME 'Modules' }; setup = $null } + @{ inputStr = 'cd "$PSHOME\Modu"'; expected = "`"$(Join-Path $PSHOME 'Modules')`""; setup = $null } @{ inputStr = '$PSHOME\System.Management.Au'; expected = if($PSHOME.Contains(' ')) { "`& '$(Join-Path $PSHOME 'System.Management.Automation.dll')'" } else { Join-Path $PSHOME 'System.Management.Automation.dll'; setup = $null }} @{ inputStr = '"$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null } @{ inputStr = '& "$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null } @@ -1112,7 +1112,7 @@ dir -Recurse ` "Overridden-TabExpansion-Function" } - $inputStr = '$pid.' + $inputStr = '$PID.' $res = [System.Management.Automation.CommandCompletion]::CompleteInput($inputStr, $inputst.Length, $null) $res.CompletionMatches | Should -HaveCount 1 $res.CompletionMatches[0].CompletionText | Should -BeExactly 'Overridden-TabExpansion-Function' @@ -1124,7 +1124,7 @@ dir -Recurse ` } Set-Alias -Name TabExpansion -Value OverrideTabExpansion - $inputStr = '$pid.' + $inputStr = '$PID.' $res = [System.Management.Automation.CommandCompletion]::CompleteInput($inputStr, $inputst.Length, $null) $res.CompletionMatches | Should -HaveCount 1 $res.CompletionMatches[0].CompletionText | Should -BeExactly "Overridden-TabExpansion-Alias" @@ -1153,12 +1153,12 @@ dir -Recurse ` $ast = {}.Ast; $tokens = [System.Management.Automation.Language.Token[]]@() $testCases = @( - @{ inputStr = {[System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput('$pid.', 7)}; expected = "PSArgumentException" } + @{ inputStr = {[System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput('$PID.', 7)}; expected = "PSArgumentException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($null, $null, $null, $null)}; expected = "PSArgumentNullException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $null, $null, $null)}; expected = "PSArgumentNullException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $tokens, $null, $null)}; expected = "PSArgumentNullException" } - @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$pid.', 7, $null, $null)}; expected = "PSArgumentException" } - @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$pid.', 5, $null, $null)}; expected = "PSArgumentNullException" } + @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$PID.', 7, $null, $null)}; expected = "PSArgumentException" } + @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$PID.', 5, $null, $null)}; expected = "PSArgumentNullException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($null, $null, $null, $null, $null)}; expected = "PSArgumentNullException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $null, $null, $null, $null)}; expected = "PSArgumentNullException" } @{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $tokens, $null, $null, $null)}; expected = "PSArgumentNullException" } @@ -1218,7 +1218,7 @@ dir -Recurse ` $testCases = @( @{ inputStr = "Invoke-CimMethod -ClassName Win32_Process -MethodName Crea"; expected = "Create" } @{ inputStr = "Get-CimInstance -ClassName Win32_Process | Invoke-CimMethod -MethodName AttachDeb"; expected = "AttachDebugger" } - @{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $Pid } | Get-CimAssociatedInstance -ResultClassName Win32_Co*uterSyst'; expected = "Win32_ComputerSystem" } + @{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $PID } | Get-CimAssociatedInstance -ResultClassName Win32_Co*uterSyst'; expected = "Win32_ComputerSystem" } @{ inputStr = "Get-CimInstance -ClassName Win32_Environm"; expected = "Win32_Environment" } @{ inputStr = "New-CimInstance -ClassName Win32_Environm"; expected = "Win32_Environment" } @{ inputStr = 'New-CimInstance -ClassName Win32_Process | %{ $_.Captio'; expected = "Caption" } @@ -1228,7 +1228,7 @@ dir -Recurse ` @{ inputStr = 'Invoke-CimMethod -Namespace root/StandardCimv2 -ClassName MSFT_NetIPAddress -MethodName Crea'; expected = 'Create' } @{ inputStr = '$win32_process = Get-CimInstance -ClassName Win32_Process; $win32_process | Invoke-CimMethod -MethodName AttachDe'; expected = 'AttachDebugger' } @{ inputStr = '$win32_process = Get-CimInstance -ClassName Win32_Process; Invoke-CimMethod -InputObject $win32_process -MethodName AttachDe'; expected = 'AttachDebugger' } - @{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $Pid } | Get-CimAssociatedInstance -ResultClassName Win32_ComputerS'; expected = 'Win32_ComputerSystem' } + @{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $PID } | Get-CimAssociatedInstance -ResultClassName Win32_ComputerS'; expected = 'Win32_ComputerSystem' } @{ inputStr = 'Get-CimInstance -Namespace root/Interop -ClassName Win32_PowerSupplyP'; expected = 'Win32_PowerSupplyProfile' } @{ inputStr = 'Get-CimInstance __NAMESP'; expected = '__NAMESPACE' } @{ inputStr = 'Get-CimInstance -Namespace root/Inter'; expected = 'root/Interop' } diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 3b3dbd6481..a3dae18f94 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/Language/Operators/NullConditional.Tests.ps1 b/test/powershell/Language/Operators/NullConditional.Tests.ps1 index 3bb2140271..7284b8e406 100644 --- a/test/powershell/Language/Operators/NullConditional.Tests.ps1 +++ b/test/powershell/Language/Operators/NullConditional.Tests.ps1 @@ -300,7 +300,7 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' { ${array}?.length | Should -Be 3 ${hash}?.a | Should -Be 1 - (Get-Process -Id $pid)?.Name | Should -BeLike "pwsh*" + (Get-Process -Id $PID)?.Name | Should -BeLike "pwsh*" (Get-Item $TestDrive)?.EnumerateFiles()?.Name | Should -BeExactly 'testfile.txt' [int32]::MaxValue?.ToString() | Should -BeExactly '2147483647' @@ -365,7 +365,7 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' { It 'Use ?. on a dynamic property name' { $testContent = @' $propName = 'Name' - (Get-Process -Id $pid)?.$propName | Should -BeLike 'pwsh*' + (Get-Process -Id $PID)?.$propName | Should -BeLike 'pwsh*' ${doesNotExist}?.$propName() | Should -BeNullOrEmpty '@ 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") diff --git a/test/powershell/Language/Operators/TernaryOperator.Tests.ps1 b/test/powershell/Language/Operators/TernaryOperator.Tests.ps1 index 99b219a6e6..1b0c810448 100644 --- a/test/powershell/Language/Operators/TernaryOperator.Tests.ps1 +++ b/test/powershell/Language/Operators/TernaryOperator.Tests.ps1 @@ -88,15 +88,15 @@ Describe "Using of ternary operator" -Tags CI { It "Tab completion for variables assigned with ternary expression should work as expected" { ## Type inference for the ternary expression should aggregate the inferred values from both branches - $text1 = '$var1 = $IsCoreCLR ? (Get-Item $PSHome) : (Get-Process -Id $PID); $var1.Full' + $text1 = '$var1 = $IsCoreCLR ? (Get-Item $PSHOME) : (Get-Process -Id $PID); $var1.Full' $result = TabExpansion2 -inputScript $text1 -cursorColumn $text1.Length $result.CompletionMatches[0].CompletionText | Should -BeExactly FullName - $text2 = '$var1 = $IsCoreCLR ? (Get-Item $PSHome) : (Get-Process -Id $PID); $var1.Proce' + $text2 = '$var1 = $IsCoreCLR ? (Get-Item $PSHOME) : (Get-Process -Id $PID); $var1.Proce' $result = TabExpansion2 -inputScript $text2 -cursorColumn $text2.Length $result.CompletionMatches[0].CompletionText | Should -BeExactly ProcessName - $text3 = '$IsCoreCLR ? ($var2 = Get-Item $PSHome) : "blah"; $var2.Full' + $text3 = '$IsCoreCLR ? ($var2 = Get-Item $PSHOME) : "blah"; $var2.Full' $result = TabExpansion2 -inputScript $text3 -cursorColumn $text3.Length $result.CompletionMatches[0].CompletionText | Should -BeExactly FullName } 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/Parser/Parser.Tests.ps1 b/test/powershell/Language/Parser/Parser.Tests.ps1 index 3c731fee98..a14c98fd6a 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 "