Skip to content

Commit

Permalink
Clean some stuff from pester#920 that are no longer needed because of p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Thilas authored and nohwnd committed Jan 3, 2019
1 parent 453df17 commit d13dee0
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 172 deletions.
2 changes: 1 addition & 1 deletion Functions/Coverage.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ InModuleScope Pester {
}

It 'JaCoCo report must be correct'{
[String]$jaCoCoReportXml = Get-JaCoCoReportXml -PesterState $testState -CoverageReport $coverageReport -DetailedCodeCoverage
[String]$jaCoCoReportXml = Get-JaCoCoReportXml -PesterState $testState -CoverageReport $coverageReport
$jaCoCoReportXml = $jaCoCoReportXml -replace 'Pester \([^\)]*','Pester (date'
$jaCoCoReportXml = $jaCoCoReportXml -replace 'start="[0-9]*"','start=""'
$jaCoCoReportXml = $jaCoCoReportXml -replace 'dump="[0-9]*"','dump=""'
Expand Down
4 changes: 1 addition & 3 deletions Functions/Coverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ function Get-JaCoCoReportXml {
[parameter(Mandatory=$true)]
$PesterState,
[parameter(Mandatory=$true)]
[object] $CoverageReport,

[Switch]$DetailedCodeCoverage
[object] $CoverageReport
)

if ($null -eq $CoverageReport -or ($pester.Show -eq [Pester.OutputTypes]::None) -or $CoverageReport.NumberOfCommandsAnalyzed -eq 0)
Expand Down
23 changes: 1 addition & 22 deletions Functions/Describe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ Optional parameter containing an array of strings. When calling Invoke-Pester,
it is possible to specify a -Tag parameter which will only execute Describe blocks
containing the same Tag.
.PARAMETER CodeCoverage
Adds a code coverage report to the Pester tests. Takes strings or hash table values.
A code coverage report lists the lines of code that did and did not run during
a Pester test. This report does not tell whether code was tested; only whether
the code ran during the test.
.EXAMPLE
function Add-Numbers($a, $b) {
return $a + $b
Expand Down Expand Up @@ -75,8 +68,6 @@ about_TestDrive
[Alias('Tags')]
[string[]] $Tag=@(),

[object[]] $CodeCoverage = @(),

[Parameter(Position = 1)]
[ValidateNotNull()]
[ScriptBlock] $Fixture = $(Throw "No test script block is provided. (Have you put the open curly brace on the next line?)")
Expand All @@ -91,17 +82,7 @@ about_TestDrive
$script:mockTable = @{}
}

if ($Pester.FindCodeCoverage)
{
foreach($cc in $CodeCoverage)
{
$Pester.CodeCoverage += $cc
}
}
else
{
DescribeImpl @PSBoundParameters -CommandUsed 'Describe' -Pester $Pester -DescribeOutputBlock ${function:Write-Describe} -TestOutputBlock ${function:Write-PesterResult} -NoTestRegistry:('Windows' -ne (GetPesterOs))
}
DescribeImpl @PSBoundParameters -CommandUsed 'Describe' -Pester $Pester -DescribeOutputBlock ${function:Write-Describe} -TestOutputBlock ${function:Write-PesterResult} -NoTestRegistry:('Windows' -ne (GetPesterOs))
}

function DescribeImpl {
Expand All @@ -112,8 +93,6 @@ function DescribeImpl {
[Alias('Tags')]
$Tag=@(),

[object[]] $CodeCoverage = @(),

[Parameter(Position = 1)]
[ValidateNotNull()]
[ScriptBlock] $Fixture = $(Throw "No test script block is provided. (Have you put the open curly brace on the next line?)"),
Expand Down
5 changes: 0 additions & 5 deletions Functions/PesterState.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ function New-PesterState
$script:Show = $Show
$script:InTest = $false

$script:FindCodeCoverage = $false
$script:CodeCoverage = @()

$script:TestResult = @()

$script:TotalCount = 0
Expand Down Expand Up @@ -338,8 +335,6 @@ function New-PesterState
"TestResult",
"SessionState",
"CommandCoverage",
"FindCodeCoverage",
"CodeCoverage",
"Strict",
"Show",
"Time",
Expand Down
1 change: 0 additions & 1 deletion Pester.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ $manifestPath = (Join-Path $here 'Pester.psd1')
$changeLogPath = (Join-Path $here 'CHANGELOG.md')

# DO NOT CHANGE THIS TAG NAME; IT AFFECTS THE CI BUILD.
#
Describe -Tags 'VersionChecks' "Pester manifest and changelog" {
$script:manifest = $null
$script:tagVersion = $null
Expand Down
41 changes: 3 additions & 38 deletions Pester.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,6 @@ Default value is: JaCoCo.
Currently supported formats are:
- JaCoCo - this XML file format is compatible with the VSTS/TFS
.PARAMETER DetailedCodeCoverage
Add the sourcefile names and lines covered and missed to the codecoverage file.
.PARAMETER Strict
Makes Pending and Skipped tests to Failed tests. Useful for continuous
integration where you need to make sure all tests passed.
Expand Down Expand Up @@ -1056,8 +1053,6 @@ New-PesterOption
[ValidateSet('JaCoCo')]
[String]$CodeCoverageOutputFileFormat = "JaCoCo",

[Switch]$DetailedCodeCoverage = $false,

[Switch]$Strict,

[Parameter(Mandatory = $true, ParameterSetName = 'NewOutputSet')]
Expand Down Expand Up @@ -1104,6 +1099,7 @@ New-PesterOption

try
{
Enter-CoverageAnalysis -CodeCoverage $CodeCoverage -PesterState $pester
Write-PesterStart $pester $Script

$invokeTestScript = {
Expand Down Expand Up @@ -1131,34 +1127,6 @@ New-PesterOption
$testScripts = @(ResolveTestScripts $Script)


if ($DetailedCodeCoverage)
{
$pester.FindCodeCoverage = $true
$pester.CodeCoverage = $CodeCoverage

# find describe codecoverage here
foreach ($testScript in $testScripts)
{
try
{
do
{
Write-ScriptBlockInvocationHint -Hint "Invoke-Pester" -ScriptBlock $invokeTestScript
& $invokeTestScript -Path $testScript.Path -Arguments $testScript.Arguments -Parameters $testScript.Parameters
} until ($true)
}
catch
{ }
}


$pester.FindCodeCoverage = $false
$CodeCoverage = $pester.CodeCoverage
}


Enter-CoverageAnalysis -CodeCoverage $CodeCoverage -PesterState $pester

foreach ($testScript in $testScripts)
{
#Get test description for better output
Expand Down Expand Up @@ -1201,13 +1169,10 @@ New-PesterOption

$pester | Write-PesterReport
$coverageReport = Get-CoverageReport -PesterState $pester
if ($DetailedCodeCoverage -eq $false)
{
Write-CoverageReport -CoverageReport $coverageReport
}
Write-CoverageReport -CoverageReport $coverageReport
if ((& $script:SafeCommands['Get-Variable'] -Name CodeCoverageOutputFile -ValueOnly -ErrorAction $script:IgnoreErrorPreference) `
-and (& $script:SafeCommands['Get-Variable'] -Name CodeCoverageOutputFileFormat -ValueOnly -ErrorAction $script:IgnoreErrorPreference) -eq 'JaCoCo') {
$jaCoCoReport = Get-JaCoCoReportXml -PesterState $pester -CoverageReport $coverageReport -DetailedCodeCoverage:$DetailedCodeCoverage
$jaCoCoReport = Get-JaCoCoReportXml -PesterState $pester -CoverageReport $coverageReport
$jaCoCoReport | & $SafeCommands['Out-File'] $CodeCoverageOutputFile -Encoding utf8
}
Exit-CoverageAnalysis -PesterState $pester
Expand Down
102 changes: 0 additions & 102 deletions report.xsd

This file was deleted.

0 comments on commit d13dee0

Please sign in to comment.