Jameswtruher/travisdailybuild (#2958)
* Stifle progress output in build.psm1 for some operations Modify test failure presentation to use platform available XML methods * 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 * Modify native linux command tests to skip on Windows and pending on Mac * remove verbose and progress output from help tests * 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 * do not run any get-computerinfo tests on non-windows systems * suppress progress output from PowerShell Get tests * 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 * Remove commented line in Import-Counter.Tests.ps1 Remove extraneous extra line in PowerShellGet.Tests.ps1 * 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 * use the existing function of SkipCounterTests rather than duplicate the logic in import-counter.tests.ps1
This commit is contained in:
parent
4eb1494442
commit
c97ca777df
12
build.psm1
12
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 = @{
|
||||
|
|
|
@ -24,18 +24,56 @@ 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
|
||||
{
|
||||
return $_.Exception.InnerException.ErrorRecord
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( $ps -ne $null ) {
|
||||
$ps.dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function position_message
|
||||
|
@ -76,7 +114,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 10
|
||||
# for runtime errors we will only get the first one
|
||||
$expectedErrors = ,$expectedErrors[0]
|
||||
$expectedOffsets = ,$expectedOffsets[0]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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' }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,18 +7,28 @@ $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")
|
||||
$SkipTests = SkipCounterTests
|
||||
|
||||
if ( ! $SkipTests )
|
||||
{
|
||||
$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 +45,12 @@ function SetScriptVars([string]$rootPath, [int]$maxSamples, [bool]$export)
|
|||
$script:tsvPath = Join-Path $rootPath "$rootFilename.tsv"
|
||||
|
||||
$script:counterSamples = $null
|
||||
if ($maxSamples)
|
||||
if ($maxSamples -and ! $SkipTests )
|
||||
{
|
||||
$script:counterSamples = Get-Counter -Counter $counterPaths -MaxSamples $maxSamples
|
||||
}
|
||||
|
||||
if ($export)
|
||||
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
|
||||
|
@ -110,7 +120,6 @@ function RunTest($testCase)
|
|||
}
|
||||
|
||||
$cmd = ConstructCommand $testCase
|
||||
Write-Host "Command to run: $cmd"
|
||||
$cmd = $cmd + " -ErrorAction SilentlyContinue -ErrorVariable errVar"
|
||||
|
||||
$errVar = $null
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -19,7 +19,7 @@ function UpdateHelpFromLocalContentPath
|
|||
}
|
||||
else
|
||||
{
|
||||
Update-Help -Module $ModuleName -Force -Verbose -ErrorAction Stop
|
||||
Update-Help -Module $ModuleName -Force -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue