Ver código fonte

pprof: fix tests on Windows

Skip TestSymbolizationPath (seems too Unix-specific).
Fix others with golden output to adjust for Windows file name syntax.
Russ Cox 8 anos atrás
pai
commit
7eb5ba977f

+ 5
- 0
internal/driver/driver_test.go Ver arquivo

@@ -20,6 +20,7 @@ import (
20 20
 	"io/ioutil"
21 21
 	"os"
22 22
 	"regexp"
23
+	"runtime"
23 24
 	"strconv"
24 25
 	"strings"
25 26
 	"testing"
@@ -162,6 +163,10 @@ func TestParse(t *testing.T) {
162 163
 			t.Errorf("reading solution file %s: %v", solution, err)
163 164
 			continue
164 165
 		}
166
+		if runtime.GOOS == "windows" {
167
+			sbuf = bytes.Replace(sbuf, []byte("testdata/"), []byte("testdata\\"), -1)
168
+			sbuf = bytes.Replace(sbuf, []byte("/path/to/"), []byte("\\path\\to\\"), -1)
169
+		}
165 170
 
166 171
 		if flags[0] == "svg" {
167 172
 			b = removeScripts(b)

+ 5
- 0
internal/driver/fetch_test.go Ver arquivo

@@ -23,6 +23,7 @@ import (
23 23
 	"path/filepath"
24 24
 	"reflect"
25 25
 	"regexp"
26
+	"runtime"
26 27
 	"testing"
27 28
 	"time"
28 29
 
@@ -32,6 +33,10 @@ import (
32 33
 )
33 34
 
34 35
 func TestSymbolizationPath(t *testing.T) {
36
+	if runtime.GOOS == "windows" {
37
+		t.Skip("test assumes Unix paths")
38
+	}
39
+
35 40
 	// Save environment variables to restore after test
36 41
 	saveHome := os.Getenv("HOME")
37 42
 	savePath := os.Getenv("PPROF_BINARY_PATH")

+ 4
- 0
internal/proftest/proftest.go Ver arquivo

@@ -52,6 +52,10 @@ func Diff(b1, b2 []byte) (data []byte, err error) {
52 52
 		// Ignore that failure as long as we get output.
53 53
 		err = nil
54 54
 	}
55
+	if err != nil {
56
+		data = []byte(fmt.Sprintf("diff failed: %v\nb1: %q\nb2: %q\n", err, b1, b2))
57
+		err = nil
58
+	}
55 59
 	return
56 60
 }
57 61
 

+ 4
- 0
internal/report/report_test.go Ver arquivo

@@ -18,6 +18,7 @@ import (
18 18
 	"bytes"
19 19
 	"io/ioutil"
20 20
 	"regexp"
21
+	"runtime"
21 22
 	"testing"
22 23
 
23 24
 	"github.com/google/pprof/internal/binutils"
@@ -76,6 +77,9 @@ func TestSource(t *testing.T) {
76 77
 		if err != nil {
77 78
 			t.Fatalf("%s: %v", tc.want, err)
78 79
 		}
80
+		if runtime.GOOS == "windows" {
81
+			gold = bytes.Replace(gold, []byte("testdata/"), []byte("testdata\\"), -1)
82
+		}
79 83
 		if string(b.String()) != string(gold) {
80 84
 			d, err := proftest.Diff(gold, b.Bytes())
81 85
 			if err != nil {