Skip to content

Commit

Permalink
pprof: fix tests on Windows
Browse files Browse the repository at this point in the history
Skip TestSymbolizationPath (seems too Unix-specific).
Fix others with golden output to adjust for Windows file name syntax.
  • Loading branch information
rsc committed Feb 24, 2017
1 parent e859bce commit 7eb5ba9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -162,6 +163,10 @@ func TestParse(t *testing.T) {
t.Errorf("reading solution file %s: %v", solution, err)
continue
}
if runtime.GOOS == "windows" {
sbuf = bytes.Replace(sbuf, []byte("testdata/"), []byte("testdata\\"), -1)
sbuf = bytes.Replace(sbuf, []byte("/path/to/"), []byte("\\path\\to\\"), -1)
}

if flags[0] == "svg" {
b = removeScripts(b)
Expand Down
5 changes: 5 additions & 0 deletions internal/driver/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"path/filepath"
"reflect"
"regexp"
"runtime"
"testing"
"time"

Expand All @@ -32,6 +33,10 @@ import (
)

func TestSymbolizationPath(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("test assumes Unix paths")
}

// Save environment variables to restore after test
saveHome := os.Getenv("HOME")
savePath := os.Getenv("PPROF_BINARY_PATH")
Expand Down
4 changes: 4 additions & 0 deletions internal/proftest/proftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func Diff(b1, b2 []byte) (data []byte, err error) {
// Ignore that failure as long as we get output.
err = nil
}
if err != nil {
data = []byte(fmt.Sprintf("diff failed: %v\nb1: %q\nb2: %q\n", err, b1, b2))
err = nil
}
return
}

Expand Down
4 changes: 4 additions & 0 deletions internal/report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"bytes"
"io/ioutil"
"regexp"
"runtime"
"testing"

"github.com/google/pprof/internal/binutils"
Expand Down Expand Up @@ -76,6 +77,9 @@ func TestSource(t *testing.T) {
if err != nil {
t.Fatalf("%s: %v", tc.want, err)
}
if runtime.GOOS == "windows" {
gold = bytes.Replace(gold, []byte("testdata/"), []byte("testdata\\"), -1)
}
if string(b.String()) != string(gold) {
d, err := proftest.Diff(gold, b.Bytes())
if err != nil {
Expand Down

0 comments on commit 7eb5ba9

Please sign in to comment.