Skip to content

Commit

Permalink
Remove dead code in Output.ps1 (#2597)
Browse files Browse the repository at this point in the history
* Remove dead code in Output.ps1 (fixes #2584).

* Remove unused Total output

---------

Co-authored-by: Frode Flaten <[email protected]>
  • Loading branch information
davidmatson and fflaten authored Jan 8, 2025
1 parent 62823f5 commit 5eba7b6
Showing 1 changed file with 4 additions and 56 deletions.
60 changes: 4 additions & 56 deletions src/functions/Output.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
$script:ReportStrings = DATA {
@{
VersionMessage = "Pester v{0}"
FilterMessage = ' matching test name {0}'
TagMessage = ' with Tags {0}'
MessageOfs = "', '"

CoverageTitle = 'Code Coverage report:'
CoverageMessage = 'Covered {2:0.##}% / {5:0.##}%. {3:N0} analyzed {0} in {4:N0} {1}.'
MissedSingular = 'Missed command:'
MissedPlural = 'Missed commands:'
Expand All @@ -15,15 +11,10 @@ $script:ReportStrings = DATA {
FilePlural = 'Files'

Describe = 'Describing {0}'
Script = 'Executing script {0}'
Context = 'Context {0}'
Margin = ' '
Timing = 'Tests completed in {0}'

# If this is set to an empty string, the count won't be printed
ContextsPassed = ''
ContextsFailed = ''

TestsPassed = 'Tests Passed: {0}, '
TestsFailed = 'Failed: {0}, '
TestsSkipped = 'Skipped: {0}, '
Expand All @@ -34,10 +25,11 @@ $script:ReportStrings = DATA {

$script:ReportTheme = DATA {
@{
Container = 'Magenta'
Describe = 'Green'
DescribeDetail = 'DarkYellow'
Context = 'Cyan'
ContextDetail = 'DarkCyan'

BlockFail = 'Red'
Pass = 'DarkGreen'
PassTime = 'DarkGray'
Fail = 'Red'
Expand All @@ -46,19 +38,15 @@ $script:ReportTheme = DATA {
Skipped = 'Yellow'
SkippedTime = 'DarkGray'
NotRun = 'Gray'
NotRunTime = 'DarkGray'
Total = 'Gray'
Inconclusive = 'Gray'
InconclusiveTime = 'DarkGray'
Incomplete = 'Yellow'
IncompleteTime = 'DarkGray'
Foreground = 'White'
Information = 'DarkGray'

Coverage = 'White'
Discovery = 'Magenta'
Container = 'Magenta'
BlockFail = 'Red'
Warning = 'Yellow'
}
}

Expand Down Expand Up @@ -295,44 +283,17 @@ function Write-PesterReport {
$ReportTheme.Information
}

$Total = if ($RunResult.TotalCount -gt 0) {
$ReportTheme.Total
}
else {
$ReportTheme.Information
}

$Inconclusive = if ($RunResult.InconclusiveCount -gt 0) {
$ReportTheme.Inconclusive
}
else {
$ReportTheme.Information
}

# Try {
# $PesterStatePassedScenariosCount = $PesterState.PassedScenarios.Count
# }
# Catch {
# $PesterStatePassedScenariosCount = 0
# }

# Try {
# $PesterStateFailedScenariosCount = $PesterState.FailedScenarios.Count
# }
# Catch {
# $PesterStateFailedScenariosCount = 0
# }

# if ($ReportStrings.ContextsPassed) {
# & $SafeCommands['Write-Host'] ($ReportStrings.ContextsPassed -f $PesterStatePassedScenariosCount) -Foreground $Success -NoNewLine
# & $SafeCommands['Write-Host'] ($ReportStrings.ContextsFailed -f $PesterStateFailedScenariosCount) -Foreground $Failure
# }
# if ($ReportStrings.TestsPassed) {
Write-PesterHostMessage ($ReportStrings.TestsPassed -f $RunResult.PassedCount) -Foreground $Success -NoNewLine
Write-PesterHostMessage ($ReportStrings.TestsFailed -f $RunResult.FailedCount) -Foreground $Failure -NoNewLine
Write-PesterHostMessage ($ReportStrings.TestsSkipped -f $RunResult.SkippedCount) -Foreground $Skipped -NoNewLine
Write-PesterHostMessage ($ReportStrings.TestsInconclusive -f $RunResult.InconclusiveCount) -Foreground $Inconclusive -NoNewLine
Write-PesterHostMessage ($ReportStrings.TestsTotal -f $RunResult.TotalCount) -Foreground $Total -NoNewLine
Write-PesterHostMessage ($ReportStrings.TestsNotRun -f $RunResult.NotRunCount) -Foreground $NotRun

if (0 -lt $RunResult.FailedBlocksCount) {
Expand Down Expand Up @@ -565,13 +526,6 @@ function Get-WriteScreenPlugin ($Verbosity) {
$p.DiscoveryEnd = {
param ($Context)

# if ($Context.AnyFocusedTests) {
# $focusedTests = $Context.FocusedTests
# & $SafeCommands["Write-Host"] -ForegroundColor Magenta "There are some ($($focusedTests.Count)) focused tests '$($(foreach ($p in $focusedTests) { $p -join "." }) -join ",")' running just them."
# }

# . Found $count$(if(1 -eq $count) { " test" } else { " tests" })

$discoveredTests = @(View-Flat -Block $Context.BlockContainers)
Write-PesterHostMessage -ForegroundColor $ReportTheme.Discovery "Discovery found $($discoveredTests.Count) tests in $(Get-HumanTime $Context.Duration)."

Expand Down Expand Up @@ -650,12 +604,6 @@ function Get-WriteScreenPlugin ($Verbosity) {
}
}

if ($PesterPreference.Output.Verbosity.Value -in 'Detailed', 'Diagnostic') {
$p.EachBlockSetupStart = {
$Context.Configuration.BlockWritePostponed = $true
}
}

if ($PesterPreference.Output.Verbosity.Value -in 'Detailed', 'Diagnostic') {
$p.EachTestSetupStart = {
param ($Context)
Expand Down

0 comments on commit 5eba7b6

Please sign in to comment.