Skip to content

Commit

Permalink
Merge 53dfefa into e2e9dff
Browse files Browse the repository at this point in the history
  • Loading branch information
msabramo committed Feb 14, 2018
2 parents e2e9dff + 53dfefa commit 759e17a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
26 changes: 6 additions & 20 deletions gocover-cobertura_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"text/template"
)

const SaveTestResults = false
Expand Down Expand Up @@ -115,22 +113,10 @@ func TestParseProfilePermissionDenied(t *testing.T) {
}

func TestConvertSetMode(t *testing.T) {
tmpl, err := template.ParseFiles("testdata/testdata_set.txt")
pipe1rd, err := os.Open("testdata/testdata_set.txt")
if err != nil {
t.Fatal("Can't parse testdata.")
}
dirInfo := dirInfo{}
dirInfo.PkgPath = reflect.TypeOf(Coverage{}).PkgPath()

pipe1rd, pipe1wr := io.Pipe()
go func() {
err := tmpl.Execute(pipe1wr, dirInfo)
if err != nil {
t.Error("Can't execute template.")
panic("tmpl.Execute failed")
}
pipe1wr.Close()
}()

pipe2rd, pipe2wr := io.Pipe()

Expand Down Expand Up @@ -163,7 +149,7 @@ func TestConvertSetMode(t *testing.T) {
}

p := v.Packages[0]
if strings.TrimRight(p.Name, "/") != dirInfo.PkgPath+"/testdata" {
if strings.TrimRight(p.Name, "/") != "./testdata" {
t.Fatal(p.Name)
}
if p.Classes == nil || len(p.Classes) != 2 {
Expand All @@ -174,8 +160,8 @@ func TestConvertSetMode(t *testing.T) {
if c.Name != "-" {
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 != "./testdata/func1.go" {
t.Errorf("Expected %s but %s", "./testdata/func1.go", c.Filename)
}
if c.Methods == nil || len(c.Methods) != 1 {
t.Fatal()
Expand Down Expand Up @@ -226,8 +212,8 @@ func TestConvertSetMode(t *testing.T) {
if c.Name != "Type1" {
t.Error()
}
if c.Filename != dirInfo.PkgPath+"/testdata/func2.go" {
t.Errorf("Expected %s but %s", dirInfo.PkgPath+"/testdata/func2.go", c.Filename)
if c.Filename != "./testdata/func2.go" {
t.Errorf("Expected %s but %s", "./testdata/func2.go", c.Filename)
}
if c.Methods == nil || len(c.Methods) != 3 {
t.Fatal()
Expand Down
12 changes: 6 additions & 6 deletions testdata/testdata_set.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mode: set
{{.PkgPath}}/testdata/func1.go:4.23,5.16 1 1
{{.PkgPath}}/testdata/func1.go:5.16,7.3 1 0
{{.PkgPath}}/testdata/func2.go:7.34,8.16 1 1
{{.PkgPath}}/testdata/func2.go:8.16,10.3 1 1
{{.PkgPath}}/testdata/func2.go:13.35,14.2 0 0
{{.PkgPath}}/testdata/func2.go:16.35,17.2 0 0
./testdata/func1.go:4.23,5.16 1 1
./testdata/func1.go:5.16,7.3 1 0
./testdata/func2.go:7.34,8.16 1 1
./testdata/func2.go:8.16,10.3 1 1
./testdata/func2.go:13.35,14.2 0 0
./testdata/func2.go:16.35,17.2 0 0

0 comments on commit 759e17a

Please sign in to comment.