From 3ff1bea19a669967959523dd5b8f466002cd5831 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 12:23:46 -0800 Subject: [PATCH 01/11] Stifle progress output in build.psm1 for some operations Modify test failure presentation to use platform available XML methods --- build.psm1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index e1850ad8f2d..ad1580f05e4 100644 --- a/build.psm1 +++ b/build.psm1 @@ -400,6 +400,7 @@ cmd.exe /C cd /d "$location" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch if($PSModuleRestore) { + $ProgressPreference = "SilentlyContinue" # Downloading the PowerShellGet and PackageManagement modules. # $Options.Output is pointing to something like "...\src\powershell-win-core\bin\Debug\netcoreapp1.1\win10-x64\publish\powershell.exe", # so we need to get its parent directory @@ -835,7 +836,14 @@ function Test-PSPesterResults if ([int]$x.'test-results'.failures -gt 0) { logerror "TEST FAILURES" - foreach ( $testfail in $x.SelectNodes('.//test-case[@result = "Failure"]')) + # switch between methods, SelectNode is not available on dotnet core + if ( "System.Xml.XmlDocumentXPathExtensions" -as "Type" ) { + $failures = [System.Xml.XmlDocumentXPathExtensions]::SelectNodes($x."test-results",'.//test-case[@result = "Failure"]') + } + else { + $failures = $x.SelectNodes('.//test-case[@result = "Failure"]') + } + foreach ( $testfail in $failures ) { Show-PSPesterError $testfail } @@ -2813,6 +2821,8 @@ function Restore-PSModule log ("Name='{0}', Destination='{1}', Repository='{2}'" -f ($Name -join ','), $Destination, $RepositoryName) + # do not output progress + $ProgressPreference = "SilentlyContinue" $Name | ForEach-Object { $command = @{ From a63a928f2d9243c229ead595ad1ee94c62e407ff Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 12:32:30 -0800 Subject: [PATCH 02/11] Add timeout support for returning runtime parsing errors Some of the language/parser tests have been hanging in a non-reproducable manner which causes the CI system to invalidate the entire run. This change adds support for timeout which will fail a test if it runs to long, rather than invalidate the entire run. current behavior is still supported, and is not done in a new session: PS> get-runtimeerror -src '1/' At line:1 char:3 + 1/ + ~ You must provide a value expression following the '/' operator. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : ExpectedValueExpression Adding a timeout will do the operation in a async powershell session PS> get-runtimeerror -src '1/' -timeout 5 You must provide a value expression following the '/' operator. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : ExpectedValueExpression If the operation takes longer than the supplied timeout, a timeout error will be returned PS> get-runtimeerror -src 'start-sleep 6' -timeout 2 get-runtimeerror : Operation Timed Out ('start-sleep 6') At line:1 char:1 + get-runtimeerror -src 'start-sleep 6' -timeout 2 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-RuntimeError --- .../Language/LanguageTestSupport.psm1 | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/test/powershell/Language/LanguageTestSupport.psm1 b/test/powershell/Language/LanguageTestSupport.psm1 index 362615a8e86..c0dab70de6a 100644 --- a/test/powershell/Language/LanguageTestSupport.psm1 +++ b/test/powershell/Language/LanguageTestSupport.psm1 @@ -24,18 +24,57 @@ function Get-RuntimeError [CmdletBinding()] param( [Parameter(ValueFromPipeline=$True,Mandatory=$True)] - [string]$src + [string]$src, + [Parameter()] + [int]$Timeout = 0 ) - + $errors = $null try { - [scriptblock]::Create($src).Invoke() > $null + # some tests cannot be run in a isolated runspace + # easily because they require more than just a single + # execution + if ( $Timeout -eq 0 ) + { + [scriptblock]::Create($src).Invoke() > $null + } + else + { + $ps = [powershell]::Create() + $ps.AddScript($src) > $null + $ar = $ps.BeginInvoke() + # give it 250 milliseconds to complete + start-sleep -mill 250 + if ( $ar.IsCompleted ) { + $ps.EndInvoke($ar) + } + # wait another ${Timeout} seconds, then give up + else { + Start-Sleep -sec $Timeout + if ( $ar.IsCompleted ) { + # this can throw, which will be picked up below + $ps.EndInvoke($ar) + } + else { + # if it didn't throw, then return a constructed error + $ER = Write-Error "Operation Timed Out ('$src')" 2>&1 + return $ER + } + } + } } catch { + write-verbose -verbose "caught" return $_.Exception.InnerException.ErrorRecord } + finally + { + if ( $ps -ne $null ) { + $ps.dispose() + } + } } function position_message @@ -76,7 +115,7 @@ function ShouldBeParseError if ($SkipAndCheckRuntimeError) { It "error should happen at parse time, not at runtime" -Skip {} - $errors = Get-RuntimeError -Src $src + $errors = Get-RuntimeError -Src $src -Timeout 5 # for runtime errors we will only get the first one $expectedErrors = ,$expectedErrors[0] $expectedOffsets = ,$expectedOffsets[0] From ae15e5fed2a0e4ac6089eaf8af427117657acbed Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 12:44:19 -0800 Subject: [PATCH 03/11] Modify native linux command tests to skip on Windows and pending on Mac --- .../NativeLinuxCommands.Tests.ps1 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/powershell/Language/Scripting/NativeExecution/NativeLinuxCommands.Tests.ps1 b/test/powershell/Language/Scripting/NativeExecution/NativeLinuxCommands.Tests.ps1 index d7203ec277c..576dfe8aa7b 100644 --- a/test/powershell/Language/Scripting/NativeExecution/NativeLinuxCommands.Tests.ps1 +++ b/test/powershell/Language/Scripting/NativeExecution/NativeLinuxCommands.Tests.ps1 @@ -1,28 +1,37 @@ +if ( $IsWindows ) { + $PesterSkipOrPending = @{ Skip = $true } +} +elseif ( $IsOSX ) { + $PesterSkipOrPending = @{ Pending = $true } +} +else { + $PesterSkipOrPending = @{} +} Describe "NativeLinuxCommands" -tags "CI" { It "Should return a type of System.Object for hostname cmdlet" { (hostname).GetType().BaseType | Should Be 'System.Object' (hostname).GetType().Name | Should Be String } - It "Should find Application grep" -Skip:$IsWindows { + It "Should find Application grep" @PesterSkipOrPending { (get-command grep).CommandType | Should Be Application } - It "Should pipe to grep and get result" -Skip:$IsWindows { + It "Should pipe to grep and get result" @PesterSkipOrPending { "hello world" | grep hello | Should Be "hello world" } - It "Should find Application touch" -Skip:$IsWindows { + It "Should find Application touch" @PesterSkipOrPending { (get-command touch).CommandType | Should Be Application } - It "Should not redirect standard input if native command is the first command in pipeline (1)" -Skip:$IsWindows { + It "Should not redirect standard input if native command is the first command in pipeline (1)" @PesterSkipOrPending { stty | ForEach-Object -Begin { $out = @() } -Process { $out += $_ } $out.Length -gt 0 | Should Be $true $out[0] -like "speed * baud; line =*" | Should Be $true } - It "Should not redirect standard input if native command is the first command in pipeline (2)" -Skip:$IsWindows { + It "Should not redirect standard input if native command is the first command in pipeline (2)" @PesterSkipOrPending { $out = stty $out.Length -gt 0 | Should Be $true $out[0] -like "speed * baud; line =*" | Should Be $true From d495bf8246faf16a8cb8d39262efd9c85c605e06 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 13:02:50 -0800 Subject: [PATCH 04/11] remove verbose and progress output from help tests --- test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 | 8 +++++--- test/powershell/engine/Help/HelpSystem.Tests.ps1 | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 b/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 index 41d4f534ac9..988177906f6 100644 --- a/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 +++ b/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 @@ -1,4 +1,6 @@ - Describe 'get-help HelpFunc1' -Tags "Feature" { +$ProgressPreference = "SilentlyContinue" + +Describe 'get-help HelpFunc1' -Tags "Feature" { BeforeAll { function TestHelpError { [CmdletBinding()] @@ -22,7 +24,7 @@ It '$x.relatedLinks.navigationLink[0].uri' { $x.relatedLinks.navigationLink[0].uri | Should Be "http://blogs.msdn.com/powershell" } It '$x.relatedLinks.navigationLink[1].linkText' { $x.relatedLinks.navigationLink[1].linkText | Should Be "other commands" } It '$x.examples.example.code' { $x.examples.example.code | Should Be "If you need an example, you're hopeless." } - It '$x.inputTypes.inputType.type.name‘ { $x.inputTypes.inputType.type.name | Should Be "Anything you like." } + It '$x.inputTypes.inputType.type.name' { $x.inputTypes.inputType.type.name | Should Be "Anything you like." } It '$x.returnValues.returnValue.type.name' { $x.returnValues.returnValue.type.name | Should Be "Nothing." } It '$x.Component' { $x.Component | Should Be "Something" } It '$x.Role' { $x.Role | Should Be "CrazyUser" } @@ -555,4 +557,4 @@ Describe 'get-help other tests' -Tags "CI" { It '$x.Parameters.parameter[1].defaultValue' { $x.Parameters.parameter[1].defaultValue | Should Be '42' } It '$x.Parameters.parameter[2].defaultValue' { $x.Parameters.parameter[2].defaultValue | Should Be 'parameter is mandatory' } } -} \ No newline at end of file +} diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index 81c7d1cd344..cbf446a61aa 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -19,7 +19,7 @@ function UpdateHelpFromLocalContentPath } else { - Update-Help -Module $ModuleName -Force -Verbose -ErrorAction Stop + Update-Help -Module $ModuleName -Force -ErrorAction Stop } } From 1f26d3bf73d8d2d3a8dec5663062de20d1fcf806 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 13:08:10 -0800 Subject: [PATCH 05/11] Be sure that Feature Counter tests only run on Windows Also, only call add-type in CounterTestHelperFunctions.ps1 if we're going to actually run the tests --- .../CounterTestHelperFunctions.ps1 | 12 ++++-- .../Import-Counter.Tests.ps1 | 38 +++++++++++-------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 index ebada43569a..ac759d3f894 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 @@ -142,7 +142,10 @@ using System.Text; } "@ -Add-Type -TypeDefinition $helperSource +if ( $IsWindows ) +{ + Add-Type -TypeDefinition $helperSource +} # Strip off machine name, if present, from counter path function RemoveMachineName @@ -167,8 +170,11 @@ function RemoveMachineName # Retrieve the counters array from the Registry function GetCounters { - $key = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\CurrentLanguage' - return (Get-ItemProperty -Path $key -Name Counter).Counter + if ( $IsWindows ) + { + $key = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\CurrentLanguage' + return (Get-ItemProperty -Path $key -Name Counter).Counter + } } # Translate a counter name from English to a localized counter name diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 index b16efe98aaa..51dc23b93a8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 @@ -7,18 +7,26 @@ $cmdletName = "Import-Counter" . "$PSScriptRoot/CounterTestHelperFunctions.ps1" -$counterPaths = @( - (TranslateCounterPath "\Memory\Available Bytes") - (TranslateCounterPath "\processor(*)\% Processor time") - (TranslateCounterPath "\Processor(_Total)\% Processor Time") - (TranslateCounterPath "\PhysicalDisk(_Total)\Current Disk Queue Length") - (TranslateCounterPath "\PhysicalDisk(_Total)\Disk Bytes/sec") - (TranslateCounterPath "\PhysicalDisk(_Total)\Disk Read Bytes/sec") -) -$setNames = @{ - Memory = (TranslateCounterName "memory") - PhysicalDisk = (TranslateCounterName "physicaldisk") - Processor = (TranslateCounterName "processor") +if ( $IsWindows ) +{ + $counterPaths = @( + (TranslateCounterPath "\Memory\Available Bytes") + (TranslateCounterPath "\processor(*)\% Processor time") + (TranslateCounterPath "\Processor(_Total)\% Processor Time") + (TranslateCounterPath "\PhysicalDisk(_Total)\Current Disk Queue Length") + (TranslateCounterPath "\PhysicalDisk(_Total)\Disk Bytes/sec") + (TranslateCounterPath "\PhysicalDisk(_Total)\Disk Read Bytes/sec") + ) + $setNames = @{ + Memory = (TranslateCounterName "memory") + PhysicalDisk = (TranslateCounterName "physicaldisk") + Processor = (TranslateCounterName "processor") + } +} +else +{ + $counterPaths = @() + $setNames = @{} } $badSamplesBlgPath = Join-Path $PSScriptRoot "assets" "BadCounterSamples.blg" @@ -35,12 +43,12 @@ function SetScriptVars([string]$rootPath, [int]$maxSamples, [bool]$export) $script:tsvPath = Join-Path $rootPath "$rootFilename.tsv" $script:counterSamples = $null - if ($maxSamples) + if ($maxSamples -and $IsWindows) { $script:counterSamples = Get-Counter -Counter $counterPaths -MaxSamples $maxSamples } - if ($export) + if ($export -and $IsWindows) { Export-Counter -Force -FileFormat "blg" -Path $script:blgPath -InputObject $script:counterSamples Export-Counter -Force -FileFormat "csv" -Path $script:csvPath -InputObject $script:counterSamples @@ -110,7 +118,7 @@ function RunTest($testCase) } $cmd = ConstructCommand $testCase - Write-Host "Command to run: $cmd" + # Write-Host "Command to run: $cmd" $cmd = $cmd + " -ErrorAction SilentlyContinue -ErrorVariable errVar" $errVar = $null From 53d3e8e45c5a56ff90e5c4d6c2baad329a0f1f37 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 13:10:56 -0800 Subject: [PATCH 06/11] do not run any get-computerinfo tests on non-windows systems --- .../Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 index 43851212974..333f7ce43a4 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 @@ -1318,7 +1318,7 @@ try { } - It "(special case) Test for property = OsFreeSpaceInPagingFiles" -Skip:([System.Management.Automation.Platform]::IsIoT) { + It "(special case) Test for property = OsFreeSpaceInPagingFiles" -Skip:([System.Management.Automation.Platform]::IsIoT -or !$IsWindows) { ($observed.OsFreeSpaceInPagingFiles -gt 0) | Should Be $true } From 4be7f19bcbd311baa3bff17573cb89c6fc98efff Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 13:15:07 -0800 Subject: [PATCH 07/11] suppress progress output from PowerShell Get tests --- .../Modules/PowerShellGet/PowerShellGet.Tests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 index 0ce39093d88..acdf4370608 100644 --- a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 +++ b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 @@ -1,4 +1,7 @@ -$RepositoryName = 'INTGallery' +# no progress output during these tests +$ProgressPreference = "SilentlyContinue" + +$RepositoryName = 'INTGallery' $SourceLocation = 'https://dtlgalleryint.cloudapp.net' $RegisteredINTRepo = $false $ContosoServer = 'ContosoServer' @@ -90,6 +93,7 @@ function Remove-InstalledModules Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | Uninstall-Module -Force } + Describe "PowerShellGet - Module tests" -tags "Feature" { BeforeEach { From 750ba2138883e8d95f3b0b723e669f54b53a0998 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 13:17:23 -0800 Subject: [PATCH 08/11] remove -quiet from API and CRON Builds Travis watches output from the build to ensure that it hasn't hung we need to find a balance between too much output and not enough output. A run which has too much output is killed because it looks like an error loop A run which has too little output is killed because it looks like a hang --- tools/travis.ps1 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 577ea191263..ba5a9c67889 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -17,13 +17,6 @@ $pesterParam = @{ 'binDir' = $output } if ($isFullBuild) { $pesterParam['Tag'] = @('CI','Feature','Scenario') $pesterParam['ExcludeTag'] = @() - # cron jobs create log files which include the stdout of Pester - # which creates too much data for travis to put in the log file - # and the job is then cancelled. Add Quiet to reduce the log size - # the xunit log created by pester is what is important - if ( $env:TRAVIS_EVENT_TYPE -eq 'cron' ) { - $pesterParam['Quiet'] = $true - } } else { $pesterParam['Tag'] = @('CI') $pesterParam['ThrowOnFailure'] = $true From da6f88fe6b68e9c162c4406d0e9f55dfe853099b Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Thu, 5 Jan 2017 15:29:54 -0800 Subject: [PATCH 09/11] Remove commented line in Import-Counter.Tests.ps1 Remove extraneous extra line in PowerShellGet.Tests.ps1 --- .../Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 | 1 - test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 | 1 - 2 files changed, 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 index 51dc23b93a8..a88fde212f9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 @@ -118,7 +118,6 @@ function RunTest($testCase) } $cmd = ConstructCommand $testCase - # Write-Host "Command to run: $cmd" $cmd = $cmd + " -ErrorAction SilentlyContinue -ErrorVariable errVar" $errVar = $null diff --git a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 index acdf4370608..066838c93fe 100644 --- a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 +++ b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 @@ -93,7 +93,6 @@ function Remove-InstalledModules Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | Uninstall-Module -Force } - Describe "PowerShellGet - Module tests" -tags "Feature" { BeforeEach { From 99112fdab470cee47c05c866dee896ddd6894cb2 Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Fri, 6 Jan 2017 10:05:37 -0800 Subject: [PATCH 10/11] Change `-as "type"` to `-as [type]` in build.psm1 Alter timeout to 10 seconds to be improve chances of not timing out for runtime parser checks improve logic for counter tests to also skip for IoT --- build.psm1 | 2 +- .../powershell/Language/LanguageTestSupport.psm1 | 3 +-- .../CounterTestHelperFunctions.ps1 | 3 ++- .../Import-Counter.Tests.ps1 | 16 +++++++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/build.psm1 b/build.psm1 index ad1580f05e4..9d64e9aa434 100644 --- a/build.psm1 +++ b/build.psm1 @@ -837,7 +837,7 @@ function Test-PSPesterResults { logerror "TEST FAILURES" # switch between methods, SelectNode is not available on dotnet core - if ( "System.Xml.XmlDocumentXPathExtensions" -as "Type" ) { + if ( "System.Xml.XmlDocumentXPathExtensions" -as [Type] ) { $failures = [System.Xml.XmlDocumentXPathExtensions]::SelectNodes($x."test-results",'.//test-case[@result = "Failure"]') } else { diff --git a/test/powershell/Language/LanguageTestSupport.psm1 b/test/powershell/Language/LanguageTestSupport.psm1 index c0dab70de6a..d4b4ef0cb7e 100644 --- a/test/powershell/Language/LanguageTestSupport.psm1 +++ b/test/powershell/Language/LanguageTestSupport.psm1 @@ -66,7 +66,6 @@ function Get-RuntimeError } catch { - write-verbose -verbose "caught" return $_.Exception.InnerException.ErrorRecord } finally @@ -115,7 +114,7 @@ function ShouldBeParseError if ($SkipAndCheckRuntimeError) { It "error should happen at parse time, not at runtime" -Skip {} - $errors = Get-RuntimeError -Src $src -Timeout 5 + $errors = Get-RuntimeError -Src $src -Timeout 10 # for runtime errors we will only get the first one $expectedErrors = ,$expectedErrors[0] $expectedOffsets = ,$expectedOffsets[0] diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 index ac759d3f894..5e21c426034 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/CounterTestHelperFunctions.ps1 @@ -288,7 +288,8 @@ function CompareCounterSets function SkipCounterTests { if ([System.Management.Automation.Platform]::IsLinux -or - [System.Management.Automation.Platform]::IsOSX) + [System.Management.Automation.Platform]::IsOSX -or + [System.Management.Automation.Platform]::IsIoT) { return $true } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 index a88fde212f9..e1f9839edf4 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 @@ -7,7 +7,17 @@ $cmdletName = "Import-Counter" . "$PSScriptRoot/CounterTestHelperFunctions.ps1" -if ( $IsWindows ) +if ( $IsWindows -and ! [System.Management.Automation.Platform]::IsIoT ) +{ + $ShouldRun = $true +} +else +{ + # don't run on IoT, Linux, or Mac + $ShouldRun = $false +} + +if ( $ShouldRun ) { $counterPaths = @( (TranslateCounterPath "\Memory\Available Bytes") @@ -43,12 +53,12 @@ function SetScriptVars([string]$rootPath, [int]$maxSamples, [bool]$export) $script:tsvPath = Join-Path $rootPath "$rootFilename.tsv" $script:counterSamples = $null - if ($maxSamples -and $IsWindows) + if ($maxSamples -and $ShouldRun) { $script:counterSamples = Get-Counter -Counter $counterPaths -MaxSamples $maxSamples } - if ($export -and $IsWindows) + if ($export -and $ShouldRun) { Export-Counter -Force -FileFormat "blg" -Path $script:blgPath -InputObject $script:counterSamples Export-Counter -Force -FileFormat "csv" -Path $script:csvPath -InputObject $script:counterSamples From 218415abe28c9fa90de1608884ae22ee745760ac Mon Sep 17 00:00:00 2001 From: JamesWTruher Date: Sun, 8 Jan 2017 14:29:58 -0800 Subject: [PATCH 11/11] use the existing function of SkipCounterTests rather than duplicate the logic in import-counter.tests.ps1 --- .../Import-Counter.Tests.ps1 | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 index e1f9839edf4..16ac07a85b6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Import-Counter.Tests.ps1 @@ -7,17 +7,9 @@ $cmdletName = "Import-Counter" . "$PSScriptRoot/CounterTestHelperFunctions.ps1" -if ( $IsWindows -and ! [System.Management.Automation.Platform]::IsIoT ) -{ - $ShouldRun = $true -} -else -{ - # don't run on IoT, Linux, or Mac - $ShouldRun = $false -} +$SkipTests = SkipCounterTests -if ( $ShouldRun ) +if ( ! $SkipTests ) { $counterPaths = @( (TranslateCounterPath "\Memory\Available Bytes") @@ -53,12 +45,12 @@ function SetScriptVars([string]$rootPath, [int]$maxSamples, [bool]$export) $script:tsvPath = Join-Path $rootPath "$rootFilename.tsv" $script:counterSamples = $null - if ($maxSamples -and $ShouldRun) + if ($maxSamples -and ! $SkipTests ) { $script:counterSamples = Get-Counter -Counter $counterPaths -MaxSamples $maxSamples } - if ($export -and $ShouldRun) + if ($export -and ! $SkipTests ) { Export-Counter -Force -FileFormat "blg" -Path $script:blgPath -InputObject $script:counterSamples Export-Counter -Force -FileFormat "csv" -Path $script:csvPath -InputObject $script:counterSamples