Update travis-ci script so that PRs can fail due to pester tests (#4830)
* Add a switch to force tests to fail for testing CI system to Start-PSPester * [includeFailingTest] Add commit tag to force tests to fail for testing CI system
This commit is contained in:
parent
5fedd9c54f
commit
ea7c2bddbe
13
build.psm1
13
build.psm1
|
@ -843,9 +843,15 @@ function Start-PSPester {
|
|||
[switch]$Unelevate,
|
||||
[switch]$Quiet,
|
||||
[Parameter(ParameterSetName='PassThru',Mandatory=$true)]
|
||||
[switch]$PassThru
|
||||
[switch]$PassThru,
|
||||
[switch]$IncludeFailingTest
|
||||
)
|
||||
|
||||
if ($IncludeFailingTest.IsPresent)
|
||||
{
|
||||
$Path += "$PSScriptRoot/tools/failingTests"
|
||||
}
|
||||
|
||||
# we need to do few checks and if user didn't provide $ExcludeTag explicitly, we should alternate the default
|
||||
if ($Unelevate)
|
||||
{
|
||||
|
@ -1079,14 +1085,17 @@ function Test-PSPesterResults
|
|||
{
|
||||
if ($ResultObject.TotalCount -le 0)
|
||||
{
|
||||
logerror 'NO TESTS RUN'
|
||||
throw 'NO TESTS RUN'
|
||||
}
|
||||
elseif ($ResultObject.FailedCount -gt 0)
|
||||
{
|
||||
logerror 'TEST FAILURES'
|
||||
|
||||
$ResultObject.TestResult | Where-Object {$_.Passed -eq $false} | ForEach-Object {
|
||||
Show-PSPesterError -testFailureObject $_
|
||||
}
|
||||
|
||||
throw "$($ResultObject.FailedCount) tests in $TestArea failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
5
tools/failingTests/fail.tests.ps1
Normal file
5
tools/failingTests/fail.tests.ps1
Normal file
|
@ -0,0 +1,5 @@
|
|||
Describe "Failing test used to test CI Scripts" -Tags 'CI' {
|
||||
It "Should fail" {
|
||||
1 | should be 2
|
||||
}
|
||||
}
|
|
@ -114,6 +114,7 @@ else
|
|||
|
||||
# Run a full build if the build was trigger via cron, api or the commit message contains `[Feature]`
|
||||
$hasFeatureTag = $commitMessage -match '\[feature\]'
|
||||
$hasRunFailingTestTag = $commitMessage -match '\[includeFailingTest\]'
|
||||
$isDailyBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq 'api'
|
||||
# only update the build badge for the cron job
|
||||
$cronBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron'
|
||||
|
@ -167,6 +168,11 @@ else
|
|||
$pesterParam['ThrowOnFailure'] = $true
|
||||
}
|
||||
|
||||
if ($hasRunFailingTestTag)
|
||||
{
|
||||
$pesterParam['IncludeFailingTest'] = $true
|
||||
}
|
||||
|
||||
# Remove telemetry semaphore file in CI
|
||||
$telemetrySemaphoreFilepath = Join-Path $output DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY
|
||||
if ( Test-Path "${telemetrySemaphoreFilepath}" ) {
|
||||
|
|
Loading…
Reference in a new issue