Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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"
Copy link
Copy Markdown
Member

@adityapatwardhan adityapatwardhan Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to reset this back to previous setting when we complete the script? #ByDesign

Copy link
Copy Markdown
Collaborator Author

@JamesWTruher JamesWTruher Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope - test tests are executed in a new scope, so it gets set back when the script exits #Closed

$Name | ForEach-Object {

$command = @{
Expand Down
46 changes: 42 additions & 4 deletions test/powershell/Language/LanguageTestSupport.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Collaborator

@iSazonov iSazonov Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser tests is very fast (some ms). This change will slow them down in many times.
And how will it help us to find the root of the problem? Travis already has a global monitoring of a job duration and automatically kills a hung job. Maybe we ask them to take a dump in this moment? #WontFix

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will slow down some tests, but I reckoned that it was better to slow down the test than to invalidate an entire run - that's what I'm trying to avoid. When running a full test pass I saw nearly 100% test runs killed for lack of activity. Each one of those runs were hung in the language tests.


In reply to: 94967709 [](ancestors = 94967709)

Copy link
Copy Markdown
Collaborator

@iSazonov iSazonov Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned that we conceal the problem. Is there a way to reproduce this problem except to get a hung accidentally? I believe that we in the allowed time could identify the problem and fix it by analyzing a dump without slow down tests. #WontFix

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while I agree that we need to determine root cause, i disagree about where. Catching this in CI has been extremely difficult and collecting dumps in Travis is really something I would rather avoid (if it's even possible).
we need to track down this issue, but I don't believe CI is the appropriate place


In reply to: 94993680 [](ancestors = 94993680)

Copy link
Copy Markdown
Member

@TravisEz13 TravisEz13 Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be an issue that needs investigation. Please open an issue for this. #Resolved

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an issue has already been created for the hanging behavior. #2748


In reply to: 95024875 [](ancestors = 95024875)

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
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions test/powershell/Language/Scripting/ScriptHelp.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
 Describe 'get-help HelpFunc1' -Tags "Feature" {
$ProgressPreference = "SilentlyContinue"

Describe 'get-help HelpFunc1' -Tags "Feature" {
BeforeAll {
function TestHelpError {
[CmdletBinding()]
Expand All @@ -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" }
Expand Down Expand Up @@ -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' }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -282,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -110,7 +120,6 @@ function RunTest($testCase)
}

$cmd = ConstructCommand $testCase
Write-Host "Command to run: $cmd"
$cmd = $cmd + " -ErrorAction SilentlyContinue -ErrorVariable errVar"

$errVar = $null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/engine/Help/HelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function UpdateHelpFromLocalContentPath
}
else
{
Update-Help -Module $ModuleName -Force -Verbose -ErrorAction Stop
Update-Help -Module $ModuleName -Force -ErrorAction Stop
}
}

Expand Down
7 changes: 0 additions & 7 deletions tools/travis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down