Explorar o código

Merge pull request #10871 from ahmetalpbalkan/win-cli/TestBuildAddBadLinks-fix

integ-cli: Fix TestBuildAddBadLinks for windows
Alexander Morozov %!s(int64=10) %!d(string=hai) anos
pai
achega
4ba1128c18
Modificáronse 1 ficheiros con 16 adicións e 1 borrados
  1. 16 1
      integration-cli/docker_cli_build_test.go

+ 16 - 1
integration-cli/docker_cli_build_test.go

@@ -12,6 +12,7 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"reflect"
 	"reflect"
 	"regexp"
 	"regexp"
+	"runtime"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
 	"syscall"
 	"syscall"
@@ -1568,7 +1569,21 @@ func TestBuildAddBadLinks(t *testing.T) {
 	}
 	}
 	defer os.RemoveAll(tempDir)
 	defer os.RemoveAll(tempDir)
 
 
-	symlinkTarget := fmt.Sprintf("/../../../../../../../../../../../..%s", tempDir)
+	var symlinkTarget string
+	if runtime.GOOS == "windows" {
+		var driveLetter string
+		if abs, err := filepath.Abs(tempDir); err != nil {
+			t.Fatal(err)
+		} else {
+			driveLetter = abs[:1]
+		}
+		tempDirWithoutDrive := tempDir[2:]
+		symlinkTarget = fmt.Sprintf(`%s:\..\..\..\..\..\..\..\..\..\..\..\..%s`, driveLetter, tempDirWithoutDrive)
+	} else {
+		symlinkTarget = fmt.Sprintf("/../../../../../../../../../../../..%s", tempDir)
+	}
+
+	t.Logf("***=== %s", symlinkTarget)
 	tarPath := filepath.Join(ctx.Dir, "links.tar")
 	tarPath := filepath.Join(ctx.Dir, "links.tar")
 	nonExistingFile := filepath.Join(tempDir, targetFile)
 	nonExistingFile := filepath.Join(tempDir, targetFile)
 	fooPath := filepath.Join(ctx.Dir, targetFile)
 	fooPath := filepath.Join(ctx.Dir, targetFile)