Skip to content

Commit

Permalink
Allow for extra loggers in addition to trx
Browse files Browse the repository at this point in the history
dotnet-test allows multiple loggers to be specified, so we should not prevent that.
  • Loading branch information
kzu committed Aug 6, 2024
1 parent 281d33a commit e0a5484
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dotnet-retest/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"dotnet-retest": {
"commandName": "Project",
"commandLineArgs": "-- ..\\Sample\\Sample.csproj",
"commandLineArgs": "-- ..\\Sample\\Sample.csproj --logger \"html;logfilename=testResults.html\" --results-directory bin",
"workingDirectory": "."
}
}
Expand Down
16 changes: 6 additions & 10 deletions src/dotnet-retest/RetestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ record TestResult(string FullName, bool Failed);

public override async Task<int> ExecuteAsync(CommandContext context, RetestSettings settings)
{
string? path = null;
string? logger = null;

var args = context.Remaining.Raw.ToList();
// A typical mistake would be to pass dotnet test args directly without the -- separator
// so account for this automatically so users fall in the pit of success
Expand All @@ -43,9 +40,12 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
}
}

string? path = null;
var hastrx = false;

new OptionSet
{
{ "l|logger=", v => logger = v },
{ "l|logger=", v => hastrx = v.StartsWith("trx") },
{ "results-directory=", v => path = v },
}.Parse(args);

Expand All @@ -65,12 +65,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
args.Insert(1, trx.Path);
}

if (logger != null && !logger.StartsWith("trx"))
{
WriteLine($"[red]Error:[/] Unsupported logger {logger}. Use 'trx' or omit entirely.");
return -1;
}
else if (logger == null)
// Ensure we add the trx logger. Note that there can be other loggers too
if (!hastrx)
{
args.Insert(0, "--logger");
args.Insert(1, "trx");
Expand Down
1 change: 1 addition & 0 deletions src/dotnet-retest/dotnet-retest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Devlooped</RootNamespace>
<AssemblyName>retest</AssemblyName>
<NoWarn>CS9107</NoWarn>
<GenerateDocumentationFile>false</GenerateDocumentationFile>

<PackageId>dotnet-retest</PackageId>
Expand Down

0 comments on commit e0a5484

Please sign in to comment.