Skip to content

Commit e5ebd84

Browse files
include failed tests in table
1 parent 7c21ae1 commit e5ebd84

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/app/table_tests.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type packageTests struct {
4141
skipped []*parse.Test
4242
passedCount int
4343
passed []*parse.Test
44+
failed []*parse.Test
45+
failedCount int
4446
}
4547

4648
func (c *consoleWriter) testsTable(packages []*parse.Package, option TestTableOptions) {
@@ -77,9 +79,10 @@ func (c *consoleWriter) testsTable(packages []*parse.Package, option TestTableOp
7779
continue
7880
}
7981
pkgTests := getTestsFromPackages(pkg, option)
80-
all := make([]*parse.Test, 0, len(pkgTests.passed)+len(pkgTests.skipped))
82+
all := make([]*parse.Test, 0, len(pkgTests.passed)+len(pkgTests.skipped)+len(pkgTests.failed))
8183
all = append(all, pkgTests.passed...)
8284
all = append(all, pkgTests.skipped...)
85+
all = append(all, pkgTests.failed...)
8386

8487
for _, t := range all {
8588
// TODO(mf): why are we sorting this?
@@ -145,9 +148,10 @@ func (c *consoleWriter) testsTableMarkdown(packages []*parse.Package, option Tes
145148
continue
146149
}
147150
pkgTests := getTestsFromPackages(pkg, option)
148-
all := make([]*parse.Test, 0, len(pkgTests.passed)+len(pkgTests.skipped))
151+
all := make([]*parse.Test, 0, len(pkgTests.passed)+len(pkgTests.skipped)+len(pkgTests.failed))
149152
all = append(all, pkgTests.passed...)
150153
all = append(all, pkgTests.skipped...)
154+
all = append(all, pkgTests.failed...)
151155

152156
for _, t := range all {
153157
// TODO(mf): why are we sorting this?
@@ -174,9 +178,10 @@ func (c *consoleWriter) testsTableMarkdown(packages []*parse.Package, option Tes
174178
fmt.Fprintf(c.w, "## 📦 Package **`%s`**\n", pkg.Summary.Package)
175179
fmt.Fprintln(c.w)
176180

177-
msg := fmt.Sprintf("Tests: ✓ %d passed | %d skipped\n",
181+
msg := fmt.Sprintf("Tests: ✓ %d passed | %d skipped | %d failed\n",
178182
pkgTests.passedCount,
179183
pkgTests.skippedCount,
184+
pkgTests.failedCount,
180185
)
181186
if option.Slow > 0 && option.Slow < pkgTests.passedCount {
182187
msg += fmt.Sprintf("↓ Slowest %d passed tests shown (of %d)\n",
@@ -205,6 +210,8 @@ func getTestsFromPackages(pkg *parse.Package, option TestTableOptions) *packageT
205210
tests.skippedCount = len(skipped)
206211
passed := pkg.TestsByAction(parse.ActionPass)
207212
tests.passedCount = len(passed)
213+
failed := pkg.TestsByAction(parse.ActionFail)
214+
tests.failedCount = len(failed)
208215
if option.Skip {
209216
tests.skipped = append(tests.skipped, skipped...)
210217
}
@@ -219,6 +226,7 @@ func getTestsFromPackages(pkg *parse.Package, option TestTableOptions) *packageT
219226
tests.passed = tests.passed[:option.Slow]
220227
}
221228
}
229+
tests.failed = append(tests.failed, failed...)
222230
return tests
223231
}
224232

0 commit comments

Comments
 (0)