From ec75a8049cb240411f7c85a8df881a989335eade Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 24 Sep 2015 10:53:47 -0700 Subject: [PATCH] Fixes 16556 CI failures Signed-off-by: John Howard --- integration/utils.go | 11 +++++++---- integration/utils_test.go | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/integration/utils.go b/integration/utils.go index 9c78cd0..469f720 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -11,7 +11,6 @@ import ( "os/exec" "path/filepath" "reflect" - "runtime" "strings" "syscall" "time" @@ -247,12 +246,16 @@ func ListTar(f io.Reader) ([]string, error) { // RandomTmpDirPath provides a temporary path with rand string appended. // does not create or checks if it exists. -func RandomTmpDirPath(s string) string { +func RandomTmpDirPath(s string, platform string) string { tmp := "/tmp" - if runtime.GOOS == "windows" { + if platform == "windows" { tmp = os.Getenv("TEMP") } - return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) + path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) + if platform == "windows" { + return filepath.FromSlash(path) // Using \ + } + return filepath.ToSlash(path) // Using / } // ConsumeWithSpeed reads chunkSize bytes from reader after every interval. diff --git a/integration/utils_test.go b/integration/utils_test.go index 0c0bceb..7c5df4e 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -343,7 +343,7 @@ func TestListTar(t *testing.T) { } func TestRandomTmpDirPath(t *testing.T) { - path := RandomTmpDirPath("something") + path := RandomTmpDirPath("something", runtime.GOOS) prefix := "/tmp/something" if runtime.GOOS == "windows" {