Skip to content

Commit f648a45

Browse files
committed
Update coverage format option handling and exit code mapping
- Allow multiple --formats options (ArgumentArity.OneOrMore) instead of comma-separated values - Enforce single, supported format per --formats argument - Update tests to use repeated --formats options - Expand and clarify process exit code to error message mapping
1 parent 4fa64ae commit f648a45

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/coverlet.MTP/CommandLine/CoverletCommandLineOptionsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public IReadOnlyCollection<CommandLineOption> GetCommandLineOptions()
5151

5252
new(FormatsOptionName,
5353
"Output format(s) for coverage report (json, lcov, opencover, cobertura). Multiple formats can be specified comma-separated.",
54-
ArgumentArity.ExactlyOne, isHidden: false),
54+
ArgumentArity.OneOrMore, isHidden: false),
5555

5656
//new(OutputOptionName,
5757
// "Output path for coverage files",

src/coverlet.MTP/CoverletExtensionCommandLineProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public Task<ValidationResult> ValidateOptionArgumentsAsync(CommandLineOption com
5555

5656
foreach (string format in arguments)
5757
{
58+
// does not support string with multiple formats e.g. "json,lcov"
5859
if (!s_supportedFormats.Contains(format))
5960
{
6061
return Task.FromResult(ValidationResult.Invalid($"The value '{format}' is not a valid option for '{commandOption.Name}'."));

test/coverlet.MTP.validation.tests/CollectCoverageTests.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public async Task MultipleCoverageFormats_GeneratesAllReports()
198198
// Act
199199
var result = await RunTestsWithCoverage(
200200
testProject.ProjectPath,
201-
"--coverlet-coverage --formats json,cobertura,lcov",
201+
"--coverlet-coverage --formats json --formats cobertura --formats lcov",
202202
testName: TestContext.Current.TestCase!.TestMethodName!);
203203

204204
TestContext.Current?.AddAttachment("Test Output", result.CombinedOutput);
@@ -544,13 +544,21 @@ private async Task<TestResult> RunTestsWithCoverage(string projectPath, string a
544544

545545
string errorContext = process.ExitCode switch
546546
{
547-
0 => "Success",
548-
1 => "Test failures occurred",
549-
2 => "Invalid command-line arguments",
550-
3 => "Test discovery failed",
551-
4 => "Test execution failed",
552-
5 => "Unexpected error (unhandled exception)",
553-
_ => "Unknown error"
547+
0 => "Success, no errors",
548+
1 => "unknown errors",
549+
2 => "test failure",
550+
3 => "test session was aborted",
551+
4 => "setup of used extensions is invalid",
552+
5 => "command line arguments passed to the test app are invalid",
553+
6 => "test session is using a non-implemented feature",
554+
7 => "unable to complete successfully (likely crashed)",
555+
8 => "test session ran zero tests",
556+
9 => "minimum execution policy for the executed tests was violated",
557+
10 => "test adapter, Testing.Platform Test Framework, MSTest, NUnit, or xUnit, failed to run tests for an infrastructure reason",
558+
11 => "test process will exit if dependent process exits",
559+
12 => "test session was unable to run because the client does not support any of the supported protocol versions",
560+
13 => "excited number of maximum failed tests ",
561+
_ => "unrecognized exit code"
554562
};
555563

556564
return new TestResult

0 commit comments

Comments
 (0)