Add --coverlet-file-prefix option for unique report files#1869
Merged
Bertk merged 8 commits intocoverlet-coverage:masterfrom Mar 27, 2026
Merged
Add --coverlet-file-prefix option for unique report files#1869Bertk merged 8 commits intocoverlet-coverage:masterfrom
Bertk merged 8 commits intocoverlet-coverage:masterfrom
Conversation
Introduce --coverlet-file-prefix to allow custom prefixes for coverage report filenames, preventing overwrites in multi-project test runs. Updated documentation, command-line parsing, configuration, and report generation logic to support the new option. Added comprehensive unit tests for filename generation and option handling. Improves usability in CI and multi-project scenarios.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new --coverlet-file-prefix CLI option to help generate unique coverage report filenames (avoiding overwrites) during multi-project test runs in coverlet.MTP.
Changes:
- Introduces
coverlet-file-prefixoption name/definition and threads it through configuration into report generation. - Updates report filename generation to optionally use
<prefix>.coverage.<extension>. - Adds documentation and unit tests around option handling and filename generation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/coverlet.MTP.tests/Configuration/CoverageConfigurationTests.cs | Adds unit tests for CoverageConfiguration.GetFilePrefix() behavior. |
| test/coverlet.MTP.tests/CommandLine/CoverletMTPCommandLineTests.cs | Verifies the new option is exposed and treated as valid with a value. |
| test/coverlet.MTP.tests/Collector/CollectorExtensionTests.GenerateReports.cs | Adds tests asserting prefixed/unprefixed report filenames across formats. |
| src/coverlet.MTP/Configuration/CoverletExtensionConfiguration.cs | Adds FilePrefix to the extension configuration object. |
| src/coverlet.MTP/Configuration/CoverageConfiguration.cs | Adds GetFilePrefix() to read the option value from CLI args. |
| src/coverlet.MTP/CommandLine/CoverletOptionNames.cs | Defines the coverlet-file-prefix option name constant. |
| src/coverlet.MTP/CommandLine/CoverletCommandLineOptionDefinitions.cs | Registers the new command-line option definition. |
| src/coverlet.MTP/Collector/CollectorExtension.cs | Wires the prefix into configuration and uses it in report file naming. |
| Documentation/Coverlet.MTP.Integration.md | Documents the new option and shows example usage/output naming. |
Add robust validation and sanitization for the filePrefix option used in coverage report filenames to prevent path traversal and invalid characters. Update CollectorExtension and command-line provider to reject unsafe prefixes and fall back to defaults when necessary. Improve CoverageConfiguration to trim and validate prefixes. Add comprehensive unit tests to verify correct and secure behavior.
Added unit tests to ensure coverage report file prefixes with invalid characters or whitespace fall back to default filenames. Also tested command-line prefix validation for invalid and potentially unsafe values. Improves robustness and security of file naming logic.
This was referenced Apr 17, 2026
This was referenced Apr 18, 2026
Open
Open
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.
Introduce --coverlet-file-prefix to allow custom prefixes for coverage report filenames, preventing overwrites in multi-project test runs. Updated documentation, command-line parsing, configuration, and report generation logic to support the new option. Added comprehensive unit tests for filename generation and option handling. Improves usability in CI and multi-project scenarios.