Skip to content

Commit

Permalink
fix duplicate package output.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-yuki committed Oct 30, 2013
1 parent 080b495 commit e42a6cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions gocover-cobertura.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (cov *Coverage) parseProfile(profile *Profile) error {
}
if pkg == nil {
pkg = &Package{Name: pkgPath, Classes: []*Class{}}
cov.Packages = append(cov.Packages, pkg)
}
visitor := &fileVisitor{
fset: fset,
Expand All @@ -90,13 +91,10 @@ func (cov *Coverage) parseProfile(profile *Profile) error {
coverage: cov,
classes: make(map[string]*Class),
data: data,
pkg: pkg,
profile: profile,
}
ast.Walk(visitor, visitor.astFile)
for _, c := range visitor.classes {
pkg.Classes = append(pkg.Classes, c)
}
cov.Packages = append(cov.Packages, pkg)
return nil
}

Expand All @@ -107,6 +105,7 @@ type fileVisitor struct {
coverage *Coverage
classes map[string]*Class
data []byte
pkg *Package
profile *Profile
}

Expand Down Expand Up @@ -156,6 +155,7 @@ func (v *fileVisitor) class(n *ast.FuncDecl) *Class {
if class == nil {
class = &Class{Name: className, Filename: v.name, Methods: []*Method{}, Lines: []*Line{}}
v.classes[className] = class
v.pkg.Classes = append(v.pkg.Classes, class)
}
return class
}
Expand Down
4 changes: 2 additions & 2 deletions gocover-cobertura_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func TestConvertSetMode(t *testing.T) {
if c.Name != "Type1" {
t.Error()
}
if c.Filename != dirInfo.PkgPath+"/testdata/func1.go" {
t.Errorf("Expected %s but %s", dirInfo.PkgPath+"/testdata/func1.go", c.Filename)
if c.Filename != dirInfo.PkgPath+"/testdata/func2.go" {
t.Errorf("Expected %s but %s", dirInfo.PkgPath+"/testdata/func2.go", c.Filename)
}
if c.Methods == nil || len(c.Methods) != 3 {
t.Fatal()
Expand Down

0 comments on commit e42a6cd

Please sign in to comment.