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] 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",