Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,12 @@ Categories=Application;
# Validate on Linux by reassociating default app for text file
& $TestFile
# It may take time for handler to start
Wait-FileToBePresent -File "$HOME/nativeCommandProcessor.Success" -TimeoutInSeconds 10 -IntervalInMilliseconds 100
Wait-FileToBePresent -File "$HOME/nativeCommandProcessor.Success" -TimeoutInSeconds 10 -IntervalInMilliseconds 100 | Should -BeTrue
Get-Content $HOME/nativeCommandProcessor.Success | Should -BeExactly $TestFile
}
else {
& $TestFile
Wait-FileToBePresent -File $TestDrive\foo.txt -TimeoutInSeconds 10 -IntervalInMilliseconds 100
"$TestDrive\foo.txt" | Should -Exist
Wait-FileToBePresent -File $TestDrive\foo.txt -TimeoutInSeconds 10 -IntervalInMilliseconds 100 | Should -BeTrue
Get-Content $TestDrive\foo.txt | Should -BeExactly $TestFile
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
}

It "Can enter, exit, and re-enter another PSHost" {
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $pwshId) }
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $pwshId) } | Should -BeTrue

# This will enter and exit another process
Invoke-PSHostProcessScript -ArgumentString "-Id $pwshId" -Id $pwshId |
Expand All @@ -109,7 +109,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
$powershellId = Wait-JobPid $powershellJob

try {
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $powershellId) }
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $powershellId) } | Should -BeTrue

# This will enter and exit another process
Invoke-PSHostProcessScript -ArgumentString "-Id $powershellId" -Id $powershellId |
Expand All @@ -126,7 +126,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {

It "Can enter using NamedPipeConnectionInfo" {
try {
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $pwshId) }
Wait-UntilTrue { [bool](Get-PSHostProcessInfo -Id $pwshId) } | Should -BeTrue

$npInfo = [System.Management.Automation.Runspaces.NamedPipeConnectionInfo]::new($pwshId)
$rs = [runspacefactory]::CreateRunspace($npInfo)
Expand Down Expand Up @@ -159,7 +159,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
$pwshId = Wait-JobPid $pwshJob

try {
Wait-UntilTrue { Test-Path $pipePath }
Wait-UntilTrue { Test-Path $pipePath } | Should -BeTrue

# This will enter and exit another process
Invoke-PSHostProcessScript -ArgumentString "-CustomPipeName $pipeName" -Id $pwshId |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Describe "Get-PSHostProcessInfo tests" -Tag CI {
# Creation of the named pipe is async
Wait-UntilTrue {
Get-PSHostProcessInfo | Where-Object { $_.ProcessId -eq $pwsh.Id }
}
} | Should -BeTrue
$pshosts = Get-PSHostProcessInfo
$pshosts.Count | Should -BeGreaterOrEqual 1
$pshosts.ProcessId | Should -Contain $pwsh.Id
Expand All @@ -43,7 +43,7 @@ Describe "Get-PSHostProcessInfo tests" -Tag CI {
# Creation of the named pipe is async
Wait-UntilTrue {
Get-PSHostProcessInfo | Where-Object { $_.ProcessId -eq $powershell.Id }
}
} | Should -BeTrue
$psProcess = Get-PSHostProcessInfo | Where-Object { $_.ProcessName -eq "powershell" }
$psProcess.Count | Should -BeGreaterOrEqual 1
$psProcess.ProcessId | Should -Contain $powershell.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ Describe "Remove-Item UnAuthorized Access" -Tags "CI", "RequireAdminOnWindows" {
Set-Acl $protectedPath $acl

runas.exe /trustlevel:0x20000 "$cmdline"
Wait-FileToBePresent -File $errorFile -TimeoutInSeconds 10
Wait-FileToBePresent -File $errorFile -TimeoutInSeconds 10 | Should -BeTrue
Get-Content $errorFile | Should -BeExactly 'RemoveItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RemoveItemCommand'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" {
$process.Length | Should -Be 1
$process.Id | Should -BeGreaterThan 1
}

It "Should run without errors when -ArgumentList is @()" {
$process = Start-Process $pingCommand -ArgumentList @() -PassThru @extraArgs
$process.Length | Should -Be 1
Expand Down Expand Up @@ -165,9 +165,7 @@ Describe "Start-Process tests requiring admin" -Tags "Feature","RequireAdminOnWi
New-Item $fooFile -ItemType File -Force
Start-Process $fooFile

Wait-FileToBePresent -File "$testdrive\foo.txt" -TimeoutInSeconds 10 -IntervalInMilliseconds 100

"$testdrive\foo.txt" | Should -Exist
Wait-FileToBePresent -File "$testdrive\foo.txt" -TimeoutInSeconds 10 -IntervalInMilliseconds 100 | Should -BeTrue
Get-Content $testdrive\foo.txt | Should -BeExactly $fooFile
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Describe 'ConvertTo-Json' -tags "CI" {
$jsonFormat | Should -Match '"TestValue3": 99999'
}

It "StopProcessing should succeed" {
It "StopProcessing should succeed" -Pending:$true {
$ps = [PowerShell]::Create()
$null = $ps.AddScript({
$obj = [PSCustomObject]@{P1 = ''; P2 = ''; P3 = ''; P4 = ''; P5 = ''; P6 = ''}
Expand All @@ -32,7 +32,7 @@ Describe 'ConvertTo-Json' -tags "CI" {
})
$null = $ps.BeginInvoke()
# wait for verbose message from ConvertTo-Json to ensure cmdlet is processing
Wait-UntilTrue { $ps.Streams.Verbose.Count -gt 0 }
Wait-UntilTrue { $ps.Streams.Verbose.Count -gt 0 } | Should -BeTrue
$null = $ps.BeginStop($null, $null)
# wait a bit to ensure state has changed, not using synchronous Stop() to avoid blocking Pester
Start-Sleep -Milliseconds 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Categories=Application;
$before = $windows.Count
Invoke-Item -Path ~
# may take time for explorer to open window
Wait-UntilTrue -sb { $windows.Count -gt $before } -TimeoutInMilliseconds (10*1000) -IntervalInMilliseconds 100 > $null
Wait-UntilTrue -sb { $windows.Count -gt $before } -TimeoutInMilliseconds (10*1000) -IntervalInMilliseconds 100 | Should -BeTrue
$after = $windows.Count

$before + 1 | Should -Be $after
Expand All @@ -234,7 +234,7 @@ Categories=Application;
# validate on Unix by reassociating default app for directories
Invoke-Item -Path $PSHOME
# may take time for handler to start
Wait-FileToBePresent -File "$HOME/InvokeItemTest.Success" -TimeoutInSeconds 10 -IntervalInMilliseconds 100
Wait-FileToBePresent -File "$HOME/InvokeItemTest.Success" -TimeoutInSeconds 10 -IntervalInMilliseconds 100 | Should -BeTrue
Get-Content $HOME/InvokeItemTest.Success | Should -Be $PSHOME
}
else
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/engine/Api/BasicEngine.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ write-host should_not_stop_responding_at_exit
exit
'@
$process = Start-Process pwsh -ArgumentList $command -PassThru
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 1000 > $null
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 1000 | Should -BeTrue

$expect = "powershell process exits in 5 seconds"
if (-not $process.HasExited) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ try {
$ps = [powershell]::Create()
try {
$ir = $ps.AddScript("Start-Sleep -Seconds 60").InvokeAsync()
Wait-UntilTrue { $ps.InvocationStateInfo.State -eq [System.Management.Automation.PSInvocationState]::Running }
Wait-UntilTrue { $ps.InvocationStateInfo.State -eq [System.Management.Automation.PSInvocationState]::Running } | Should -BeTrue
$sr = $ps.StopAsync($null, $null)
[System.Threading.Tasks.Task]::WaitAll(@($sr))
$sr.IsCompletedSuccessfully | Should -Be $true
Expand Down
4 changes: 2 additions & 2 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Wait-UntilTrue
return $false
}
# Wait
Start-Sleep -Milliseconds $intervalInMilliseconds
Start-Sleep -Milliseconds $intervalInMilliseconds > $null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed, but won't hurt anything

}
return $true
}
Expand All @@ -32,7 +32,7 @@ function Wait-FileToBePresent
[int]$IntervalInMilliseconds = 100
)

Wait-UntilTrue -sb { Test-Path $File } -TimeoutInMilliseconds ($TimeoutInSeconds*1000) -IntervalInMilliseconds $IntervalInMilliseconds > $null
return Wait-UntilTrue -sb { Test-Path $File } -TimeoutInMilliseconds ($TimeoutInSeconds*1000) -IntervalInMilliseconds $IntervalInMilliseconds
}

function Test-IsElevated
Expand Down