Correct pwsh run (#11486)
This commit is contained in:
parent
2c0d68c1c2
commit
b221c2afa2
|
@ -244,17 +244,17 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
|
||||||
'@
|
'@
|
||||||
$testFilePath = Join-Path $TestDrive "test.ps1"
|
$testFilePath = Join-Path $TestDrive "test.ps1"
|
||||||
Set-Content -Path $testFilePath -Value $testScript
|
Set-Content -Path $testFilePath -Value $testScript
|
||||||
$observed = echo hello | pwsh -noprofile $testFilePath e -
|
$observed = echo hello | & $powershell -noprofile $testFilePath e -
|
||||||
$observed | Should -BeExactly "h-llo"
|
$observed | Should -BeExactly "h-llo"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Empty command should fail" {
|
It "Empty command should fail" {
|
||||||
pwsh -noprofile -c ''
|
& $powershell -noprofile -c ''
|
||||||
$LASTEXITCODE | Should -Be 64
|
$LASTEXITCODE | Should -Be 64
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Whitespace command should succeed" {
|
It "Whitespace command should succeed" {
|
||||||
pwsh -noprofile -c ' ' | Should -BeNullOrEmpty
|
& $powershell -noprofile -c ' ' | Should -BeNullOrEmpty
|
||||||
$LASTEXITCODE | Should -Be 0
|
$LASTEXITCODE | Should -Be 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ namespace StackTest {
|
||||||
|
|
||||||
Context "PATH environment variable" {
|
Context "PATH environment variable" {
|
||||||
It "`$PSHOME should be in front so that pwsh.exe starts current running PowerShell" {
|
It "`$PSHOME should be in front so that pwsh.exe starts current running PowerShell" {
|
||||||
pwsh -v | Should -Match $psversiontable.GitCommitId
|
& $powershell -v | Should -Match $psversiontable.GitCommitId
|
||||||
}
|
}
|
||||||
|
|
||||||
It "powershell starts if PATH is not set" -Skip:($IsWindows) {
|
It "powershell starts if PATH is not set" -Skip:($IsWindows) {
|
||||||
|
@ -731,7 +731,7 @@ namespace StackTest {
|
||||||
"@ > $PROFILE
|
"@ > $PROFILE
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$out = pwsh -workingdirectory ~ -c '(Get-Location).Path'
|
$out = & $powershell -workingdirectory ~ -c '(Get-Location).Path'
|
||||||
$out | Should -HaveCount 2
|
$out | Should -HaveCount 2
|
||||||
$out[0] | Should -BeExactly (Get-Item ~).FullName
|
$out[0] | Should -BeExactly (Get-Item ~).FullName
|
||||||
$out[1] | Should -BeExactly "$testdrive"
|
$out[1] | Should -BeExactly "$testdrive"
|
||||||
|
@ -879,7 +879,7 @@ public enum ShowWindowCommands : int
|
||||||
param ($WindowStyle)
|
param ($WindowStyle)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$ps = Start-Process pwsh -ArgumentList "-WindowStyle $WindowStyle -noexit -interactive" -PassThru
|
$ps = Start-Process $powershell -ArgumentList "-WindowStyle $WindowStyle -noexit -interactive" -PassThru
|
||||||
$startTime = Get-Date
|
$startTime = Get-Date
|
||||||
$showCmd = "Unknown"
|
$showCmd = "Unknown"
|
||||||
while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and $showCmd -ne $WindowStyle) {
|
while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and $showCmd -ne $WindowStyle) {
|
||||||
|
@ -894,7 +894,7 @@ public enum ShowWindowCommands : int
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Invalid -WindowStyle returns error" {
|
It "Invalid -WindowStyle returns error" {
|
||||||
pwsh -WindowStyle invalid
|
& $powershell -WindowStyle invalid
|
||||||
$LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter
|
$LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ Describe "Validate start of console host" -Tag CI {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "PSReadLine should not be auto-loaded when screen reader status is active" -Skip:(-not $IsWindows) {
|
It "PSReadLine should not be auto-loaded when screen reader status is active" -Skip:(-not $IsWindows) {
|
||||||
$output = pwsh -noprofile -noexit -c "Get-Module PSReadLine; exit"
|
$output = & "$PSHOME/pwsh" -noprofile -noexit -c "Get-Module PSReadLine; exit"
|
||||||
$output.Length | Should -BeExactly 2
|
$output.Length | Should -BeExactly 2
|
||||||
|
|
||||||
## The warning message about screen reader should be returned, but the PSReadLine module should not be loaded.
|
## The warning message about screen reader should be returned, but the PSReadLine module should not be loaded.
|
||||||
|
|
|
@ -99,7 +99,7 @@ Describe "Validate start of console host" -Tag CI {
|
||||||
Remove-Item $profileDataFile -Force
|
Remove-Item $profileDataFile -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
$loadedAssemblies = pwsh -noprofile -command '([System.AppDomain]::CurrentDomain.GetAssemblies()).manifestmodule | Where-Object { $_.Name -notlike ""<*>"" } | ForEach-Object { $_.Name }'
|
$loadedAssemblies = & "$PSHOME/pwsh" -noprofile -command '([System.AppDomain]::CurrentDomain.GetAssemblies()).manifestmodule | Where-Object { $_.Name -notlike ""<*>"" } | ForEach-Object { $_.Name }'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "No new assemblies are loaded" {
|
It "No new assemblies are loaded" {
|
||||||
|
|
|
@ -74,25 +74,25 @@ public class ABC {}
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
It "Assembly loaded at runtime" -pending {
|
It "Assembly loaded at runtime" -pending {
|
||||||
$assemblies = pwsh -noprofile -command @"
|
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
||||||
using assembly .\UsingAssemblyTest$guid.dll
|
using assembly .\UsingAssemblyTest$guid.dll
|
||||||
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
"@
|
"@
|
||||||
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
|
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
|
||||||
|
|
||||||
$assemblies = pwsh -noprofile -command @"
|
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
||||||
using assembly $PSScriptRoot\UsingAssemblyTest$guid.dll
|
using assembly $PSScriptRoot\UsingAssemblyTest$guid.dll
|
||||||
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
"@
|
"@
|
||||||
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
|
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
|
||||||
|
|
||||||
$assemblies = pwsh -noprofile -command @"
|
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
||||||
using assembly System.Drawing
|
using assembly System.Drawing
|
||||||
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
"@
|
"@
|
||||||
$assemblies -contains "System.Drawing" | Should -BeTrue
|
$assemblies -contains "System.Drawing" | Should -BeTrue
|
||||||
|
|
||||||
$assemblies = pwsh -noprofile -command @"
|
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
||||||
using assembly 'System.Drawing, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
|
using assembly 'System.Drawing, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
|
||||||
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
"@
|
"@
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Native streams behavior with PowerShell" -Tags 'CI' {
|
Describe "Native streams behavior with PowerShell" -Tags 'CI' {
|
||||||
|
BeforeAll {
|
||||||
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
|
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
|
||||||
|
}
|
||||||
|
|
||||||
Context "Error stream" {
|
Context "Error stream" {
|
||||||
# we are using powershell itself as an example of a native program.
|
# we are using powershell itself as an example of a native program.
|
||||||
|
@ -57,7 +59,7 @@ Describe "Native streams behavior with PowerShell" -Tags 'CI' {
|
||||||
while ($longtext.Length -lt [console]::WindowWidth) {
|
while ($longtext.Length -lt [console]::WindowWidth) {
|
||||||
$longtext += $longtext
|
$longtext += $longtext
|
||||||
}
|
}
|
||||||
pwsh -c "& { [Console]::Error.WriteLine('$longtext') }" 2>&1 > $testdrive\error.txt
|
& $powershell -c "& { [Console]::Error.WriteLine('$longtext') }" 2>&1 > $testdrive\error.txt
|
||||||
$e = Get-Content -Path $testdrive\error.txt
|
$e = Get-Content -Path $testdrive\error.txt
|
||||||
$e.Count | Should -Be 1
|
$e.Count | Should -Be 1
|
||||||
$e | Should -BeExactly $longtext
|
$e | Should -BeExactly $longtext
|
||||||
|
|
|
@ -414,6 +414,7 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" {
|
||||||
|
|
||||||
Context "Tests that ErrorAction/WarningAction have effect when Import-Module with WinCompat is used" {
|
Context "Tests that ErrorAction/WarningAction have effect when Import-Module with WinCompat is used" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
|
$pwsh = "$PSHOME/pwsh"
|
||||||
Add-ModulePath $basePath
|
Add-ModulePath $basePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,25 +424,25 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" {
|
||||||
|
|
||||||
It "Verify that Error is generated with default ErrorAction" {
|
It "Verify that Error is generated with default ErrorAction" {
|
||||||
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
||||||
pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName" *> $LogPath
|
& $pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName" *> $LogPath
|
||||||
$LogPath | Should -FileContentMatch 'divide by zero'
|
$LogPath | Should -FileContentMatch 'divide by zero'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verify that Warning is generated with default WarningAction" {
|
It "Verify that Warning is generated with default WarningAction" {
|
||||||
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
||||||
pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName" *> $LogPath
|
& $pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName" *> $LogPath
|
||||||
$LogPath | Should -FileContentMatch 'loaded in Windows PowerShell'
|
$LogPath | Should -FileContentMatch 'loaded in Windows PowerShell'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verify that Error is Not generated with -ErrorAction Ignore" {
|
It "Verify that Error is Not generated with -ErrorAction Ignore" {
|
||||||
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
||||||
pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName -ErrorAction Ignore" *> $LogPath
|
& $pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName -ErrorAction Ignore" *> $LogPath
|
||||||
$LogPath | Should -Not -FileContentMatch 'divide by zero'
|
$LogPath | Should -Not -FileContentMatch 'divide by zero'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verify that Warning is Not generated with -WarningAction Ignore" {
|
It "Verify that Warning is Not generated with -WarningAction Ignore" {
|
||||||
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
$LogPath = Join-Path $TestDrive (New-Guid).ToString()
|
||||||
pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName -WarningAction Ignore" *> $LogPath
|
& $pwsh -NoProfile -NonInteractive -c "[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('TestWindowsPowerShellPSHomeLocation', `'$basePath`');Import-Module $ModuleName -WarningAction Ignore" *> $LogPath
|
||||||
$LogPath | Should -Not -FileContentMatch 'loaded in Windows PowerShell'
|
$LogPath | Should -Not -FileContentMatch 'loaded in Windows PowerShell'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +473,8 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" {
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "PSModulePath changes interacting with other PowerShell processes" -Tag "Feature" {
|
Describe "PSModulePath changes interacting with other PowerShell processes" -Tag "Feature" {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
|
$pwsh = "$PSHOME/pwsh"
|
||||||
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
|
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
|
||||||
if ( ! $IsWindows ) {
|
if ( ! $IsWindows ) {
|
||||||
$PSDefaultParameterValues["it:skip"] = $true
|
$PSDefaultParameterValues["it:skip"] = $true
|
||||||
|
@ -507,14 +508,14 @@ Describe "PSModulePath changes interacting with other PowerShell processes" -Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Allows PowerShell subprocesses to call core modules" {
|
It "Allows PowerShell subprocesses to call core modules" {
|
||||||
$errors = pwsh.exe -Command "Get-ChildItem" 2>&1 | Where-Object { $_ -is [System.Management.Automation.ErrorRecord] }
|
$errors = & $pwsh -Command "Get-ChildItem" 2>&1 | Where-Object { $_ -is [System.Management.Automation.ErrorRecord] }
|
||||||
$errors | Should -Be $null
|
$errors | Should -Be $null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Does not duplicate the System32 module path in subprocesses" {
|
It "Does not duplicate the System32 module path in subprocesses" {
|
||||||
$sys32ModPathCount = pwsh.exe -C {
|
$sys32ModPathCount = & $pwsh -C {
|
||||||
pwsh.exe -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
|
$sys32ModPathCount | Should -Be 1
|
||||||
|
|
|
@ -274,7 +274,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" {
|
||||||
|
|
||||||
It "'Get-Module -ListAvailable' should not load the module assembly" {
|
It "'Get-Module -ListAvailable' should not load the module assembly" {
|
||||||
## $fullName should be null and thus the result should just be the module's name.
|
## $fullName should be null and thus the result should just be the module's name.
|
||||||
$result = pwsh -noprofile -c "`$env:PSModulePath = '$tempModulePath'; `$module = Get-Module -ListAvailable; `$fullName = [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location -eq $assemblyPath | Foreach-Object FullName; `$module.Name + `$fullName"
|
$result = & "$PSHOME/pwsh" -noprofile -c "`$env:PSModulePath = '$tempModulePath'; `$module = Get-Module -ListAvailable; `$fullName = [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location -eq $assemblyPath | Foreach-Object FullName; `$module.Name + `$fullName"
|
||||||
$result | Should -BeExactly "MyModuelTest"
|
$result | Should -BeExactly "MyModuelTest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' {
|
||||||
Copy-Item $gacAssemblyPath -Destination $destPath -Force
|
Copy-Item $gacAssemblyPath -Destination $destPath -Force
|
||||||
|
|
||||||
# Use a different pwsh so that we do not have the PSScheduledJob module already loaded.
|
# Use a different pwsh so that we do not have the PSScheduledJob module already loaded.
|
||||||
$loadedAssemblyLocation = pwsh -noprofile -c "Import-Module $destPath -Force; [Microsoft.PowerShell.ScheduledJob.AddJobTriggerCommand].Assembly.Location"
|
$loadedAssemblyLocation = & "$PSHOME/pwsh" -noprofile -c "Import-Module $destPath -Force; [Microsoft.PowerShell.ScheduledJob.AddJobTriggerCommand].Assembly.Location"
|
||||||
$loadedAssemblyLocation | Should -BeLike "$TestDrive*\Microsoft.PowerShell.ScheduledJob.dll"
|
$loadedAssemblyLocation | Should -BeLike "$TestDrive*\Microsoft.PowerShell.ScheduledJob.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ Describe "Get-Command Feature tests" -Tag Feature {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Can return multiple results relying on auto module loading" {
|
It "Can return multiple results relying on auto module loading" {
|
||||||
$results = pwsh -outputformat xml -command "`$env:PSModulePath += '$testPSModulePath'; Get-Command i-fzz -UseAbbreviationExpansion"
|
$results = & "$PSHOME/pwsh" -outputformat xml -command "`$env:PSModulePath += '$testPSModulePath'; Get-Command i-fzz -UseAbbreviationExpansion"
|
||||||
$results | Should -HaveCount 2
|
$results | Should -HaveCount 2
|
||||||
$results.Name | Should -Contain "Invoke-FooZedZed"
|
$results.Name | Should -Contain "Invoke-FooZedZed"
|
||||||
$results.Name | Should -Contain "Import-FooZedZed"
|
$results.Name | Should -Contain "Import-FooZedZed"
|
||||||
|
|
|
@ -39,7 +39,7 @@ Describe "Read-Host Test" -tag "CI" {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Read-Host doesn't enter command prompt mode" {
|
It "Read-Host doesn't enter command prompt mode" {
|
||||||
$result = "!1" | pwsh -NoProfile -c "Read-host -Prompt 'foo'"
|
$result = "!1" | & "$PSHOME/pwsh" -NoProfile -c "Read-host -Prompt 'foo'"
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
# Windows write to console directly so can't capture prompt in stdout
|
# Windows write to console directly so can't capture prompt in stdout
|
||||||
$expected = @('!1','!1')
|
$expected = @('!1','!1')
|
||||||
|
|
|
@ -101,7 +101,7 @@ Describe "Write-Error Tests" -Tags "CI" {
|
||||||
while ($longtext.Length -lt [console]::WindowWidth) {
|
while ($longtext.Length -lt [console]::WindowWidth) {
|
||||||
$longtext += $longtext
|
$longtext += $longtext
|
||||||
}
|
}
|
||||||
$result = pwsh -noprofile -command "`$ErrorView = 'NormalView'; Write-Error -Message '$longtext'" 2>&1
|
$result = & "$PSHOME/pwsh" -noprofile -command "`$ErrorView = 'NormalView'; Write-Error -Message '$longtext'" 2>&1
|
||||||
$result.Count | Should -BeExactly 3
|
$result.Count | Should -BeExactly 3
|
||||||
$result[0] | Should -Match $longtext
|
$result[0] | Should -Match $longtext
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Transcription should be closed if the only runspace gets closed" {
|
It "Transcription should be closed if the only runspace gets closed" {
|
||||||
pwsh -c "start-transcript $transcriptFilePath; Write-Host ''Before Dispose'';"
|
& "$PSHOME/pwsh" -c "start-transcript $transcriptFilePath; Write-Host ''Before Dispose'';"
|
||||||
|
|
||||||
$transcriptFilePath | Should -Exist
|
$transcriptFilePath | Should -Exist
|
||||||
$transcriptFilePath | Should -FileContentMatch "Before Dispose"
|
$transcriptFilePath | Should -FileContentMatch "Before Dispose"
|
||||||
|
|
|
@ -49,7 +49,7 @@ $null = $ps.AddScript(1).Invoke()
|
||||||
exit
|
exit
|
||||||
'@
|
'@
|
||||||
$outputFile = New-Item -Path $TestDrive\output.txt -ItemType File
|
$outputFile = New-Item -Path $TestDrive\output.txt -ItemType File
|
||||||
$process = Start-Process pwsh -ArgumentList $command -PassThru -RedirectStandardOutput $outputFile
|
$process = Start-Process "$PSHOME/pwsh" -ArgumentList $command -PassThru -RedirectStandardOutput $outputFile
|
||||||
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 1000 | Should -BeTrue
|
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 1000 | Should -BeTrue
|
||||||
$hasExited = $process.HasExited
|
$hasExited = $process.HasExited
|
||||||
|
|
||||||
|
|
|
@ -523,8 +523,8 @@ Describe "Verify approved aliases list" -Tags "CI" {
|
||||||
if ($isPreview) {
|
if ($isPreview) {
|
||||||
$emptyConfigPath = Join-Path -Path $TestDrive -ChildPath "test.config.json"
|
$emptyConfigPath = Join-Path -Path $TestDrive -ChildPath "test.config.json"
|
||||||
Set-Content -Path $emptyConfigPath -Value "" -Force -ErrorAction Stop
|
Set-Content -Path $emptyConfigPath -Value "" -Force -ErrorAction Stop
|
||||||
$currentAliasList = pwsh -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getAliases -args ($moduleList | ConvertTo-Json)
|
$currentAliasList = & "$PSHOME/pwsh" -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getAliases -args ($moduleList | ConvertTo-Json)
|
||||||
$currentCmdletList = pwsh -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getCommands -args ($moduleList | ConvertTo-Json)
|
$currentCmdletList = & "$PSHOME/pwsh" -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getCommands -args ($moduleList | ConvertTo-Json)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$currentAliasList = & $getAliases $moduleList
|
$currentAliasList = & $getAliases $moduleList
|
||||||
|
|
|
@ -151,7 +151,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
|
||||||
Set-ItemProperty -Path $KeyPath -Name EnableInvocationHeader -Value 1 -Force
|
Set-ItemProperty -Path $KeyPath -Name EnableInvocationHeader -Value 1 -Force
|
||||||
|
|
||||||
$number = get-random
|
$number = get-random
|
||||||
$null = pwsh -NoProfile -NonInteractive -c "$number"
|
$null = & "$PSHOME/pwsh" -NoProfile -NonInteractive -c "$number"
|
||||||
|
|
||||||
Remove-ItemProperty -Path $KeyPath -Name OutputDirectory -Force
|
Remove-ItemProperty -Path $KeyPath -Name OutputDirectory -Force
|
||||||
Remove-ItemProperty -Path $KeyPath -Name EnableInvocationHeader -Force
|
Remove-ItemProperty -Path $KeyPath -Name EnableInvocationHeader -Force
|
||||||
|
@ -228,7 +228,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
|
||||||
Set-ItemProperty -Path $KeyPath -Name ConsoleSessionConfigurationName -Value $SessionName -Force
|
Set-ItemProperty -Path $KeyPath -Name ConsoleSessionConfigurationName -Value $SessionName -Force
|
||||||
|
|
||||||
$LogPath = (New-TemporaryFile).FullName
|
$LogPath = (New-TemporaryFile).FullName
|
||||||
pwsh -NoProfile -NonInteractive -c "1" *> $LogPath # this implicitly uses SessionConfiguration from the policy
|
& "$PSHOME/pwsh" -NoProfile -NonInteractive -c "1" *> $LogPath # this implicitly uses SessionConfiguration from the policy
|
||||||
|
|
||||||
# Log should have an error that has our configuration session name; e.g.:
|
# Log should have an error that has our configuration session name; e.g.:
|
||||||
# 'The shell cannot be started. A failure occurred during initialization:
|
# 'The shell cannot be started. A failure occurred during initialization:
|
||||||
|
|
|
@ -6,6 +6,6 @@ Describe "Resolve types in additional referenced assemblies" -Tag CI {
|
||||||
@{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" }
|
@{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" }
|
||||||
){
|
){
|
||||||
param ($typename, $name)
|
param ($typename, $name)
|
||||||
pwsh -noprofile -command "$typename.Name" | Should -BeExactly $name
|
& "$PSHOME/pwsh" -noprofile -command "$typename.Name" | Should -BeExactly $name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ Import-Module HelpersCommon
|
||||||
Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tags "Feature","RequireAdminOnWindows" {
|
Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tags "Feature","RequireAdminOnWindows" {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
|
$pwsh = "$PSHOME/pwsh"
|
||||||
$systemConfigPath = "$PSHOME/powershell.config.json"
|
$systemConfigPath = "$PSHOME/powershell.config.json"
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
$userConfigPath = "~/Documents/powershell/powershell.config.json"
|
$userConfigPath = "~/Documents/powershell/powershell.config.json"
|
||||||
|
@ -58,11 +59,11 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
||||||
$feature.Enabled | Should -BeFalse -Because "All Experimental Features disabled when no config file"
|
$feature.Enabled | Should -BeFalse -Because "All Experimental Features disabled when no config file"
|
||||||
$feature = pwsh -noprofile -output xml -command Enable-ExperimentalFeature ExpTest.FeatureOne -Scope $scope -WarningAction SilentlyContinue
|
$feature = & $pwsh -noprofile -output xml -command Enable-ExperimentalFeature ExpTest.FeatureOne -Scope $scope -WarningAction SilentlyContinue
|
||||||
$feature | Should -BeNullOrEmpty -Because "No object is output to pipeline on success"
|
$feature | Should -BeNullOrEmpty -Because "No object is output to pipeline on success"
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
||||||
$feature.Enabled | Should -BeTrue -Because "The experimental feature is now enabled"
|
$feature.Enabled | Should -BeTrue -Because "The experimental feature is now enabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +78,11 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
|
||||||
}
|
}
|
||||||
|
|
||||||
'{"ExperimentalFeatures":["ExpTest.FeatureOne"]}' > $configPath
|
'{"ExperimentalFeatures":["ExpTest.FeatureOne"]}' > $configPath
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
||||||
$feature.Enabled | Should -BeTrue -Because "Test config should enable ExpTest.FeatureOne"
|
$feature.Enabled | Should -BeTrue -Because "Test config should enable ExpTest.FeatureOne"
|
||||||
$feature = pwsh -noprofile -output xml -command Disable-ExperimentalFeature ExpTest.FeatureOne -Scope $scope -WarningAction SilentlyContinue
|
$feature = & $pwsh -noprofile -output xml -command Disable-ExperimentalFeature ExpTest.FeatureOne -Scope $scope -WarningAction SilentlyContinue
|
||||||
$feature | Should -BeNullOrEmpty -Because "No object is output to pipeline on success"
|
$feature | Should -BeNullOrEmpty -Because "No object is output to pipeline on success"
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
||||||
$feature.Enabled | Should -BeFalse -Because "The experimental feature is now disabled"
|
$feature.Enabled | Should -BeFalse -Because "The experimental feature is now disabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ Import-Module HelpersCommon
|
||||||
Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows" {
|
Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows" {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
|
$pwsh = "$PSHOME/pwsh"
|
||||||
$systemConfigPath = "$PSHOME/powershell.config.json"
|
$systemConfigPath = "$PSHOME/powershell.config.json"
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
$userConfigPath = "~/Documents/powershell/powershell.config.json"
|
$userConfigPath = "~/Documents/powershell/powershell.config.json"
|
||||||
|
@ -55,7 +56,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
|
||||||
Context "Feature disabled tests" {
|
Context "Feature disabled tests" {
|
||||||
|
|
||||||
It "'Get-ExperimentalFeature' should return all available features from module path" {
|
It "'Get-ExperimentalFeature' should return all available features from module path" {
|
||||||
$features = pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest*"
|
$features = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest*"
|
||||||
$features | Should -Not -BeNullOrEmpty
|
$features | Should -Not -BeNullOrEmpty
|
||||||
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
||||||
$features[0].Enabled | Should -BeFalse
|
$features[0].Enabled | Should -BeFalse
|
||||||
|
@ -67,7 +68,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "'Get-ExperimentalFeature' pipeline input" {
|
It "'Get-ExperimentalFeature' pipeline input" {
|
||||||
$features = pwsh -noprofile -output xml -command { "ExpTest.FeatureOne", "ExpTest.FeatureTwo" | Get-ExperimentalFeature }
|
$features = & $pwsh -noprofile -output xml -command { "ExpTest.FeatureOne", "ExpTest.FeatureTwo" | Get-ExperimentalFeature }
|
||||||
$features | Should -Not -BeNullOrEmpty
|
$features | Should -Not -BeNullOrEmpty
|
||||||
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
||||||
$features[0].Enabled | Should -BeFalse
|
$features[0].Enabled | Should -BeFalse
|
||||||
|
@ -85,15 +86,15 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "'Get-ExperimentalFeature' should return enabled features 'ExpTest.FeatureOne'" {
|
It "'Get-ExperimentalFeature' should return enabled features 'ExpTest.FeatureOne'" {
|
||||||
pwsh -noprofile -command '$EnabledExperimentalFeatures.Count' | Should -Be 1
|
& $pwsh -noprofile -command '$EnabledExperimentalFeatures.Count' | Should -Be 1
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest.FeatureOne"
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest.FeatureOne"
|
||||||
$feature | Should -Not -BeNullOrEmpty
|
$feature | Should -Not -BeNullOrEmpty
|
||||||
$feature.Enabled | Should -BeTrue
|
$feature.Enabled | Should -BeTrue
|
||||||
$feature.Source | Should -BeExactly $testModuleManifestPath
|
$feature.Source | Should -BeExactly $testModuleManifestPath
|
||||||
}
|
}
|
||||||
|
|
||||||
It "'Get-ExperimentalFeature' should return all available features from module path" {
|
It "'Get-ExperimentalFeature' should return all available features from module path" {
|
||||||
$features = pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest*"
|
$features = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest*"
|
||||||
$features | Should -Not -BeNullOrEmpty
|
$features | Should -Not -BeNullOrEmpty
|
||||||
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
||||||
$features[0].Enabled | Should -BeTrue
|
$features[0].Enabled | Should -BeTrue
|
||||||
|
@ -105,7 +106,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "'Get-ExperimentalFeature' pipeline input" {
|
It "'Get-ExperimentalFeature' pipeline input" {
|
||||||
$features = pwsh -noprofile -output xml -command { "ExpTest.FeatureOne", "ExpTest.FeatureTwo" | Get-ExperimentalFeature }
|
$features = & $pwsh -noprofile -output xml -command { "ExpTest.FeatureOne", "ExpTest.FeatureTwo" | Get-ExperimentalFeature }
|
||||||
$features | Should -Not -BeNullOrEmpty
|
$features | Should -Not -BeNullOrEmpty
|
||||||
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
$features[0].Name | Should -BeExactly "ExpTest.FeatureOne"
|
||||||
$features[0].Enabled | Should -BeTrue
|
$features[0].Enabled | Should -BeTrue
|
||||||
|
@ -122,9 +123,9 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
|
||||||
'{"ExperimentalFeatures":["ExpTest.FeatureOne"]}' > $userConfigPath
|
'{"ExperimentalFeatures":["ExpTest.FeatureOne"]}' > $userConfigPath
|
||||||
'{"ExperimentalFeatures":["ExpTest.FeatureTwo"]}' > $systemConfigPath
|
'{"ExperimentalFeatures":["ExpTest.FeatureTwo"]}' > $systemConfigPath
|
||||||
|
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureOne
|
||||||
$feature.Enabled | Should -BeTrue -Because "FeatureOne is enabled in user config"
|
$feature.Enabled | Should -BeTrue -Because "FeatureOne is enabled in user config"
|
||||||
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureTwo
|
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature ExpTest.FeatureTwo
|
||||||
$feature.Enabled | Should -BeFalse -Because "System config is not read when user config exists"
|
$feature.Enabled | Should -BeFalse -Because "System config is not read when user config exists"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,14 @@ Describe 'Tests for $ErrorView' -Tag CI {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Activity shows up correctly for scriptblocks" {
|
It "Activity shows up correctly for scriptblocks" {
|
||||||
$e = pwsh -noprofile -command 'Write-Error 'myError' -ErrorAction SilentlyContinue; $error[0] | Out-String'
|
$e = & "$PSHOME/pwsh" -noprofile -command 'Write-Error 'myError' -ErrorAction SilentlyContinue; $error[0] | Out-String'
|
||||||
[string]::Join('', $e).Trim() | Should -BeLike "*Write-Error:*myError*" # wildcard due to VT100
|
[string]::Join('', $e).Trim() | Should -BeLike "*Write-Error:*myError*" # wildcard due to VT100
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Function shows up correctly" {
|
It "Function shows up correctly" {
|
||||||
function test-myerror { [cmdletbinding()] param() write-error 'myError' }
|
function test-myerror { [cmdletbinding()] param() write-error 'myError' }
|
||||||
|
|
||||||
$e = pwsh -noprofile -command 'function test-myerror { [cmdletbinding()] param() write-error "myError" }; test-myerror -ErrorAction SilentlyContinue; $error[0] | Out-String'
|
$e = & "$PSHOME/pwsh" -noprofile -command 'function test-myerror { [cmdletbinding()] param() write-error "myError" }; test-myerror -ErrorAction SilentlyContinue; $error[0] | Out-String'
|
||||||
[string]::Join('', $e).Trim() | Should -BeLike "*test-myerror:*myError*" # wildcard due to VT100
|
[string]::Join('', $e).Trim() | Should -BeLike "*test-myerror:*myError*" # wildcard due to VT100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ Describe 'Basic Job Tests' -Tags 'CI' {
|
||||||
|
|
||||||
It "Create job with native command" {
|
It "Create job with native command" {
|
||||||
try {
|
try {
|
||||||
$nativeJob = Start-job { pwsh -c 1+1 }
|
$nativeJob = Start-job { & "$PSHOME/pwsh" -c 1+1 }
|
||||||
$nativeJob | Wait-Job
|
$nativeJob | Wait-Job
|
||||||
$nativeJob.State | Should -BeExactly "Completed"
|
$nativeJob.State | Should -BeExactly "Completed"
|
||||||
$nativeJob.HasMoreData | Should -BeTrue
|
$nativeJob.HasMoreData | Should -BeTrue
|
||||||
|
|
|
@ -180,7 +180,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||||
try {
|
try {
|
||||||
$userConfig = '{ "PSModulePath": "myUserPath" }'
|
$userConfig = '{ "PSModulePath": "myUserPath" }'
|
||||||
Set-Content -Path $userConfigPath -Value $userConfig -Force
|
Set-Content -Path $userConfigPath -Value $userConfig -Force
|
||||||
$out = pwsh -noprofile -command 'powershell.exe -noprofile -command $env:PSModulePath'
|
$out = & $powershell -noprofile -command 'powershell.exe -noprofile -command $env:PSModulePath'
|
||||||
$out | Should -Not -BeLike 'myUserPath;*'
|
$out | Should -Not -BeLike 'myUserPath;*'
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
|
@ -277,7 +277,7 @@ Describe "Parameter Binding Tests" -Tags "CI" {
|
||||||
$test2File = Join-Path -Path $tempDir -ChildPath "test2.ps1"
|
$test2File = Join-Path -Path $tempDir -ChildPath "test2.ps1"
|
||||||
|
|
||||||
$expected = "[$tempDir]"
|
$expected = "[$tempDir]"
|
||||||
$psPath = "$PSHOME\pwsh"
|
$pwsh = "$PSHOME\pwsh"
|
||||||
|
|
||||||
$null = New-Item -Path $tempDir -ItemType Directory -Force
|
$null = New-Item -Path $tempDir -ItemType Directory -Force
|
||||||
Set-Content -Path $test1File -Value $test1 -Force
|
Set-Content -Path $test1File -Value $test1 -Force
|
||||||
|
@ -297,10 +297,10 @@ Describe "Parameter Binding Tests" -Tags "CI" {
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Test 'powershell -File' should evaluate '`$PSScriptRoot' for parameter default value" {
|
It "Test 'powershell -File' should evaluate '`$PSScriptRoot' for parameter default value" {
|
||||||
$result = & $psPath -NoProfile -File $test1File
|
$result = & $pwsh -NoProfile -File $test1File
|
||||||
$result | Should -Be $expected
|
$result | Should -Be $expected
|
||||||
|
|
||||||
$result = & $psPath -NoProfile -File $test2File
|
$result = & $pwsh -NoProfile -File $test2File
|
||||||
$result | Should -Be $expected
|
$result | Should -Be $expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue