Skip to content

Commit

Permalink
fix test result summary, broken exit code and batch file exit
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Sep 12, 2012
2 parents 4033c57 + bd27373 commit d8012bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Functions/It.ps1
@@ -1,5 +1,6 @@
function It($name, [ScriptBlock] $test)
{
if($test_name -ne $Null -and $test_name.ToLower() -ne $name) {return}
$results = Get-GlobalTestResults
$margin = " " * $results.TestDepth
$error_margin = $margin * 2
Expand Down
6 changes: 3 additions & 3 deletions Functions/TestResults.ps1
Expand Up @@ -23,8 +23,8 @@ function Reset-GlobalTestResults {

function Write-TestReport {
$results = $Global:TestResults
Write-Host Tests completed in (Get-HumanTime $results.TotalTime)
Write-Host Passed: $($results.TestCount - $results.FailedTestsCount) Failed: $($results.FailedTestsCount)
Write-Host "Tests completed in $(Get-HumanTime $results.TotalTime)"
Write-Host "Passed: $($results.TestCount - $results.FailedTestsCount) Failed: $($results.FailedTestsCount)"
}

function Get-HumanTime($seconds) {
Expand Down Expand Up @@ -126,7 +126,7 @@ function Get-RunTimeEnvironment() {


function Exit-WithCode {
$failedTestCount = $Global:TestResults.FailedTests.Length
$failedTestCount = $Global:TestResults.FailedTestsCount
$host.SetShouldExit($failedTestCount)
}

2 changes: 1 addition & 1 deletion Pester.psm1
Expand Up @@ -2,7 +2,7 @@ Resolve-Path $PSScriptRoot\Functions\*.ps1 |
? { -not ($_.ProviderPath.Contains(".Tests.")) } |
% { . $_.ProviderPath }

function Invoke-Pester($relative_path = ".", [switch] $EnableExit, $OutputXml = $null) {
function Invoke-Pester($relative_path = ".", $test_name = $null, [switch] $EnableExit) {
Reset-GlobalTestResults
. "$PSScriptRoot\ObjectAdaptations\PesterFailure.ps1"
Update-TypeData -pre "$PSScriptRoot\ObjectAdaptations\types.ps1xml" -ErrorAction SilentlyContinue
Expand Down
2 changes: 1 addition & 1 deletion bin/pester.bat
Expand Up @@ -8,7 +8,7 @@ if '%1'=='/help' goto usage
if '%1'=='help' goto usage
if '%1'=='new-fixture' goto newfixture

@PowerShell -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "& Import-Module '%DIR%..\Pester.psm1'; & { Invoke-Pester -OutputXml Test.xml -EnableExit; exit $LastExitCode}"
@PowerShell -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "& Import-Module '%DIR%..\Pester.psm1'; & { Invoke-Pester -OutputXml Test.xml -EnableExit %*}"

goto finish
:newfixture
Expand Down

0 comments on commit d8012bd

Please sign in to comment.