Correct pwsh run (#11486)

This commit is contained in:
Ilya 2020-01-05 12:17:41 +05:00 committed by GitHub
parent 2c0d68c1c2
commit b221c2afa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 61 additions and 56 deletions

View file

@ -244,17 +244,17 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
'@
$testFilePath = Join-Path $TestDrive "test.ps1"
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"
}
It "Empty command should fail" {
pwsh -noprofile -c ''
& $powershell -noprofile -c ''
$LASTEXITCODE | Should -Be 64
}
It "Whitespace command should succeed" {
pwsh -noprofile -c ' ' | Should -BeNullOrEmpty
& $powershell -noprofile -c ' ' | Should -BeNullOrEmpty
$LASTEXITCODE | Should -Be 0
}
}
@ -655,7 +655,7 @@ namespace StackTest {
Context "PATH environment variable" {
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) {
@ -731,7 +731,7 @@ namespace StackTest {
"@ > $PROFILE
try {
$out = pwsh -workingdirectory ~ -c '(Get-Location).Path'
$out = & $powershell -workingdirectory ~ -c '(Get-Location).Path'
$out | Should -HaveCount 2
$out[0] | Should -BeExactly (Get-Item ~).FullName
$out[1] | Should -BeExactly "$testdrive"
@ -879,7 +879,7 @@ public enum ShowWindowCommands : int
param ($WindowStyle)
try {
$ps = Start-Process pwsh -ArgumentList "-WindowStyle $WindowStyle -noexit -interactive" -PassThru
$ps = Start-Process $powershell -ArgumentList "-WindowStyle $WindowStyle -noexit -interactive" -PassThru
$startTime = Get-Date
$showCmd = "Unknown"
while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and $showCmd -ne $WindowStyle) {
@ -894,7 +894,7 @@ public enum ShowWindowCommands : int
}
It "Invalid -WindowStyle returns error" {
pwsh -WindowStyle invalid
& $powershell -WindowStyle invalid
$LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter
}
}

View file

@ -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) {
$output = pwsh -noprofile -noexit -c "Get-Module PSReadLine; exit"
$output = & "$PSHOME/pwsh" -noprofile -noexit -c "Get-Module PSReadLine; exit"
$output.Length | Should -BeExactly 2
## The warning message about screen reader should be returned, but the PSReadLine module should not be loaded.

View file

@ -99,7 +99,7 @@ Describe "Validate start of console host" -Tag CI {
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" {

View file

@ -74,25 +74,25 @@ public class ABC {}
}
#>
It "Assembly loaded at runtime" -pending {
$assemblies = pwsh -noprofile -command @"
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
using assembly .\UsingAssemblyTest$guid.dll
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
"@
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
$assemblies = pwsh -noprofile -command @"
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
using assembly $PSScriptRoot\UsingAssemblyTest$guid.dll
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
"@
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeTrue
$assemblies = pwsh -noprofile -command @"
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
using assembly System.Drawing
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
"@
$assemblies -contains "System.Drawing" | Should -BeTrue
$assemblies = pwsh -noprofile -command @"
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
using assembly 'System.Drawing, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
"@

View file

@ -1,7 +1,9 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Native streams behavior with PowerShell" -Tags 'CI' {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
}
Context "Error stream" {
# 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) {
$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.Count | Should -Be 1
$e | Should -BeExactly $longtext

View file

@ -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" {
BeforeAll {
$pwsh = "$PSHOME/pwsh"
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" {
$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'
}
It "Verify that Warning is generated with default WarningAction" {
$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'
}
It "Verify that Error is Not generated with -ErrorAction Ignore" {
$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'
}
It "Verify that Warning is Not generated with -WarningAction Ignore" {
$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'
}
@ -472,8 +473,8 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" {
}
Describe "PSModulePath changes interacting with other PowerShell processes" -Tag "Feature" {
BeforeAll {
$pwsh = "$PSHOME/pwsh"
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
if ( ! $IsWindows ) {
$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" {
$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
}
}
It "Does not duplicate the System32 module path in subprocesses" {
$sys32ModPathCount = pwsh.exe -C {
pwsh.exe -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count'
$sys32ModPathCount = & $pwsh -C {
& "$PSHOME/pwsh" -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count'
}
$sys32ModPathCount | Should -Be 1

View file

@ -274,7 +274,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" {
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.
$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"
}
}

View file

@ -257,7 +257,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' {
Copy-Item $gacAssemblyPath -Destination $destPath -Force
# 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"
}
}

View file

@ -35,7 +35,7 @@ Describe "Get-Command Feature tests" -Tag Feature {
}
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.Name | Should -Contain "Invoke-FooZedZed"
$results.Name | Should -Contain "Import-FooZedZed"

View file

@ -39,7 +39,7 @@ Describe "Read-Host Test" -tag "CI" {
}
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) {
# Windows write to console directly so can't capture prompt in stdout
$expected = @('!1','!1')

View file

@ -101,7 +101,7 @@ Describe "Write-Error Tests" -Tags "CI" {
while ($longtext.Length -lt [console]::WindowWidth) {
$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[0] | Should -Match $longtext
}

View file

@ -149,7 +149,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
}
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 -FileContentMatch "Before Dispose"

View file

@ -49,7 +49,7 @@ $null = $ps.AddScript(1).Invoke()
exit
'@
$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
$hasExited = $process.HasExited

View file

@ -523,8 +523,8 @@ Describe "Verify approved aliases list" -Tags "CI" {
if ($isPreview) {
$emptyConfigPath = Join-Path -Path $TestDrive -ChildPath "test.config.json"
Set-Content -Path $emptyConfigPath -Value "" -Force -ErrorAction Stop
$currentAliasList = 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)
$currentAliasList = & "$PSHOME/pwsh" -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getAliases -args ($moduleList | ConvertTo-Json)
$currentCmdletList = & "$PSHOME/pwsh" -NoProfile -OutputFormat XML -SettingsFile $emptyConfigPath -Command $getCommands -args ($moduleList | ConvertTo-Json)
}
else {
$currentAliasList = & $getAliases $moduleList

View file

@ -151,7 +151,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
Set-ItemProperty -Path $KeyPath -Name EnableInvocationHeader -Value 1 -Force
$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 EnableInvocationHeader -Force
@ -228,7 +228,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
Set-ItemProperty -Path $KeyPath -Name ConsoleSessionConfigurationName -Value $SessionName -Force
$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.:
# 'The shell cannot be started. A failure occurred during initialization:

View file

@ -6,6 +6,6 @@ Describe "Resolve types in additional referenced assemblies" -Tag CI {
@{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" }
){
param ($typename, $name)
pwsh -noprofile -command "$typename.Name" | Should -BeExactly $name
& "$PSHOME/pwsh" -noprofile -command "$typename.Name" | Should -BeExactly $name
}
}

View file

@ -6,6 +6,7 @@ Import-Module HelpersCommon
Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tags "Feature","RequireAdminOnWindows" {
BeforeAll {
$pwsh = "$PSHOME/pwsh"
$systemConfigPath = "$PSHOME/powershell.config.json"
if ($IsWindows) {
$userConfigPath = "~/Documents/powershell/powershell.config.json"
@ -58,11 +59,11 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
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 = 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 = 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"
}
@ -77,11 +78,11 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
}
'{"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 = 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 = 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"
}

View file

@ -6,6 +6,7 @@ Import-Module HelpersCommon
Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows" {
BeforeAll {
$pwsh = "$PSHOME/pwsh"
$systemConfigPath = "$PSHOME/powershell.config.json"
if ($IsWindows) {
$userConfigPath = "~/Documents/powershell/powershell.config.json"
@ -55,7 +56,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
Context "Feature disabled tests" {
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[0].Name | Should -BeExactly "ExpTest.FeatureOne"
$features[0].Enabled | Should -BeFalse
@ -67,7 +68,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
}
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[0].Name | Should -BeExactly "ExpTest.FeatureOne"
$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'" {
pwsh -noprofile -command '$EnabledExperimentalFeatures.Count' | Should -Be 1
$feature = pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest.FeatureOne"
& $pwsh -noprofile -command '$EnabledExperimentalFeatures.Count' | Should -Be 1
$feature = & $pwsh -noprofile -output xml -command Get-ExperimentalFeature "ExpTest.FeatureOne"
$feature | Should -Not -BeNullOrEmpty
$feature.Enabled | Should -BeTrue
$feature.Source | Should -BeExactly $testModuleManifestPath
}
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[0].Name | Should -BeExactly "ExpTest.FeatureOne"
$features[0].Enabled | Should -BeTrue
@ -105,7 +106,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
}
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[0].Name | Should -BeExactly "ExpTest.FeatureOne"
$features[0].Enabled | Should -BeTrue
@ -122,9 +123,9 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
'{"ExperimentalFeatures":["ExpTest.FeatureOne"]}' > $userConfigPath
'{"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 = 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"
}
}

View file

@ -48,14 +48,14 @@ Describe 'Tests for $ErrorView' -Tag CI {
}
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
}
It "Function shows up correctly" {
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
}

View file

@ -114,7 +114,7 @@ Describe 'Basic Job Tests' -Tags 'CI' {
It "Create job with native command" {
try {
$nativeJob = Start-job { pwsh -c 1+1 }
$nativeJob = Start-job { & "$PSHOME/pwsh" -c 1+1 }
$nativeJob | Wait-Job
$nativeJob.State | Should -BeExactly "Completed"
$nativeJob.HasMoreData | Should -BeTrue

View file

@ -180,7 +180,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
try {
$userConfig = '{ "PSModulePath": "myUserPath" }'
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;*'
}
finally {

View file

@ -277,7 +277,7 @@ Describe "Parameter Binding Tests" -Tags "CI" {
$test2File = Join-Path -Path $tempDir -ChildPath "test2.ps1"
$expected = "[$tempDir]"
$psPath = "$PSHOME\pwsh"
$pwsh = "$PSHOME\pwsh"
$null = New-Item -Path $tempDir -ItemType Directory -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" {
$result = & $psPath -NoProfile -File $test1File
$result = & $pwsh -NoProfile -File $test1File
$result | Should -Be $expected
$result = & $psPath -NoProfile -File $test2File
$result = & $pwsh -NoProfile -File $test2File
$result | Should -Be $expected
}
}