Skip to content

Commit

Permalink
Fix empty package check in dot format
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Dec 10, 2022
1 parent b212ffd commit fb867e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/junitxml/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func generate(exec *testjson.Execution, cfg Config) JUnitTestSuites {
}
for _, pkgname := range exec.Packages() {
pkg := exec.Package(pkgname)
if cfg.HideEmptyPackages && pkg.Total == 0 && !pkg.TestMainFailed() {
if cfg.HideEmptyPackages && pkg.IsEmpty() {
continue
}
junitpkg := JUnitTestSuite{
Expand Down
2 changes: 1 addition & 1 deletion testjson/dotformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (d *dotFormatter) Format(event TestEvent, exec *Execution) error {

sort.Slice(d.order, d.orderByLastUpdated)
for _, pkg := range d.order {
if d.opts.HideEmptyPackages && exec.Package(pkg).Total == 0 {
if d.opts.HideEmptyPackages && exec.Package(pkg).IsEmpty() {
continue
}

Expand Down
5 changes: 5 additions & 0 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func (p *Package) TestMainFailed() bool {
return p.action == ActionFail && len(p.Failed) == 0
}

// IsEmpty returns true if this package contains no tests.
func (p *Package) IsEmpty() bool {
return p.Total == 0 && !p.TestMainFailed()
}

const neverFinished time.Duration = -1

// end adds any tests that were missing an ActionFail TestEvent to the list of
Expand Down

0 comments on commit fb867e3

Please sign in to comment.