mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Add CI definition for VSTS for macOS - Add VSTS YAML for mac - Add a function to upload log files during a test on VSTS
45 lines
1.5 KiB
PowerShell
45 lines
1.5 KiB
PowerShell
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
Describe "Start-Sleep DRT Unit Tests" -Tags "CI" {
|
|
|
|
# WaitHandle.WaitOne(milliseconds, exitContext) is not accurate.
|
|
# The wait time varies from 980ms to 1150ms from observation, so
|
|
# the tests here are changed to be greater than 950ms.
|
|
$minTime = 950
|
|
$maxTime = 1200
|
|
|
|
It "Should work properly when sleeping with Second" {
|
|
$watch = [System.Diagnostics.Stopwatch]::StartNew()
|
|
Start-Sleep -Seconds 1
|
|
$watch.Stop()
|
|
$watch.ElapsedMilliseconds | Should -BeGreaterThan $minTime
|
|
$watch.ElapsedMilliseconds | Should -BeLessThan $maxTime
|
|
}
|
|
|
|
It "Should work properly when sleeping with Milliseconds" {
|
|
$watch = [System.Diagnostics.Stopwatch]::StartNew()
|
|
Start-Sleep -Milliseconds 1000
|
|
$watch.Stop()
|
|
$watch.ElapsedMilliseconds | Should -BeGreaterThan $minTime
|
|
$watch.ElapsedMilliseconds | Should -BeLessThan $maxTime
|
|
}
|
|
|
|
It "Should work properly when sleeping with ms alias" {
|
|
$watch = [System.Diagnostics.Stopwatch]::StartNew()
|
|
Start-Sleep -ms 1000
|
|
$watch.Stop()
|
|
$watch.ElapsedMilliseconds | Should -BeGreaterThan $minTime
|
|
$watch.ElapsedMilliseconds | Should -BeLessThan $maxTime
|
|
}
|
|
}
|
|
|
|
Describe "Start-Sleep" -Tags "CI" {
|
|
|
|
Context "Validate Start-Sleep works properly" {
|
|
It "Should only sleep for at least 1 second" {
|
|
$result = Measure-Command { Start-Sleep -s 1 }
|
|
$result.TotalSeconds | Should -BeGreaterThan 0.25
|
|
}
|
|
}
|
|
}
|