-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathConvert-CodeCoverage.ps1
More file actions
34 lines (31 loc) · 1.29 KB
/
Copy pathConvert-CodeCoverage.ps1
File metadata and controls
34 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function Convert-CodeCoverage {
<#
.SYNOPSIS
Convert the file name and line numbers from Pester code coverage of "optimized" modules to the source
.EXAMPLE
Invoke-Pester .\Tests -CodeCoverage (Get-ChildItem .\Output -Filter *.psm1).FullName -PassThru |
Convert-CodeCoverage -SourceRoot .\Source -Relative
Runs pester tests from a "Tests" subfolder against an optimized module in the "Output" folder,
piping the results through Convert-CodeCoverage to render the code coverage misses with the source paths.
#>
param(
# The root of the source folder (for resolving source code paths)
[Parameter(Mandatory)]
[string]$SourceRoot,
# The output of `Invoke-Pester -Pasthru`
# Note: Pester doesn't apply a custom type name
[Parameter(ValueFromPipeline)]
[PSObject]$InputObject,
# Output paths as short paths, relative to the SourceRoot
[switch]$Relative
)
process {
Push-Location $SourceRoot
try {
$InputObject.CodeCoverage.MissedCommands | Convert-LineNumber -Passthru |
Select-Object SourceFile, @{Name="Line"; Expr={$_.SourceLineNumber}}, Command
} finally {
Pop-Location
}
}
}