diff --git a/.github/workflows/pwsh.yml b/.github/workflows/pwsh.yml index 0cd76f277..7668504f4 100644 --- a/.github/workflows/pwsh.yml +++ b/.github/workflows/pwsh.yml @@ -34,6 +34,11 @@ jobs: run: | Import-Module Pester -PassThru $ErrorActionPreference = 'Continue' + + "Currently, PSNativeCommandArgumentPassing: '$PSNativeCommandArgumentPassing'" + "Forcing PowerShell 7.3 behavior with value: 'Standard'..." + $PSNativeCommandArgumentPassing = 'Standard' + $res = Invoke-Pester -Path test -Output Detailed -PassThru -ErrorAction SilentlyContinue if (!$res -or ($res.FailedCount -gt 0)) { $Error | Format-List * -Force diff --git a/test/GitParamTabExpansionVsts.Tests.ps1 b/test/GitParamTabExpansionVsts.Tests.ps1 index 729b9f7f9..31cc28af4 100644 --- a/test/GitParamTabExpansionVsts.Tests.ps1 +++ b/test/GitParamTabExpansionVsts.Tests.ps1 @@ -7,10 +7,7 @@ Describe 'ParamsTabExpansion VSTS Tests' { # Create a git alias for 'pr', as if we'd installed vsts-cli BeforeEach { [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssigments', '')] - $repoPath = NewGitTempRepo - - # Test with non-standard vsts pr alias name - &$gitbin config alias.test-vsts-pr "!f() { exec vsts code pr \`"`$`@\`"; }; f" + $repoPath = NewGitTempRepo -WithAliasTestVstsPr } AfterEach { RemoveGitTempRepo $repoPath diff --git a/test/Shared.ps1 b/test/Shared.ps1 index 036e3a6b8..18bf3882d 100644 --- a/test/Shared.ps1 +++ b/test/Shared.ps1 @@ -122,7 +122,7 @@ function MakeGitPath([string]$Path) { $Path -replace '\\', '/' } -function NewGitTempRepo([switch]$MakeInitialCommit) { +function NewGitTempRepo([switch]$MakeInitialCommit, [switch]$WithAliasTestVstsPr) { Push-Location $temp = [System.IO.Path]::GetTempPath() $repoPath = Join-Path $temp ([IO.Path]::GetRandomFileName()) @@ -142,6 +142,18 @@ function NewGitTempRepo([switch]$MakeInitialCommit) { &$gitbin commit -m "initial commit." *>$null } + if ($WithAliasTestVstsPr) { + # Test with non-standard vsts pr alias name + $value = "!f() { exec vsts code pr `"$@`"; }; f" + + if (-not (Test-Path Variable:PSNativeCommandArgumentPassing) ` + -or $PSNativeCommandArgumentPassing -eq 'Legacy') { + $value = $value.Replace("`"", "\`"") + } + + &$gitbin config alias.test-vsts-pr $value + } + $repoPath } diff --git a/test/TabExpansion.Tests.ps1 b/test/TabExpansion.Tests.ps1 index 4138893e4..7e113aaf4 100644 --- a/test/TabExpansion.Tests.ps1 +++ b/test/TabExpansion.Tests.ps1 @@ -213,10 +213,7 @@ Describe 'TabExpansion Tests' { Context 'Vsts' { BeforeEach { [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssigments', '')] - $repoPath = NewGitTempRepo - - # Test with non-standard vsts pr alias name - &$gitbin config alias.test-vsts-pr "!f() { exec vsts code pr \`"`$`@\`"; }; f" + $repoPath = NewGitTempRepo -WithAliasTestVstsPr } AfterEach { RemoveGitTempRepo $repoPath