Skip to content

Commit

Permalink
Add ouctome column and screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Aug 7, 2024
1 parent 0afb6aa commit a8bb70c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Binary file added assets/img/progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/timings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ test results, integrating also with GitHub PR comments just like [dotnet-trx](ht

![Demo](https://raw.githubusercontent.com/devlooped/dotnet-retest/main/assets/img/ciretry.png)

When running locally, it provides live progress on each run:

![Demo](https://raw.githubusercontent.com/devlooped/dotnet-retest/main/assets/img/progress.png)

and timing and outcome for each attempt:

![Demo](https://raw.githubusercontent.com/devlooped/dotnet-retest/main/assets/img/timings.png)

Typical usage: `dotnet retest [OPTIONS] [-- [dotnet test options]]` (with optional `--attempts` which defaults to `5`):

```yml
Expand Down
28 changes: 22 additions & 6 deletions src/dotnet-retest/RetestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti

ProgressColumn[] columns = ci ?
[new TaskDescriptionColumn { Alignment = Justify.Left }] :
[new SpinnerColumn(), new ElapsedTimeColumn(), new MultilineTaskDescriptionColumn()];
[new OutcomeSpinnerColumn(), new ElapsedTimeColumn(), new MultilineTaskDescriptionColumn()];

var exitCode = await Progress()
.Columns(columns)
Expand Down Expand Up @@ -144,13 +144,13 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
}
}));

// By setting the exit code to the task, the OutcomeSpinnerColumn can render appropately
task.Value = exit.ExitCode;
// Restore description without last progress (if any)
task.Description = prefix;

if (exit.ExitCode == 0)
{
task.Description = prefix + " :check_mark_button:";
return 0;
}

task.Description = prefix + " :cross_mark:";

if (!HasTestExpr().IsMatch(exit.StandardOutput) &&
!HasTestSummaryExpr().IsMatch(exit.StandardOutput))
Expand Down Expand Up @@ -320,4 +320,20 @@ public override IRenderable Render(RenderOptions options, ProgressTask task, Tim
.Justify(Justify.Left);
}
}

class OutcomeSpinnerColumn : ProgressColumn
{
readonly SpinnerColumn spinner = new();

public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
{
if (!task.IsFinished)
return spinner.Render(options, task, deltaTime);

if (task.Value == 0)
return new Markup(":check_mark_button:");
else
return new Markup(":cross_mark:");
}
}
}

0 comments on commit a8bb70c

Please sign in to comment.