Align HTML report filename path semantics with TRX#8523
Merged
Evangelink merged 7 commits intoMay 25, 2026
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix incompatible path semantics for report-html-filename and report-trx-filename
Align HTML report filename path semantics with TRX
May 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns --report-html-filename behavior with TRX report filename semantics in the Microsoft.Testing.Extensions.HtmlReport extension, expanding accepted path forms and adding placeholder resolution + write-time sanitization.
Changes:
- Updated HTML report filename validation to accept relative/absolute paths while rejecting paths that can escape the results directory.
- Added placeholder resolution (
{pname},{pid},{asm},{tfm},{time}), leaf-name sanitization, and automatic creation of missing output directories when writing the HTML report. - Updated help/acceptance expectations and added unit + integration coverage for the new contract.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HtmlReportGeneratorCommandLineTests.cs | Updates validation-focused unit tests to cover nested paths, absolute paths, traversal rejection, and drive-relative handling. |
| test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HtmlReportEngineTests.cs | Adds unit tests for relative/absolute output resolution, placeholder substitution, sanitization, and directory creation. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HtmlReportTests.cs | Updates acceptance coverage to expect HTML reports generated under nested relative paths. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs | Updates help output expectations to document new path/placeholder contract. |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.*.xlf | Regenerates localized strings for updated option description and validation messages. |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/ExtensionResources.resx | Updates option description and adjusts validation error wording to the new contract. |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/Microsoft.Testing.Extensions.HtmlReport.csproj | Links in ArtifactNamingHelper to share placeholder resolution logic. |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportGeneratorCommandLine.cs | Implements updated validation rules (relative/absolute paths, traversal/escaping checks). |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportEngine.cs | Implements placeholder resolution, leaf sanitization (TRX-aligned), and directory creation prior to writing. |
Copilot's findings
Comments suppressed due to low confidence (1)
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HtmlReportGeneratorCommandLineTests.cs:66
- Test name says the relative path "escapes" the results directory, but
nested/../report.htmldoesn’t actually escape; it’s rejected because any..segment is disallowed (matching TRX’s policy). Consider renaming the test/data row to reflect the actual rule (e.g., “contains parent-directory traversal segment”).
[TestMethod]
[DataRow("../report.html")]
[DataRow("nested/../report.html")]
public async Task IsInvalid_If_RelativePath_Escapes_TestResultsDirectory(string fileName)
{
var provider = new HtmlReportGeneratorCommandLine();
Platform.Extensions.CommandLine.CommandLineOption option = provider.GetCommandLineOptions()
.First(x => x.Name == HtmlReportGeneratorCommandLine.HtmlReportFileNameOptionName);
- Files reviewed: 21/21 changed files
- Comments generated: 2
- Drop the cross-platform IsDriveRelativePath heuristic from HtmlReportGeneratorCommandLine: on Unix ':' is a valid filename character and rejecting C:report.html there diverged from --report-trx-filename. Use Path.IsPathRooted alone (Windows-only in practice) to mirror TRX behavior. - Split the nested-path data row that used '\\' into a Windows-only test so the assertion no longer implies cross-platform separator semantics that aren't implemented. - Rename the '..' validation test to reflect the actual rule (any parent-directory segment is rejected; the path doesn't have to resolve outside the results directory). - Gate the drive-relative-path test to Windows, matching the TRX unit test layout. - Update the --info acceptance expectation for --report-html-filename to match the new option description (full path/placeholder contract), which was broken after the option description was expanded. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
Addressed review feedback in 2816362 and fixed the broken
Verified locally:
|
Splits the HTML filename validation errors so that the empty-argument and empty-leaf cases use a dedicated 'must not be empty' message, matching the TRX resource layout (TrxReportFileNameMustNotBeEmpty vs TrxReportFileNameRelativePathMustStayUnderResultsDirectory). The existing 'should not contain path' resource is renamed to HtmlReportFileNameRelativePathMustStayUnderResultsDirectory so the keys, wording, and intent stay aligned with TRX. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--report-html-filenameand--report-trx-filenamelooked like sibling options but accepted different path shapes. HTML rejected nested paths while TRX accepted relative paths, absolute paths, and placeholders.HTML filename validation
.htmlleaf extension validation.HTML report output
{pname},{pid},{asm},{tfm},{time}.Help and tests
Example: