Skip to content

Commit

Permalink
tests: add testDockerfileFromHTTP for WCOW
Browse files Browse the repository at this point in the history
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"
// instead use
src := filepath.Join("/", "\\context") // "\context"
```

Addressing tests marked as Revisit for #4485

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
  • Loading branch information
profnandaa committed Nov 15, 2024
1 parent 9a33f71 commit ef753c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/llb/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
_ "crypto/sha256" // for opencontainers/go-digest
"os"
"path"
"path/filepath"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -576,7 +577,7 @@ func (a *fileActionCopy) sourcePath(ctx context.Context) (string, error) {
return "", err
}
}
return path.Join(dir, p), nil
return filepath.Join(dir, p), nil
}

func (a *fileActionCopy) addCaps(f *FileOp) {
Expand Down
6 changes: 3 additions & 3 deletions frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")

Expand Down

0 comments on commit ef753c4

Please sign in to comment.