diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2015-09-01 22:25:43 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-09-01 22:25:43 +0000 |
commit | c97a4c2b824d1c076707e9bd1d9f927ae8bb0def (patch) | |
tree | 3cc5829f7c6fc2cacc2bd94f7446067a6a651159 | |
parent | 9f9719d1a4555e788e430bf9b2375d3842d5b24c (diff) | |
parent | 0cac9d87b785bec832be427dfe78a3a4cf529485 (diff) | |
download | tools-c97a4c2b824d1c076707e9bd1d9f927ae8bb0def.tar.gz |
cmd/fiximports: make tests pass on windows
automerge: 0cac9d8
* commit '0cac9d87b785bec832be427dfe78a3a4cf529485':
cmd/fiximports: make tests pass on windows
-rw-r--r-- | cmd/fiximports/main_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/fiximports/main_test.go b/cmd/fiximports/main_test.go index 80adbc4..7320e22 100644 --- a/cmd/fiximports/main_test.go +++ b/cmd/fiximports/main_test.go @@ -7,6 +7,8 @@ package main import ( "bytes" "os" + "path/filepath" + "runtime" "strings" "testing" ) @@ -27,7 +29,7 @@ import ( // titanic.biz/foo -- domain is sinking but package has no import comment yet func TestFixImports(t *testing.T) { - gopath := cwd + "/testdata" + gopath := filepath.Join(cwd, "testdata") if err := os.Setenv("GOPATH", gopath); err != nil { t.Fatalf("os.Setenv: %v", err) } @@ -107,10 +109,16 @@ import ( gotRewrite := make(map[string]string) writeFile = func(filename string, content []byte, mode os.FileMode) error { filename = strings.Replace(filename, gopath, "$GOPATH", 1) + filename = filepath.ToSlash(filename) gotRewrite[filename] = string(bytes.TrimSpace(content)) return nil } + if runtime.GOOS == "windows" { + test.wantStderr = strings.Replace(test.wantStderr, `testdata/src/old.com/bad/bad.go`, `testdata\src\old.com\bad\bad.go`, -1) + test.wantStderr = strings.Replace(test.wantStderr, `testdata/src/fruit.io/banana/banana.go`, `testdata\src\fruit.io\banana\banana.go`, -1) + } + // Check status code. if fiximports(test.packages...) != test.wantOK { t.Errorf("#%d. fiximports() = %t", i, !test.wantOK) @@ -138,7 +146,7 @@ import ( // TestDryRun tests that the -n flag suppresses calls to writeFile. func TestDryRun(t *testing.T) { - gopath := cwd + "/testdata" + gopath := filepath.Join(cwd, "testdata") if err := os.Setenv("GOPATH", gopath); err != nil { t.Fatalf("os.Setenv: %v", err) } |