Skip to content

Commit

Permalink
Rename attempts to retries
Browse files Browse the repository at this point in the history
Much easier to remember the arg name and understand what it's about. In code, we still use attempts.

Also, reduce retries to 3, seems like a more sensible default (total attempts = 4 therefore, one less than before).

Make the task description cleaner
  • Loading branch information
kzu committed Aug 7, 2024
1 parent 2a246d5 commit 83b6e44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
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
```

0 comments on commit 83b6e44

Please sign in to comment.