Modules/businessdev.ALbuild.Apps/Public/Get-BcCodeCoverageSummary.ps1
|
function Get-BcCodeCoverageSummary { <# .SYNOPSIS Returns the ALbuild code-coverage summary (and per-object lines) without writing report files. .DESCRIPTION A read-only convenience over the coverage data: point it at raw *.dat (with -WorkspaceRoot for the honest source-based denominator) or at an existing coverage-summary.json. Returns the same { lineCoverage, coveredLines, totalExecutableLines, objectCount, denominatorMode } summary plus the per-object breakdown, so agents and scripts can inspect coverage without re-emitting Cobertura/Markdown. .PARAMETER CoveragePath Folder of raw *.dat files (or a single .dat file) from a coverage-enabled test run. .PARAMETER WorkspaceRoot AL source root -- restricts/maps coverage to your app objects and enables the honest denominator. .PARAMETER IncludeNonDebuggable Count [NonDebuggable] bodies in the percentage as uncovered lines. Omitted, albuild.json 'coverage.includeNonDebuggable' decides (default: listed separately, not counted). .PARAMETER SummaryPath Alternatively, an existing coverage-summary.json (or its folder) to read back. .OUTPUTS PSCustomObject: Summary, Objects. #> [CmdletBinding(DefaultParameterSetName = 'Raw')] [OutputType([PSCustomObject])] param( [Parameter(Mandatory, ParameterSetName = 'Raw')] [ValidateNotNullOrEmpty()] [string] $CoveragePath, [Parameter(ParameterSetName = 'Raw')] [string] $WorkspaceRoot, [Parameter(ParameterSetName = 'Raw')] [ValidateSet('Auto', 'Source', 'CoveredOnly')] [string] $DenominatorMode = 'Auto', [Parameter(ParameterSetName = 'Raw')] [switch] $IncludeNonDebuggable, [Parameter(Mandatory, ParameterSetName = 'Summary')] [ValidateNotNullOrEmpty()] [string] $SummaryPath ) if ($PSCmdlet.ParameterSetName -eq 'Summary') { return Resolve-BcCoverageData -SummaryPath $SummaryPath } $params = @{ CoveragePath = $CoveragePath; DenominatorMode = $DenominatorMode } if ($WorkspaceRoot) { $params['WorkspaceRoot'] = $WorkspaceRoot } if ($PSBoundParameters.ContainsKey('IncludeNonDebuggable')) { $params['IncludeNonDebuggable'] = [bool]$IncludeNonDebuggable } return Resolve-BcCoverageData @params } |