mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Add a generic file watcher function in HelpersCommon.psm1 (#4775)
Add a generic file watcher function in HelpersCommon.psm1 and update some tests to use the `Wait-FileToBePresent`.
This commit is contained in:
1 parent
6a78e303ff
commit
c06ffc4a5c
7 files changed
+26
-41
No files matched your search
@@ -233,12 +233,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
|
||||
"Test timeout waiting for $cmdLine" | Set-Content -Path $errFile
|
||||
|
||||
runas.exe /trustlevel:0x20000 "$powershell -nop -c try { $cmdline -ErrorAction Stop } catch { `$_.FullyQualifiedErrorId | Out-File $errFile }; New-Item -Type File -Path $doneFile"
|
||||
|
||||
$startTime = Get-Date
|
||||
while (((Get-Date) - $startTime).TotalSeconds -lt 15 -and -not (Test-Path $doneFile))
|
||||
{
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
Wait-FileToBePresent -File $doneFile -TimeoutInSeconds 15 -IntervalInMilliseconds 100
|
||||
|
||||
$err = Get-Content $errFile
|
||||
$err | Should Be $expectedError
|
||||
|
||||
@@ -133,11 +133,9 @@ Describe "Start-Process tests requiring admin" -Tags "Feature","RequireAdminOnWi
|
||||
$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
|
||||
}
|
||||
|
||||
Wait-FileToBePresent -File "$testdrive\foo.txt" -TimeoutInSeconds 10 -IntervalInMilliseconds 100
|
||||
|
||||
"$testdrive\foo.txt" | Should Exist
|
||||
Get-Content $testdrive\foo.txt | Should BeExactly $fooFile
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user