Skip to content

Commit 5616d58

Browse files
committed
When writing GH comment summary, include error message
We were not including the actual exception message as the first line in the GH comment report. Fixes #85
1 parent 59beecf commit 5616d58

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/dotnet-trx/TrxCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public override int Execute(CommandContext context, TrxSettings settings)
265265
{
266266
// Send workflow commands for each failure to be annotated in GH CI
267267
// TODO: somehow the notice does not end up pointing to the right file/line
268+
// TODO: we should do newline replacement with "%0A" here too
268269
//foreach (var failure in failures)
269270
// WriteLine($"::error file={failure.File},line={failure.Line},title={failure.Title}::{failure.Message}");
270271
}
@@ -460,6 +461,9 @@ void WriteError(string baseDir, List<Failed> failures, XElement result, StringBu
460461
else
461462
details.AppendLine("csharp");
462463

464+
// First line should be the actual error message.
465+
details.AppendLineIndented(message.ReplaceLineEndings(), "> ");
466+
463467
foreach (var line in lines.Select(x => x.EscapeMarkup()))
464468
{
465469
var match = ParseFile().Match(line);
@@ -479,8 +483,8 @@ void WriteError(string baseDir, List<Failed> failures, XElement result, StringBu
479483
// NOTE: we replace whichever was last, since we want the annotation on the
480484
// last one with a filename, which will be the test itself (see previous skip from last found).
481485
failed = new Failed(testName,
482-
message.ReplaceLineEndings().Replace(Environment.NewLine, "%0A"),
483-
stackTrace.ReplaceLineEndings().Replace(Environment.NewLine, "%0A"),
486+
message.ReplaceLineEndings(),
487+
stackTrace.ReplaceLineEndings(),
484488
relative, int.Parse(pos));
485489

486490
cli.AppendLine(line.Replace(file, $"[link={file}][steelblue1_1]{relative}[/][/]"));

0 commit comments

Comments
 (0)