mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
[Feature]
In CI, notepad.exe isn't starting (or starting in time) when using start-process with .txt based on file association. Since the test is validating opening files by association, fix is to create our own association that is predictable.
This commit is contained in:
@@ -1383,10 +1383,24 @@ try {
|
||||
"2" = "HypervisorEnforcedCodeIntegrity"
|
||||
}
|
||||
$observed.DeviceGuardSmartStatus | Should Be (Get-StringValuesFromValueMap -valuemap $smartStatusValues -values $deviceGuard.SmartStatus)
|
||||
[string]::Join(",", $observed.DeviceGuardRequiredSecurityProperties) | Should Be (Get-StringValuesFromValueMap -valuemap $requiredSecurityPropertiesValues -values $deviceGuard.RequiredSecurityProperties)
|
||||
if ($deviceGuard.RequiredSecurityProperties -eq $null)
|
||||
{
|
||||
$observed.DeviceGuardRequiredSecurityProperties | Should BeNullOrEmpty
|
||||
}
|
||||
else
|
||||
{
|
||||
[string]::Join(",", $observed.DeviceGuardRequiredSecurityProperties) | Should Be (Get-StringValuesFromValueMap -valuemap $requiredSecurityPropertiesValues -values $deviceGuard.RequiredSecurityProperties)
|
||||
}
|
||||
$observed.DeviceGuardAvailableSecurityProperties | Should Be $deviceGuard.AvailableSecurityProperties
|
||||
$observed.DeviceGuardSecurityServicesConfigured | Should Be $deviceGuard.SecurityServicesConfigured
|
||||
[string]::Join(",", $observed.DeviceGuardSecurityServicesRunning) | Should Be (Get-StringValuesFromValueMap -valuemap $securityServicesRunningValues -values $deviceGuard.SecurityServicesRunning)
|
||||
if ($deviceGuard.SecurityServicesRunning -eq $null)
|
||||
{
|
||||
$observed.DeviceGuardSecurityServicesRunning | Should BeNullOrEmpty
|
||||
}
|
||||
else
|
||||
{
|
||||
[string]::Join(",", $observed.DeviceGuardSecurityServicesRunning) | Should Be (Get-StringValuesFromValueMap -valuemap $securityServicesRunningValues -values $deviceGuard.SecurityServicesRunning)
|
||||
}
|
||||
$observed.DeviceGuardCodeIntegrityPolicyEnforcementStatus | Should Be $deviceGuard.CodeIntegrityPolicyEnforcementStatus
|
||||
$observed.DeviceGuardUserModeCodeIntegrityPolicyEnforcementStatus | Should Be $deviceGuard.UserModeCodeIntegrityPolicyEnforcementStatus
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "Start-Process" -Tags @("CI","SLOW") {
|
||||
Describe "Start-Process" -Tags @("Feature") {
|
||||
|
||||
BeforeAll {
|
||||
$isNanoServer = [System.Management.Automation.Platform]::IsNanoServer
|
||||
@@ -10,7 +10,7 @@ Describe "Start-Process" -Tags @("CI","SLOW") {
|
||||
$tempFile = Join-Path -Path $TestDrive -ChildPath PSTest
|
||||
$assetsFile = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath SortTest.txt
|
||||
if ($IsWindows) {
|
||||
$pingParam = "-n 2 localhost"
|
||||
$pingParam = "-n 2 localhost"
|
||||
}
|
||||
elseif ($IsLinux -Or $IsOSX) {
|
||||
$pingParam = "-c 2 localhost"
|
||||
@@ -104,15 +104,31 @@ Describe "Start-Process" -Tags @("CI","SLOW") {
|
||||
$process.Name | Should Be "notepad"
|
||||
$process | Stop-Process
|
||||
}
|
||||
}
|
||||
|
||||
It "Should open the application that associates with extension '.txt'" -Skip:(!$isFullWin) {
|
||||
$txtFile = Join-Path $TestDrive "TxtTest.txt"
|
||||
New-Item $txtFile -ItemType File -Force
|
||||
$process = Start-Process $txtFile -PassThru -WindowStyle Normal
|
||||
$process.Name | Should Not BeNullOrEmpty
|
||||
$process.Id | Should BeGreaterThan 1
|
||||
$process | Stop-Process
|
||||
Describe "Start-Process tests requiring admin" -Tags "Feature","RequireAdminOnWindows" {
|
||||
|
||||
BeforeEach {
|
||||
cmd /c assoc .foo=foofile
|
||||
cmd /c ftype foofile=cmd /c echo %1^> $testdrive\foo.txt
|
||||
Remove-Item $testdrive\foo.txt -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Remove-Item -Path $tempFile -Force
|
||||
AfterEach {
|
||||
cmd /c assoc .foo=
|
||||
cmd /c ftype foofile=
|
||||
}
|
||||
|
||||
It "Should open the application that is associated a file" -Skip:(!$isFullWin) {
|
||||
$fooFile = Join-Path $TestDrive "FooTest.foo"
|
||||
New-Item $fooFile -ItemType File -Force
|
||||
Start-Process $fooFile
|
||||
$startTime = Get-Date
|
||||
while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and (!(Test-Path $testdrive\foo.txt)))
|
||||
{
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
"$testdrive\foo.txt" | Should Exist
|
||||
Get-Content $testdrive\foo.txt | Should BeExactly $fooFile
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user