From ca6e771245ad3c2a893b05abe2ba2b257cb451f5 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Fri, 15 Nov 2024 01:07:30 -0800 Subject: [PATCH] tests: add `testDockerfileFromHTTP` for WCOW Enables `testDockerfileFromHTTP` integration test for Windows. Also fixes a bug where paths were being joined wrongly, for example: ```go path.Join("/", "\\context") // would be "/\\context" ``` Addressing tests marked as Revisit for #4485 Signed-off-by: Anthony Nandaa --- client/llb/fileop.go | 3 ++- frontend/dockerfile/dockerfile_test.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/llb/fileop.go b/client/llb/fileop.go index fa8d2b60c..eabbc0f15 100644 --- a/client/llb/fileop.go +++ b/client/llb/fileop.go @@ -5,6 +5,7 @@ import ( _ "crypto/sha256" // for opencontainers/go-digest "os" "path" + "path/filepath" "strconv" "strings" "time" @@ -563,7 +564,7 @@ func (a *fileActionCopy) toProtoAction(ctx context.Context, parent string, base } func (a *fileActionCopy) sourcePath(ctx context.Context) (string, error) { - p := path.Clean(a.src) + p := filepath.ToSlash(path.Clean(a.src)) dir := "/" var err error if !path.IsAbs(p) { diff --git a/frontend/dockerfile/dockerfile_test.go b/frontend/dockerfile/dockerfile_test.go index fd2298eb5..6bd5bbceb 100644 --- a/frontend/dockerfile/dockerfile_test.go +++ b/frontend/dockerfile/dockerfile_test.go @@ -4491,7 +4491,6 @@ COPY --from=build foo bar2 } func testDockerfileFromHTTP(t *testing.T, sb integration.Sandbox) { - integration.SkipOnPlatform(t, "windows") f := getFrontend(t, sb) buf := bytes.NewBuffer(nil) @@ -4509,9 +4508,10 @@ func testDockerfileFromHTTP(t *testing.T, sb integration.Sandbox) { require.NoError(t, err) } - writeFile("mydockerfile", `FROM scratch + dockerfile := fmt.Sprintf(`FROM %s COPY foo bar -`) +`, integration.UnixOrWindows("scratch", "nanoserver")) + writeFile("mydockerfile", dockerfile) writeFile("foo", "foo-contents")