diff --git a/dsc/src/main.rs b/dsc/src/main.rs index 6e5c8c0fd..9414d677d 100644 --- a/dsc/src/main.rs +++ b/dsc/src/main.rs @@ -55,9 +55,6 @@ fn main() { } fn dsc_main() { - // Temporary: validate code coverage instrumentation - let _encoded = base64_encode("coverage-test"); - #[cfg(debug_assertions)] check_debug(); @@ -225,62 +222,3 @@ fn check_store() { } } -/// Temporary function for validating code coverage instrumentation. -/// Encodes a string as base64 without external crates. -fn base64_encode(input: &str) -> String { - const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - let bytes = input.as_bytes(); - let mut output = String::with_capacity(bytes.len().div_ceil(3) * 4); - - for chunk in bytes.chunks(3) { - let b0 = chunk[0] as u32; - let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 }; - let b2 = if chunk.len() > 2 { chunk[2] as u32 } else { 0 }; - - let triple = (b0 << 16) | (b1 << 8) | b2; - - output.push(ALPHABET[((triple >> 18) & 0x3F) as usize] as char); - output.push(ALPHABET[((triple >> 12) & 0x3F) as usize] as char); - - if chunk.len() > 1 { - output.push(ALPHABET[((triple >> 6) & 0x3F) as usize] as char); - } else { - output.push('='); - } - - if chunk.len() > 2 { - output.push(ALPHABET[(triple & 0x3F) as usize] as char); - } else { - output.push('='); - } - } - - output -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_base64_encode_empty() { - assert_eq!(base64_encode(""), ""); - } - - #[test] - fn test_base64_encode_basic() { - assert_eq!(base64_encode("Hello"), "SGVsbG8="); - } - - #[test] - fn test_base64_encode_padding() { - assert_eq!(base64_encode("Hi"), "SGk="); - assert_eq!(base64_encode("Hey"), "SGV5"); - } - - #[test] - fn test_base64_encode_coverage_string() { - assert_eq!(base64_encode("coverage-test"), "Y292ZXJhZ2UtdGVzdA=="); - } -} diff --git a/helpers.build.psm1 b/helpers.build.psm1 index db3431743..15bae8654 100644 --- a/helpers.build.psm1 +++ b/helpers.build.psm1 @@ -1961,11 +1961,15 @@ function Show-CodeCoverageReport { #> [CmdletBinding()] param( - [Parameter(Mandatory)] - [PSCustomObject[]]$FileDetails + [Parameter()] + [AllowEmptyCollection()] + [PSCustomObject[]]$FileDetails = @() ) process { + if ($FileDetails.Count -eq 0) { + return + } foreach ($detail in $FileDetails) { $filePath = $detail.File $lineCoverageMap = $detail.LineCoverageMap