From 6126624b6325da265da8a25a27f22e3a0974e341 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 15 Jan 2019 00:31:52 -0700 Subject: [PATCH] Revise use of Start-Sleep cmdlet (#8633) * Avoid use of sleep alias (follow-up to #8546) * Specify default parameter name * Shorten overly specific comments --- test/docker/networktest/DockerRemoting.Tests.ps1 | 4 ++-- .../Language/Classes/Scripting.Classes.Attributes.Tests.ps1 | 2 +- .../Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 | 2 +- .../Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 | 4 ++-- test/tools/Modules/HelpersCommon/HelpersCommon.psm1 | 2 +- test/tools/Modules/HttpListener/HttpListener.psm1 | 2 +- test/tools/Modules/PSSysLog/PSSysLog.psm1 | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/docker/networktest/DockerRemoting.Tests.ps1 b/test/docker/networktest/DockerRemoting.Tests.ps1 index f624e3e413..55fd159e6d 100644 --- a/test/docker/networktest/DockerRemoting.Tests.ps1 +++ b/test/docker/networktest/DockerRemoting.Tests.ps1 @@ -16,9 +16,9 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){ # give the containers something to do, otherwise they will exit and be removed Write-Verbose -verbose "setting up docker container PowerShell server" - $server = docker run -d $imageName powershell -c start-sleep $timeout + $server = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout Write-Verbose -verbose "setting up docker container PowerShell client" - $client = docker run -d $imageName powershell -c start-sleep $timeout + $client = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout # get fullpath to installed core powershell Write-Verbose -verbose "Getting path to PowerShell core" diff --git a/test/powershell/Language/Classes/Scripting.Classes.Attributes.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.Attributes.Tests.ps1 index c6a20f91d2..e0ba18ae26 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.Attributes.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.Attributes.Tests.ps1 @@ -470,7 +470,7 @@ Describe 'ValidateSet support a dynamically generated set' -Tag "CI" { It 'Can implement CachedValidValuesGeneratorBase with cache expiration in PowerShell' { Get-TestValidateSetPS5 -Param1 "TestString1" -ErrorAction SilentlyContinue | Should -BeExactly "TestString1" Get-TestValidateSetPS5 -Param1 "TestString1" -ErrorAction SilentlyContinue | Should -BeExactly "TestString1" - Start-Sleep 3 + Start-Sleep -Seconds 3 Get-TestValidateSetPS5 -Param1 "TestString2" -ErrorAction SilentlyContinue | Should -BeExactly "TestString2" } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 index 0ff88d6fc8..812974cd21 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 @@ -44,7 +44,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" { } Context "jobs which take time" { BeforeEach { - $j = Start-Job -ScriptBlock { Start-Sleep 15 } + $j = Start-Job -ScriptBlock { Start-Sleep -Seconds 15 } } AfterEach { Get-Job | Remove-Job -Force @@ -93,7 +93,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" { throw "Receive-Job behaves suspiciously: Cannot receive $n results in 5 minutes." } - # sleep for 300 ms to allow data to be produced + # Wait to allow data to be produced Start-Sleep -Milliseconds 300 if ($keep) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 index a6c1d7f8c3..8821f2e4ef 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 @@ -1947,7 +1947,7 @@ try Disconnect-PSSession $session Start-Process powershell -arg 'Get-PSSession -cn localhost -name Session102 | Connect-PSSession' -Wait - Start-Sleep 3 + Start-Sleep -Seconds 3 ## This time a new session is created because the old one is unavailable. $dSessionPid = Get-RemoteVariable pid diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 index 2882d88f88..20107efc4e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 @@ -56,11 +56,11 @@ Describe "XmlCommand DRT basic functionality Tests" -Tags "CI" { $ps = [PowerShell]::Create() $null = $ps.AddScript("1..10") $null = $ps.AddCommand("foreach-object") - $null = $ps.AddParameter("Process", { $_; start-sleep 1 }) + $null = $ps.AddParameter("Process", { $_; Start-Sleep -Seconds 1 }) $null = $ps.AddCommand("Export-CliXml") $null = $ps.AddParameter("Path", $testfile) $null = $ps.BeginInvoke() - Start-Sleep 1 + Start-Sleep -Seconds 1 $null = $ps.Stop() $ps.InvocationStateInfo.State | Should -Be "Stopped" $ps.Dispose() diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index f3ca73a1fe..9879d32a24 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -17,7 +17,7 @@ function Wait-UntilTrue if (([DateTime]::Now - $startTime).TotalMilliseconds -gt $timeoutInMilliseconds) { return $false } - # Sleep for the specified interval + # Wait Start-Sleep -Milliseconds $intervalInMilliseconds } return $true diff --git a/test/tools/Modules/HttpListener/HttpListener.psm1 b/test/tools/Modules/HttpListener/HttpListener.psm1 index e3747d4369..3c8dc4bb32 100644 --- a/test/tools/Modules/HttpListener/HttpListener.psm1 +++ b/test/tools/Modules/HttpListener/HttpListener.psm1 @@ -357,7 +357,7 @@ Function Start-HTTPListener { { # ignore if listener is not ready } - Start-Sleep -milliseconds 100 + Start-Sleep -Milliseconds 100 } if (!$succeeded) { diff --git a/test/tools/Modules/PSSysLog/PSSysLog.psm1 b/test/tools/Modules/PSSysLog/PSSysLog.psm1 index b667534a01..ba4b88a5ac 100644 --- a/test/tools/Modules/PSSysLog/PSSysLog.psm1 +++ b/test/tools/Modules/PSSysLog/PSSysLog.psm1 @@ -938,7 +938,7 @@ function Wait-UntilSuccess } } - # Sleep for the specified interval + # Wait Start-Sleep -Milliseconds $intervalInMilliseconds } return $true @@ -1073,7 +1073,7 @@ function Wait-PSWinEvent     do     { -        sleep $pause +        Start-Sleep -Seconds $pause $recordsToReturn = @()