Skip to content

Commit

Permalink
When no profiles, return an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
SkippyZA committed Jul 16, 2021
1 parent 7bc1b92 commit 80e1ff0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gocover-cobertura.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func convert(in io.Reader, out io.Writer, ignore *Ignore) error {
}

func getPackages(profiles []*Profile) ([]*packages.Package, error) {
if len(profiles) == 0 {
return []*packages.Package{}, nil
}

var pkgNames []string
for _, profile := range profiles {
pkgNames = append(pkgNames, getPackageName(profile.FileName))
Expand Down
3 changes: 2 additions & 1 deletion gocover-cobertura_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -68,7 +69,7 @@ func TestConvertEmpty(t *testing.T) {
require.NoError(t, err)

require.Equal(t, "coverage", v.XMLName.Local)
require.NotNil(t, v.Sources)
require.Nil(t, v.Sources)
require.Nil(t, v.Packages)
}

Expand Down

0 comments on commit 80e1ff0

Please sign in to comment.