From 99cf9fd85930738130d87322468905bf948d982f Mon Sep 17 00:00:00 2001 From: Ilya Date: Sun, 5 Jan 2020 13:01:42 +0500 Subject: [PATCH] Re-balance CI tests (#11420) --- .../Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 | 2 +- .../Get-WinEvent.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Management/FileSystem.Tests.ps1 | 7 +++---- test/powershell/engine/Api/Serialization.Tests.ps1 | 6 +++--- .../engine/Api/TaskBasedAsyncPowerShellAPI.Tests.ps1 | 5 +++-- test/powershell/engine/Basic/DefaultCommands.Tests.ps1 | 4 ++-- .../powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 | 3 ++- test/powershell/engine/Job/Jobs.Tests.ps1 | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 index f37b064a22..6954513716 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Job.Tests.ps1 @@ -51,7 +51,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" { } Context "jobs which take time" { BeforeEach { - $j = Start-Job -ScriptBlock { Start-Sleep -Seconds 15 } + $j = Start-Job -ScriptBlock { Start-Sleep -Seconds 8 } } AfterEach { Get-Job | Remove-Job -Force diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 index 345b3b6b92..2005365a1c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 @@ -19,7 +19,7 @@ Describe 'Get-WinEvent' -Tags "CI" { $result | Should -Not -BeNullOrEmpty } It 'Get-WinEvent can get a provider by name' { - $providers = Get-WinEvent -listprovider * -erroraction ignore + $providers = Get-WinEvent -listprovider MSI* -erroraction ignore $result = Get-WinEvent -listprovider ($providers[0].name) $result | Should -Not -BeNullOrEmpty } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 26349ad927..dc8fc2bd8d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -282,14 +282,13 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { Context "Appx path" { BeforeAll { $skipTest = $true - if ($IsWindows -and (Get-Command -Name Get-AppxPackage) -and (Get-AppxPackage Microsoft.WindowsCalculator)) { - $skipTest = $false + if ($IsWindows -and (Get-Command -Name Get-AppxPackage) ) { + $pkgDir = (Get-AppxPackage Microsoft.WindowsCalculator -ErrorAction SilentlyContinue).InstallLocation + $skipTest = $pkgDir -eq $null } } It "Can get an appx package item" -Skip:$skipTest { - $pkgDir = (Get-AppxPackage)[0].InstallLocation - Get-Item $pkgDir\Calculator.exe -ErrorAction Stop | Should -BeOfType [System.IO.FileInfo] Get-Item -Path $pkgDir -ErrorAction Stop | Should -BeOfType [System.IO.DirectoryInfo] Get-ChildItem -Path $pkgDir -ErrorAction Stop | Should -Not -BeNullOrEmpty diff --git a/test/powershell/engine/Api/Serialization.Tests.ps1 b/test/powershell/engine/Api/Serialization.Tests.ps1 index 419c7b17d5..0a5784bd7e 100644 --- a/test/powershell/engine/Api/Serialization.Tests.ps1 +++ b/test/powershell/engine/Api/Serialization.Tests.ps1 @@ -58,10 +58,10 @@ Describe "Serialization Tests" -tags "CI" { $objs1 = [byte]0, [byte]1, [byte]2, [byte]3, [byte]255 $objs2 = @() $objs3 = [byte]128 - $objs4 = @() - for($i=0;$i -lt 256;$i++) + $objs4 = [System.Byte[]]::new(256) + for($i=0; $i -lt 256; $i++) { - $objs4 += [byte]$i + $objs4[$i] = [byte]$i } $objsArray = New-Object System.Collections.ArrayList $objsArray.Add($objs1) diff --git a/test/powershell/engine/Api/TaskBasedAsyncPowerShellAPI.Tests.ps1 b/test/powershell/engine/Api/TaskBasedAsyncPowerShellAPI.Tests.ps1 index c22d994a2b..0a4fbb30d2 100644 --- a/test/powershell/engine/Api/TaskBasedAsyncPowerShellAPI.Tests.ps1 +++ b/test/powershell/engine/Api/TaskBasedAsyncPowerShellAPI.Tests.ps1 @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe 'Task-based PowerShell async APIs' -Tags 'CI' { + +Describe 'Task-based PowerShell async APIs' -Tags 'Feature' { BeforeAll { $sbStub = @' .foreach{ @@ -10,7 +11,7 @@ Describe 'Task-based PowerShell async APIs' -Tags 'CI' { ThreadId = [System.Threading.Thread]::CurrentThread.ManagedThreadId RunspaceId = [runspace]::DefaultRunspace.Id } - Start-Sleep -Milliseconds 500 + Start-Sleep -Milliseconds 250 } '@ } diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index 1467bfa338..73fd995a5b 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -124,7 +124,7 @@ Describe "Verify approved aliases list" -Tags "CI" { "Alias", "npssc", "New-PSSessionConfigurationFile", $($FullCLR ), "ReadOnly", "", "" "Alias", "nsn", "New-PSSession", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "" "Alias", "nv", "New-Variable", $($FullCLR -or $CoreWindows -or $CoreUnix), "ReadOnly", "", "" -"Alias", "nwsn", "New-PSWorkflowSession", $($FullCLR -or $CoreWindows ), "", "", "" +"Alias", "nwsn", "New-PSWorkflowSession", $($FullCLR ), "", "", "" "Alias", "ogv", "Out-GridView", $($FullCLR -or $CoreWindows ), "ReadOnly", "", "" "Alias", "oh", "Out-Host", $($FullCLR -or $CoreWindows -or $CoreUnix), "ReadOnly", "", "" "Alias", "popd", "Pop-Location", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "AllScope", "" @@ -496,7 +496,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # We control only default engine aliases (Source -eq "") and aliases from following default loaded modules # We control only default engine Cmdlets (Source -eq "") and Cmdlets from following default loaded modules - $moduleList = @("Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Management", "Microsoft.PowerShell.Security", "Microsoft.PowerShell.Host", "Microsoft.PowerShell.Diagnostics", "PSWorkflow", "Microsoft.WSMan.Management", "Microsoft.PowerShell.Core") + $moduleList = @("Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Management", "Microsoft.PowerShell.Security", "Microsoft.PowerShell.Host", "Microsoft.PowerShell.Diagnostics", "Microsoft.WSMan.Management", "Microsoft.PowerShell.Core") $getAliases = { param($moduleList) diff --git a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 index ace83809e0..2435b2cc1a 100644 --- a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe 'Online help tests for PowerShell Cmdlets' -Tags "CI" { + +Describe 'Online help tests for PowerShell Cmdlets' -Tags "Feature" { # The csv files (V2Cmdlets.csv and V3Cmdlets.csv) contain a list of cmdlets and expected HelpURIs. # The HelpURI is part of the cmdlet metadata, and when the user runs 'get-help -online' diff --git a/test/powershell/engine/Job/Jobs.Tests.ps1 b/test/powershell/engine/Job/Jobs.Tests.ps1 index 397a16ca11..395eaa94d9 100644 --- a/test/powershell/engine/Job/Jobs.Tests.ps1 +++ b/test/powershell/engine/Job/Jobs.Tests.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe 'Basic Job Tests' -Tags 'CI' { +Describe 'Basic Job Tests' -Tags 'Feature' { BeforeAll { # Make sure we do not have any jobs running Get-Job | Remove-Job -Force