Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/dotnet-retest/RetestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
{
attempts++;
var task = ctx.AddTask($"Running tests, attempt #{attempts}");

try
{
task.StartTask();
Expand All @@ -126,9 +127,9 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
if (attempts > 1 && !args.Contains("--no-build"))
args.Insert(0, "--no-build");

var prefix = failed.Count > 0 ?
$"Running {failed.Count} tests, attempt [yellow]#{attempts}[/]" :
$"Running tests, attempt #{attempts}";
var prefix = attempts == 1 ?
$"Running tests" :
$"Retrying {failed.Count} failed test{(failed.Count > 1 ? "s" : "")}";

task.Description = prefix;

Expand Down Expand Up @@ -272,10 +273,18 @@ async Task<BufferedCommandResult> RunTestsAsync(string dotnet, List<string> args

public class RetestSettings : CommandSettings
{
[Description("Maximum retries when re-running failed tests")]
[CommandOption("--retries")]
[DefaultValue(3)]
public int Retries
{
get => Attempts - 1;
init => Attempts = value + 1;
}

[Description("Maximum attempts to run tests")]
[CommandOption("--attempts")]
[DefaultValue(5)]
public int Attempts { get; init; } = 5;
[CommandOption("--attempts", IsHidden = true)]
public int Attempts { get; init; }

#region trx

Expand Down
16 changes: 8 additions & 8 deletions src/dotnet-retest/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ USAGE:
dotnet retest [OPTIONS] [-- [dotnet test options]]

OPTIONS:
DEFAULT
-h, --help Prints help information
-v, --version Prints version information
--attempts 5 Maximum attempts to run tests
--output Include test output in report
--skipped True Include skipped tests in report
--gh-comment True Report as GitHub PR comment
--gh-summary True Report as GitHub step summary
DEFAULT
-h, --help Prints help information
-v, --version Prints version information
--retries 3 Maximum retries when re-running failed tests
--output Include test output in report
--skipped True Include skipped tests in report
--gh-comment True Report as GitHub PR comment
--gh-summary True Report as GitHub step summary
```