Skip to content

Commit 227a7c9

Browse files
devlooped-botkzu
authored andcommitted
⬆️ Bump files with dotnet-file sync
# devlooped/dotnet-trx - Quieter output by default devlooped/dotnet-trx@aa907cf
1 parent af5a91c commit 227a7c9

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

.netconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
weak
9696
[file "src/dotnet-retest/TrxCommand.cs"]
9797
url = https://github.com/devlooped/dotnet-trx/blob/main/src/dotnet-trx/TrxCommand.cs
98-
sha = e2817844b7a87ca5492d984711dc2ce84f58377e
99-
etag = 629a31f3489e663ef439c5887f39b92594589d3447bc1e47fe91f2c24337de34
98+
sha = aa907cf46cce0b943d746d4e006bf36183215721
99+
etag = 9865e79013bd2e83f5146132da23712f09b069dc9009d141c288e4b7dc6041ce
100100
weak
101101
[file "src/dotnet-retest/Process.cs"]
102102
url = https://github.com/devlooped/dotnet-trx/blob/main/src/dotnet-trx/Process.cs

src/dotnet-retest/TrxCommand.cs

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public partial class TrxCommand : Command<TrxCommand.TrxSettings>
2626
static string Author =>
2727
$"from [{ThisAssembly.Project.PackageId}]({ThisAssembly.Project.PackageProjectUrl}) v{ThisAssembly.Project.Version} on {RuntimeInformation.FrameworkDescription} with [:purple_heart:](https://github.com/sponsors/devlooped)";
2828

29+
public enum Verbosity
30+
{
31+
[Description("Only failed tests are displayed")]
32+
Quiet,
33+
[Description("Failed and skipped tests are displayed")]
34+
Normal,
35+
[Description("Failed, skipped and passed tests are displayed")]
36+
Verbose,
37+
}
38+
2939
public class TrxSettings : CommandSettings
3040
{
3141
[Description("Optional base directory for *.trx files discovery. Defaults to current directory.")]
@@ -42,21 +52,42 @@ public class TrxSettings : CommandSettings
4252
[DefaultValue(true)]
4353
public bool Recursive { get; set; } = true;
4454

55+
/// <summary>
56+
/// Output verbosity.
57+
/// </summary>
58+
[Description(
59+
"""
60+
Output display verbosity:
61+
- quiet: only failed tests are displayed
62+
- normal: failed and skipped tests are displayed
63+
- verbose: failed, skipped and passed tests are displayed
64+
""")]
65+
[CommandOption("-v|--verbosity <quiet|normal|verbose>")]
66+
[DefaultValue(Verbosity.Quiet)]
67+
public Verbosity Verbosity { get; set; } = Verbosity.Quiet;
68+
4569
/// <summary>
4670
/// Whether to include skipped tests in the output.
4771
/// </summary>
48-
[Description("Include skipped tests")]
49-
[CommandOption("--skipped")]
72+
[Description("Include skipped tests in output")]
73+
[CommandOption("--skipped", IsHidden = true)]
5074
[DefaultValue(true)]
51-
public bool Skipped { get; set; } = true;
75+
public bool Skipped
76+
{
77+
get => Verbosity != Verbosity.Quiet;
78+
set
79+
{
80+
if (!value)
81+
Verbosity = Verbosity.Quiet;
82+
}
83+
}
5284

5385
/// <summary>
5486
/// Whether to return a -1 exit code on test failures.
5587
/// </summary>
5688
[Description("Do not return a -1 exit code on test failures")]
5789
[CommandOption("--no-exit-code")]
58-
[DefaultValue(false)]
59-
public bool NoExitCode { get; set; } = false;
90+
public bool NoExitCode { get; set; }
6091

6192
/// <summary>
6293
/// Report as GitHub PR comment.
@@ -138,14 +169,17 @@ public override int Execute(CommandContext context, TrxSettings settings)
138169
foreach (var result in results)
139170
{
140171
var test = result.Attribute("testName")!.Value.EscapeMarkup();
141-
var elapsed = TimeSpan.Parse(result.Attribute("duration")!.Value);
172+
var elapsed = TimeSpan.Parse(result.Attribute("duration")?.Value ?? "0");
142173
var output = settings.Output ? result.CssSelectElement("StdOut")?.Value : default;
143174

144175
switch (result.Attribute("outcome")?.Value)
145176
{
146177
case "Passed":
147178
passed++;
148179
duration += elapsed;
180+
if (settings.Verbosity != Verbosity.Verbose)
181+
break;
182+
149183
MarkupLine($":check_mark_button: {test}");
150184
if (output == null)
151185
details.AppendLine($":white_check_mark: {test}");
@@ -181,10 +215,10 @@ public override int Execute(CommandContext context, TrxSettings settings)
181215
details.AppendLine().AppendLine("</details>").AppendLine();
182216
break;
183217
case "NotExecuted":
184-
if (!settings.Skipped)
218+
skipped++;
219+
if (settings.Verbosity == Verbosity.Quiet)
185220
break;
186221

187-
skipped++;
188222
var reason = result.CssSelectElement("Output > ErrorInfo > Message")?.Value;
189223
Markup($"[dim]:white_question_mark: {test}[/]");
190224
details.Append($":grey_question: {test}");

0 commit comments

Comments
 (0)