Browse Source

golden_test: normalize path separators for Windows (#550)

On windows, the wantFiles in TestParameters will never match the
files discovered when doing filepath.Walk, because of the difference
in filepath separators.  For windows, just use filepath.To/FromSlash
to convert before comparing to the set of test cases.
Chris Manghane 8 years ago
parent
commit
12a586e0ad
1 changed files with 7 additions and 0 deletions
  1. 7 0
      protoc-gen-go/golden_test.go

+ 7 - 0
protoc-gen-go/golden_test.go

@@ -10,6 +10,7 @@ import (
 	"os/exec"
 	"os/exec"
 	"path/filepath"
 	"path/filepath"
 	"regexp"
 	"regexp"
+	"runtime"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
 )
 )
@@ -249,11 +250,17 @@ func TestParameters(t *testing.T) {
 			return nil
 			return nil
 		})
 		})
 		for got := range gotFiles {
 		for got := range gotFiles {
+			if runtime.GOOS == "windows" {
+				got = filepath.ToSlash(got)
+			}
 			if !test.wantFiles[got] {
 			if !test.wantFiles[got] {
 				t.Errorf("unexpected output file: %v", got)
 				t.Errorf("unexpected output file: %v", got)
 			}
 			}
 		}
 		}
 		for want := range test.wantFiles {
 		for want := range test.wantFiles {
+			if runtime.GOOS == "windows" {
+				want = filepath.FromSlash(want)
+			}
 			if !gotFiles[want] {
 			if !gotFiles[want] {
 				t.Errorf("missing output file:    %v", want)
 				t.Errorf("missing output file:    %v", want)
 			}
 			}