Open fflaten opened 3 months ago
CodeCoverage XML reports always report encoding="utf-8" regardless of CodeCoverage.OutputEncoding configuration option. The file itself is written using the selected encoding.
encoding="utf-8"
CodeCoverage.OutputEncoding
Related comment: https://github.com/pester/Pester/pull/2298#discussion_r1107700563
XML report should report the correct encoding in xml declaration.
# Executed in pester-repo $c = New-PesterConfiguration $c.Run.Path = './tst/functions/assertions' $c.Run.ExcludePath = '*/demo/*', '*/examples/*', '*/testProjects/*', '*/Pester.Tests.ps1' $c.Output.Verbosity = 'Detailed' $c.CodeCoverage.Enabled = $true $c.CodeCoverage.Path = './src/functions' $c.CodeCoverage.UseBreakpoints = $false $c.CodeCoverage.OutputFormat = 'JaCoCo' $c.CodeCoverage.OutputEncoding = 'unicode' #utf-16 Invoke-Pester -Configuration $c
Generated coverage.xml is UTF-16 LE, but says <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Pester version : 5.6.0-beta1 /workspaces/Pester/bin/Pester.psm1 PowerShell version : 7.4.1 OS version : Unix 5.15.133.1
1) Improve type for configuration option or limit current string option to valid encodings. Related issue #2451
2) Remove/replace hard-coded value here: https://github.com/pester/Pester/blob/93c661020d666c7c07577c46b8ad756b8aa74aec/src/functions/Coverage.ps1#L924
3) Consider replacing Out-File with XmlWriter and XmlWriterSettings.Encoding-option like TestResults? See related issue #2452
Out-File
XmlWriter
XmlWriterSettings.Encoding
Checklist
What is the issue?
CodeCoverage XML reports always report
encoding="utf-8"
regardless ofCodeCoverage.OutputEncoding
configuration option. The file itself is written using the selected encoding.Related comment: https://github.com/pester/Pester/pull/2298#discussion_r1107700563
Expected Behavior
XML report should report the correct encoding in xml declaration.
Steps To Reproduce
Generated coverage.xml is UTF-16 LE, but says
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Describe your environment
Pester version : 5.6.0-beta1 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.4.1 OS version : Unix 5.15.133.1
Possible Solution?
1) Improve type for configuration option or limit current string option to valid encodings. Related issue #2451
2) Remove/replace hard-coded value here: https://github.com/pester/Pester/blob/93c661020d666c7c07577c46b8ad756b8aa74aec/src/functions/Coverage.ps1#L924
3) Consider replacing
Out-File
withXmlWriter
andXmlWriterSettings.Encoding
-option like TestResults? See related issue #2452