mirror of
https://github.com/moby/buildkit.git
synced 2026-11-06 05:16:45 +00:00
Enable Windows support for BuildKit integration tests
This PR adds comprehensive Windows container support to BuildKit's integration test suite, enabling cross-platform testing while maintaining full Linux compatibility. - Updated 35+ integration tests to work on both Windows and Linux - Uses integration.UnixOrWindows() pattern for platform-specific logic - Windows: nanoserver images, cmd.exe commands, C:\ paths, CRLF handling - Linux: preserves existing alpine/busybox images and bash/sh commands - Added platform-specific adaptations for cache, export, frontend, and CLI tests - Files: 12 modified (+454/-151 lines) - Coverage: Major test categories now cross-platform compatible - Compatibility: 100% backward compatible, no breaking changes - CI: Enables Windows testing in BuildKit pipeline - Cache import/export (local, registry, multiple backends) - Image exporters (containerd, OCI, tar, metadata) - Dockerfile frontend parsing and builds - buildctl CLI functionality - Multi-stage builds and named contexts Tests requiring POSIX features (uid/gid, tmpfs, file modes) remain Linux-only. Signed-off-by: Dawei Wei <davwei@microsoft.com>
This commit is contained in:
1 parent
e6d9fcde22
commit
610dbfac5e
13 files changed
+490
-190
No files matched your search
@@ -2265,7 +2265,6 @@ func testClientGatewayNilResult(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testClientGatewayEmptyImageExec(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
|
||||
+122
-51
@@ -792,22 +792,32 @@ func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
type testVars struct {
|
||||
imgName string
|
||||
cmdStr1 string
|
||||
cmdStr2 string
|
||||
}
|
||||
|
||||
v := integration.UnixOrWindows(
|
||||
testVars{
|
||||
imgName: "busybox:latest",
|
||||
cmdStr1: "sh -c 'echo $HOSTNAME | grep %s'",
|
||||
cmdStr2: "sh -c 'echo $(hostname) | grep %s'",
|
||||
},
|
||||
testVars{
|
||||
imgName: "nanoserver:latest",
|
||||
// NOTE: Windows capitalizes the hostname hence
|
||||
// case insensitive findstr (findstr /I)
|
||||
// testtest --> TESTTEST
|
||||
cmdStr1: "cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
|
||||
cmdStr2: "cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
|
||||
},
|
||||
)
|
||||
|
||||
hostname := "testtest"
|
||||
// NOTE: Windows capitalizes the hostname hence
|
||||
// case insensitive findstr (findstr /I)
|
||||
// testtest --> TESTTEST
|
||||
cmdStr1 := integration.UnixOrWindows(
|
||||
"sh -c 'echo $HOSTNAME | grep %s'",
|
||||
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
|
||||
)
|
||||
cmdStr2 := integration.UnixOrWindows(
|
||||
"sh -c 'echo $(hostname) | grep %s'",
|
||||
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
|
||||
)
|
||||
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
|
||||
st := llb.Image(imgName).With(llb.Hostname(hostname)).
|
||||
Run(llb.Shlexf(cmdStr1, hostname)).
|
||||
Run(llb.Shlexf(cmdStr2, hostname))
|
||||
st := llb.Image(v.imgName).With(llb.Hostname(hostname)).
|
||||
Run(llb.Shlexf(v.cmdStr1, hostname)).
|
||||
Run(llb.Shlexf(v.cmdStr2, hostname))
|
||||
|
||||
def, err := st.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -2634,8 +2644,9 @@ func testOCILayoutSource(t *testing.T, sb integration.Sandbox) {
|
||||
require.Equal(t, []byte("second"+newLine), dt)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testSessionExporter(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureOCILayout)
|
||||
c, err := New(context.TODO(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
@@ -2653,7 +2664,10 @@ func testSessionExporter(t *testing.T, sb integration.Sandbox) {
|
||||
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
}
|
||||
|
||||
cmdPrefix := `sh -c "echo -n`
|
||||
cmdPrefix := integration.UnixOrWindows(
|
||||
`sh -c "echo -n`,
|
||||
`cmd /C "echo`,
|
||||
)
|
||||
run(fmt.Sprintf(`%s first > foo"`, cmdPrefix))
|
||||
run(fmt.Sprintf(`%s second > bar"`, cmdPrefix))
|
||||
|
||||
@@ -4486,7 +4500,6 @@ func testSourceDateEpochTarExporter(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testSourceDateEpochImageExporter(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
cdAddress := sb.ContainerdAddress()
|
||||
if cdAddress == "" {
|
||||
t.SkipNow()
|
||||
@@ -4495,24 +4508,46 @@ func testSourceDateEpochImageExporter(t *testing.T, sb integration.Sandbox) {
|
||||
// https://github.com/containerd/containerd/commit/133ddce7cf18a1db175150e7a69470dea1bb3132
|
||||
minVer := "v1.7.0-beta.1"
|
||||
cdVersion := containerdutil.GetVersion(t, cdAddress)
|
||||
if semver.Compare(cdVersion, minVer) < 0 {
|
||||
// Normalize containerd version to semver format (add v prefix if missing)
|
||||
normalizedCdVersion := cdVersion
|
||||
if !strings.HasPrefix(cdVersion, "v") {
|
||||
normalizedCdVersion = "v" + cdVersion
|
||||
}
|
||||
if semver.Compare(normalizedCdVersion, minVer) < 0 {
|
||||
t.Skipf("containerd version %q does not satisfy minimal version %q", cdVersion, minVer)
|
||||
}
|
||||
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureSourceDateEpoch)
|
||||
requiresLinux(t)
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
|
||||
busybox := llb.Image("busybox:latest")
|
||||
st := llb.Scratch()
|
||||
|
||||
run := func(cmd string) {
|
||||
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
type testVars struct {
|
||||
baseImgName string
|
||||
st llb.State
|
||||
cmdPrefix string
|
||||
}
|
||||
|
||||
run(`sh -c "echo -n first > foo"`)
|
||||
run(`sh -c "echo -n second > bar"`)
|
||||
baseImg := llb.Image(integration.UnixOrWindows("busybox:latest", "nanoserver:latest"))
|
||||
v := integration.UnixOrWindows(
|
||||
testVars{
|
||||
baseImgName: "busybox:latest",
|
||||
st: llb.Scratch(),
|
||||
cmdPrefix: `sh -c "echo -n`,
|
||||
},
|
||||
testVars{
|
||||
baseImgName: "nanoserver:latest",
|
||||
st: baseImg,
|
||||
cmdPrefix: `cmd /C "echo`,
|
||||
},
|
||||
)
|
||||
|
||||
st := v.st
|
||||
run := func(cmd string) {
|
||||
st = baseImg.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
}
|
||||
|
||||
run(fmt.Sprintf(`%s first> foo"`, v.cmdPrefix))
|
||||
run(fmt.Sprintf(`%s second> bar"`, v.cmdPrefix))
|
||||
|
||||
def, err := st.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -4780,12 +4815,13 @@ func testTarExporterSymlink(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testBuildExportWithForeignLayer(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureImageExporter)
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
// Use the Linux foreign layer test image regardless of platform
|
||||
// Foreign layer handling is about manifest/registry behavior, not container execution
|
||||
st := llb.Image("cpuguy83/buildkit-foreign:latest")
|
||||
def, err := st.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -6121,18 +6157,22 @@ func testLazyImagePush(t *testing.T, sb integration.Sandbox) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testZstdLocalCacheExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureCacheExport, workers.FeatureCacheBackendLocal)
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
busybox := llb.Image("busybox:latest")
|
||||
cmd := `sh -e -c "echo -n zstd > data"`
|
||||
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
|
||||
cmdStr := integration.UnixOrWindows(
|
||||
`sh -e -c "echo -n zstd > data"`,
|
||||
`cmd /C "echo zstd > C:\data"`,
|
||||
)
|
||||
|
||||
st := llb.Scratch()
|
||||
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
st := integration.UnixOrWindows(llb.Scratch(), llb.Image(imgName))
|
||||
st = llb.Image(imgName).Run(llb.Shlex(cmdStr), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
|
||||
def, err := st.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -6326,7 +6366,6 @@ func testUncompressedLocalCacheImportExport(t *testing.T, sb integration.Sandbox
|
||||
}
|
||||
|
||||
func testUncompressedRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb,
|
||||
workers.FeatureCacheExport,
|
||||
workers.FeatureCacheImport,
|
||||
@@ -6411,8 +6450,9 @@ func testImageManifestRegistryCacheImportExport(t *testing.T, sb integration.San
|
||||
testBasicCacheImportExport(t, sb, []CacheOptionsEntry{im}, []CacheOptionsEntry{ex})
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testZstdRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
|
||||
workers.CheckFeatureCompat(t, sb,
|
||||
workers.FeatureCacheExport,
|
||||
@@ -6454,7 +6494,8 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
|
||||
st := integration.UnixOrWindows(llb.Scratch(), llb.Image(imgName))
|
||||
|
||||
run := func(cmd string) {
|
||||
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
baseState := integration.UnixOrWindows(busybox, st)
|
||||
st = baseState.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
}
|
||||
|
||||
run(integration.UnixOrWindows(
|
||||
@@ -6515,7 +6556,6 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
|
||||
}
|
||||
|
||||
func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb,
|
||||
workers.FeatureCacheExport,
|
||||
workers.FeatureCacheImport,
|
||||
@@ -6537,7 +6577,6 @@ func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb,
|
||||
workers.FeatureCacheExport,
|
||||
workers.FeatureCacheImport,
|
||||
@@ -7613,7 +7652,7 @@ func testCopyFromEmptyImage(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
imgName := integration.UnixOrWindows(
|
||||
"busybox:latest",
|
||||
"mcr.microsoft.com/windows/nanoserver:ltsc2022",
|
||||
"nanoserver:latest",
|
||||
)
|
||||
busybox := llb.Image(imgName)
|
||||
|
||||
@@ -8018,19 +8057,37 @@ func testSourceMapFromRef(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testRmSymlink(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
// Test that if FileOp.Rm is called on a symlink, then
|
||||
// the symlink is removed rather than the target
|
||||
mnt := llb.Image("alpine").
|
||||
Run(llb.Shlex("touch /mnt/target")).
|
||||
type testVars struct {
|
||||
imgName string
|
||||
touchCmd string
|
||||
symlinkCmd string
|
||||
}
|
||||
|
||||
v := integration.UnixOrWindows(
|
||||
testVars{
|
||||
imgName: "alpine",
|
||||
touchCmd: "touch /mnt/target",
|
||||
symlinkCmd: "ln -s target /mnt/link",
|
||||
},
|
||||
testVars{
|
||||
imgName: "nanoserver:latest",
|
||||
touchCmd: "cmd /C type nul > /mnt/target",
|
||||
symlinkCmd: "cmd /c cd /d c:/mnt && mklink link target",
|
||||
},
|
||||
)
|
||||
|
||||
mnt := llb.Image(v.imgName).
|
||||
Run(llb.Shlex(v.touchCmd)).
|
||||
AddMount("/mnt", llb.Scratch())
|
||||
|
||||
mnt = llb.Image("alpine").
|
||||
Run(llb.Shlex("ln -s target /mnt/link")).
|
||||
mnt = llb.Image(v.imgName).
|
||||
Run(llb.Shlex(v.symlinkCmd)).
|
||||
AddMount("/mnt", mnt)
|
||||
|
||||
def, err := mnt.File(llb.Rm("link")).Marshal(sb.Context())
|
||||
@@ -11039,7 +11096,6 @@ func testSBOMSupplements(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testMultipleCacheExports(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureMultiCacheExport)
|
||||
c, err := New(sb.Context(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
@@ -11051,13 +11107,25 @@ func testMultipleCacheExports(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
busybox := llb.Image("busybox:latest")
|
||||
st := llb.Scratch()
|
||||
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
|
||||
busybox := llb.Image(imgName)
|
||||
st := integration.UnixOrWindows(llb.Scratch(), llb.Image(imgName))
|
||||
|
||||
run := func(cmd string) {
|
||||
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
|
||||
}
|
||||
run(`sh -c "echo -n foobar > const"`)
|
||||
run(`sh -c "cat /dev/urandom | head -c 100 | sha256sum > unique"`)
|
||||
|
||||
constCmd := integration.UnixOrWindows(
|
||||
`sh -c "echo -n foobar > const"`,
|
||||
`cmd /C echo foobar > const`,
|
||||
)
|
||||
uniqueCmd := integration.UnixOrWindows(
|
||||
`sh -c "cat /dev/urandom | head -c 100 | sha256sum > unique"`,
|
||||
`cmd /C echo %RANDOM% > unique`,
|
||||
)
|
||||
|
||||
run(constCmd)
|
||||
run(uniqueCmd)
|
||||
|
||||
def, err := st.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -11152,7 +11220,7 @@ func testMultipleCacheExports(t *testing.T, sb integration.Sandbox) {
|
||||
}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
ensureFileContents(t, filepath.Join(destDir, "const"), "foobar")
|
||||
ensureFileContents(t, filepath.Join(destDir, "const"), integration.UnixOrWindows("foobar", "foobar \r\n"))
|
||||
ensureFileContents(t, filepath.Join(destDir, "unique"), string(uniqueFile))
|
||||
}
|
||||
|
||||
@@ -11500,7 +11568,10 @@ func ensureFile(t *testing.T, path string) {
|
||||
func ensureFileContents(t *testing.T, path, expectedContents string) {
|
||||
contents, err := os.ReadFile(path)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expectedContents, string(contents))
|
||||
|
||||
actualContents := string(contents)
|
||||
require.Equal(t, expectedContents, actualContents,
|
||||
"file contents mismatch for %s\nexpected: %q\nactual: %q", path, expectedContents, actualContents)
|
||||
}
|
||||
|
||||
func makeSSHAgentSock(t *testing.T, agent agent.Agent) (p string, err error) {
|
||||
|
||||
+27
-12
@@ -46,9 +46,13 @@ func testBuildWithLocalFiles(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testBuildLocalExporter(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
st := llb.Image("busybox").
|
||||
Run(llb.Shlex("sh -c 'echo -n bar > /out/foo'"))
|
||||
img := integration.UnixOrWindows("busybox", "nanoserver:latest")
|
||||
cmdStr := integration.UnixOrWindows(
|
||||
"sh -c 'echo -n bar > /out/foo'",
|
||||
`cmd /c "echo bar > C:/out/foo"`,
|
||||
)
|
||||
|
||||
st := llb.Image(img).Run(llb.Shlex(cmdStr))
|
||||
|
||||
out := st.AddMount("/out", llb.Scratch())
|
||||
|
||||
@@ -65,18 +69,25 @@ func testBuildLocalExporter(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
dt, err := os.ReadFile(filepath.Join(tmpdir, "foo"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "bar", string(dt))
|
||||
|
||||
// in windows plain echo in cmd.exe will always append \r\n (CRLF)
|
||||
actualContent := integration.UnixOrWindows(string(dt), strings.TrimSpace(string(dt)))
|
||||
require.Equal(t, "bar", actualContent)
|
||||
}
|
||||
|
||||
func testBuildContainerdExporter(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
cdAddress := sb.ContainerdAddress()
|
||||
if cdAddress == "" {
|
||||
t.Skip("test is only for containerd worker")
|
||||
}
|
||||
|
||||
st := llb.Image("busybox").
|
||||
Run(llb.Shlex("sh -c 'echo -n bar > /foo'"))
|
||||
baseImg := integration.UnixOrWindows("busybox", "nanoserver:latest")
|
||||
cmdStr := integration.UnixOrWindows(
|
||||
"sh -c 'echo -n bar > /foo'",
|
||||
`cmd /c "echo bar > C:/foo"`,
|
||||
)
|
||||
|
||||
st := llb.Image(baseImg).Run(llb.Shlex(cmdStr))
|
||||
|
||||
rdr, err := marshal(sb.Context(), st.Root())
|
||||
require.NoError(t, err)
|
||||
@@ -102,8 +113,8 @@ func testBuildContainerdExporter(t *testing.T, sb integration.Sandbox) {
|
||||
img, err := client.GetImage(ctx, imageName)
|
||||
require.NoError(t, err)
|
||||
|
||||
// NOTE: by default, it is overlayfs
|
||||
snapshotter := "overlayfs"
|
||||
// NOTE: by default, it is overlayfs on Linux, windows on Windows
|
||||
snapshotter := integration.UnixOrWindows("overlayfs", "windows")
|
||||
if sn := sb.Snapshotter(); sn != "" {
|
||||
snapshotter = sn
|
||||
}
|
||||
@@ -113,9 +124,13 @@ func testBuildContainerdExporter(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testBuildMetadataFile(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
st := llb.Image("busybox").
|
||||
Run(llb.Shlex("sh -c 'echo -n bar > /foo'"))
|
||||
img := integration.UnixOrWindows("busybox", "nanoserver:latest")
|
||||
cmdStr := integration.UnixOrWindows(
|
||||
"sh -c 'echo -n bar > /foo'",
|
||||
`cmd /c "echo bar > C:/foo"`,
|
||||
)
|
||||
|
||||
st := llb.Image(img).Run(llb.Shlex(cmdStr))
|
||||
|
||||
rdr, err := marshal(sb.Context(), st.Root())
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -26,12 +26,11 @@ func TestCLIIntegration(t *testing.T) {
|
||||
testPrune,
|
||||
testUsage,
|
||||
),
|
||||
integration.WithMirroredImages(integration.OfficialImages("busybox:latest")),
|
||||
integration.WithMirroredImages(integration.OfficialImages(integration.UnixOrWindows("busybox:latest", "nanoserver:latest"))),
|
||||
)
|
||||
}
|
||||
|
||||
func testUsage(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
require.NoError(t, sb.Cmd().Run())
|
||||
|
||||
require.NoError(t, sb.Cmd("--help").Run())
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
func testDiskUsage(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
cmd := sb.Cmd("du")
|
||||
err := cmd.Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
func testPrune(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
cmd := sb.Cmd("prune")
|
||||
err := cmd.Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -24,10 +24,10 @@ func init() {
|
||||
}
|
||||
|
||||
func testAddChecksum(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
f.RequiresBuildctl(t)
|
||||
|
||||
baseImage := integration.UnixOrWindows("scratch", "nanoserver:latest")
|
||||
resp := &httpserver.Response{
|
||||
Etag: identity.NewID(),
|
||||
Content: []byte("content1"),
|
||||
@@ -43,9 +43,9 @@ func testAddChecksum(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=%s %s /tmp/foo
|
||||
`, digest.FromBytes(resp.Content).String(), server.URL+"/foo")
|
||||
`, baseImage, digest.FromBytes(resp.Content).String(), server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -60,11 +60,11 @@ ADD --checksum=%s %s /tmp/foo
|
||||
})
|
||||
t.Run("DigestFromEnv", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ENV DIGEST=%s
|
||||
ENV LINK=%s
|
||||
ADD --checksum=${DIGEST} ${LINK} /tmp/foo
|
||||
`, digest.FromBytes(resp.Content).String(), server.URL+"/foo")
|
||||
`, baseImage, digest.FromBytes(resp.Content).String(), server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -79,9 +79,9 @@ ADD --checksum=${DIGEST} ${LINK} /tmp/foo
|
||||
})
|
||||
t.Run("DigestMismatch", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=%s %s /tmp/foo
|
||||
`, digest.FromBytes(nil).String(), server.URL+"/foo")
|
||||
`, baseImage, digest.FromBytes(nil).String(), server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -96,9 +96,9 @@ ADD --checksum=%s %s /tmp/foo
|
||||
})
|
||||
t.Run("DigestWithKnownButUnsupportedAlgoName", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=md5:7e55db001d319a94b0b713529a756623 %s /tmp/foo
|
||||
`, server.URL+"/foo")
|
||||
`, baseImage, server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -113,9 +113,9 @@ ADD --checksum=md5:7e55db001d319a94b0b713529a756623 %s /tmp/foo
|
||||
})
|
||||
t.Run("DigestWithUnknownAlgoName", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=unknown:%s %s /tmp/foo
|
||||
`, digest.FromBytes(resp.Content).Encoded(), server.URL+"/foo")
|
||||
`, baseImage, digest.FromBytes(resp.Content).Encoded(), server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -130,9 +130,9 @@ ADD --checksum=unknown:%s %s /tmp/foo
|
||||
})
|
||||
t.Run("DigestWithoutAlgoName", func(t *testing.T) {
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=%s %s /tmp/foo
|
||||
`, digest.FromBytes(resp.Content).Encoded(), server.URL+"/foo")
|
||||
`, baseImage, digest.FromBytes(resp.Content).Encoded(), server.URL+"/foo")
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -148,9 +148,9 @@ ADD --checksum=%s %s /tmp/foo
|
||||
t.Run("NonHTTPSource", func(t *testing.T) {
|
||||
foo := []byte("local file")
|
||||
dockerfile := fmt.Appendf(nil, `
|
||||
FROM scratch
|
||||
FROM %s
|
||||
ADD --checksum=%s foo /tmp/foo
|
||||
`, digest.FromBytes(foo).String())
|
||||
`, baseImage, digest.FromBytes(foo).String())
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("foo", foo, 0600),
|
||||
|
||||
@@ -270,7 +270,6 @@ FROM second
|
||||
}
|
||||
|
||||
func testOutlineRecursiveArgs(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureFrontendOutline)
|
||||
f := getFrontend(t, sb)
|
||||
if _, ok := f.(*clientFrontend); !ok {
|
||||
|
||||
@@ -25,22 +25,25 @@ var targetsTests = integration.TestFuncs(
|
||||
)
|
||||
|
||||
func testTargetsList(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureFrontendTargets)
|
||||
f := getFrontend(t, sb)
|
||||
if _, ok := f.(*clientFrontend); !ok {
|
||||
t.Skip("only test with client frontend")
|
||||
}
|
||||
|
||||
// Use platform-appropriate base images
|
||||
baseImage1 := integration.UnixOrWindows("alpine", "nanoserver:latest")
|
||||
baseImage2 := integration.UnixOrWindows("busybox", "nanoserver:latest")
|
||||
|
||||
dockerfile := []byte(`
|
||||
# build defines stage for compiling the binary
|
||||
FROM alpine AS build
|
||||
FROM ` + baseImage1 + ` AS build
|
||||
RUN true
|
||||
|
||||
FROM busybox as second
|
||||
FROM ` + baseImage2 + ` as second
|
||||
RUN false
|
||||
|
||||
FROM alpine
|
||||
FROM ` + baseImage1 + `
|
||||
RUN false
|
||||
|
||||
# binary returns the compiled binary
|
||||
@@ -81,7 +84,7 @@ FROM second AS binary
|
||||
|
||||
target := list.Targets[0]
|
||||
require.Equal(t, "build", target.Name)
|
||||
require.Equal(t, "alpine", target.Base)
|
||||
require.Equal(t, baseImage1, target.Base)
|
||||
require.Equal(t, "defines stage for compiling the binary", target.Description)
|
||||
require.Equal(t, false, target.Default)
|
||||
require.Equal(t, int32(0), target.Location.SourceIndex)
|
||||
@@ -90,7 +93,7 @@ FROM second AS binary
|
||||
target = list.Targets[1]
|
||||
require.Equal(t, "second", target.Name)
|
||||
require.Equal(t, "", target.Description)
|
||||
require.Equal(t, "busybox", target.Base)
|
||||
require.Equal(t, baseImage2, target.Base)
|
||||
require.Equal(t, false, target.Default)
|
||||
require.Equal(t, int32(0), target.Location.SourceIndex)
|
||||
require.Equal(t, int32(6), target.Location.Ranges[0].Start.Line)
|
||||
@@ -98,7 +101,7 @@ FROM second AS binary
|
||||
target = list.Targets[2]
|
||||
require.Equal(t, "", target.Name)
|
||||
require.Equal(t, "", target.Description)
|
||||
require.Equal(t, "alpine", target.Base)
|
||||
require.Equal(t, baseImage1, target.Base)
|
||||
require.Equal(t, false, target.Default)
|
||||
require.Equal(t, int32(0), target.Location.SourceIndex)
|
||||
require.Equal(t, int32(9), target.Location.Ranges[0].Start.Line)
|
||||
|
||||
@@ -661,11 +661,11 @@ RUN [ "$(cat testfile)" == "contents0" ]
|
||||
}
|
||||
|
||||
func testExportCacheLoop(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureCacheExport, workers.FeatureCacheImport, workers.FeatureCacheBackendLocal)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM alpine as base
|
||||
RUN echo aa > /foo
|
||||
WORKDIR /bar
|
||||
@@ -679,7 +679,25 @@ RUN true
|
||||
|
||||
FROM scratch
|
||||
COPY --from=base2 /foo /f
|
||||
`)
|
||||
`,
|
||||
`
|
||||
FROM nanoserver AS base
|
||||
USER ContainerAdministrator
|
||||
RUN echo aa> foo
|
||||
WORKDIR /bar
|
||||
|
||||
FROM base AS base1
|
||||
USER ContainerAdministrator
|
||||
COPY hello.txt .
|
||||
|
||||
FROM base AS base2
|
||||
USER ContainerAdministrator
|
||||
COPY --from=base1 /bar/hello.txt .
|
||||
|
||||
FROM nanoserver
|
||||
COPY --from=base2 foo f
|
||||
`,
|
||||
))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -1253,8 +1271,9 @@ COPY --from=base /unique /
|
||||
|
||||
dt2, err = os.ReadFile(filepath.Join(destDir, "unique"))
|
||||
expectedStr := string(dt)
|
||||
expectedStr = integration.UnixOrWindows(expectedStr, expectedStr+"\r\n")
|
||||
require.NoError(t, err)
|
||||
require.NotEqual(t, integration.UnixOrWindows(expectedStr, expectedStr+"\r\n"), string(dt2))
|
||||
require.NotEqual(t, expectedStr, string(dt2))
|
||||
}
|
||||
|
||||
func testEmptyWildcard(t *testing.T, sb integration.Sandbox) {
|
||||
@@ -3986,17 +4005,22 @@ EXPOSE 2375 5000 1234/udp
|
||||
|
||||
// moby/buildkit#5505
|
||||
func testExportedHistoryFlattenArgs(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
f.RequiresBuildctl(t)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(`
|
||||
FROM busybox
|
||||
ARG foo=bar
|
||||
ARG bar=123
|
||||
ARG foo=bar2
|
||||
RUN ls /etc/
|
||||
`)
|
||||
`, `
|
||||
FROM nanoserver:latest
|
||||
ARG foo=bar
|
||||
ARG bar=123
|
||||
ARG foo=bar2
|
||||
RUN dir C:\Windows
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -4043,7 +4067,8 @@ RUN ls /etc/
|
||||
require.Contains(t, history[firstNonBase+2].CreatedBy, "ARG foo=bar2")
|
||||
|
||||
runLine := history[firstNonBase+3].CreatedBy
|
||||
require.Contains(t, runLine, "ls /etc/")
|
||||
expectedCmd := integration.UnixOrWindows("ls /etc/", "dir C:\\Windows")
|
||||
require.Contains(t, runLine, expectedCmd)
|
||||
require.NotContains(t, runLine, "ARG foo=bar")
|
||||
require.Contains(t, runLine, "RUN |2 foo=bar2 bar=123 ")
|
||||
}
|
||||
@@ -4365,7 +4390,6 @@ COPY --from=base /out /
|
||||
}
|
||||
|
||||
func testCopyInvalidChmod(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
@@ -4768,7 +4792,6 @@ COPY --from=build /dest /dest
|
||||
}
|
||||
|
||||
func testAddInvalidChmod(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
@@ -5446,8 +5469,9 @@ COPY --from=child /step* /
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureOCILayout)
|
||||
// create an image with onbuild that relies on "otherstage" when imported
|
||||
ctx := sb.Context()
|
||||
@@ -5459,13 +5483,16 @@ func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
|
||||
// create a tempdir where we will store the OCI layout
|
||||
ocidir := t.TempDir()
|
||||
|
||||
ociDockerfile := []byte(`
|
||||
ociDockerfile := integration.UnixOrWindows(`
|
||||
FROM busybox:latest
|
||||
ONBUILD COPY --from=otherstage /testfile /out/foo
|
||||
`, `
|
||||
FROM nanoserver:latest
|
||||
ONBUILD COPY --from=otherstage C:/testfile C:/out/foo
|
||||
`)
|
||||
inDir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", ociDockerfile, 0600),
|
||||
fstest.CreateFile("Dockerfile", []byte(ociDockerfile), 0600),
|
||||
)
|
||||
|
||||
f := getFrontend(t, sb)
|
||||
@@ -5513,7 +5540,7 @@ func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
|
||||
ociID := "ocione"
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows(`
|
||||
FROM alpine AS otherstage
|
||||
RUN echo -n "hello" > /testfile
|
||||
|
||||
@@ -5521,11 +5548,19 @@ func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
FROM scratch
|
||||
COPY --from=inputstage /out/foo /bar
|
||||
`, `
|
||||
FROM nanoserver:latest AS otherstage
|
||||
RUN cmd /S /C "echo hello>C:/testfile"
|
||||
|
||||
FROM base AS inputstage
|
||||
|
||||
FROM nanoserver:latest
|
||||
COPY --from=inputstage C:/out/foo C:/bar
|
||||
`)
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateFile("Dockerfile", []byte(dockerfile), 0600),
|
||||
)
|
||||
|
||||
destDir := t.TempDir()
|
||||
@@ -5552,15 +5587,19 @@ func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
dt, err := os.ReadFile(filepath.Join(destDir, "bar"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("hello"), dt)
|
||||
|
||||
// On Windows, echo adds \r\n line ending, on Unix it's just the content
|
||||
expected := integration.UnixOrWindows([]byte("hello"), []byte("hello\r\n"))
|
||||
require.Equal(t, expected, dt)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testOnBuildInheritedStageRun(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows(`
|
||||
FROM busybox AS base
|
||||
ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
|
||||
|
||||
@@ -5569,11 +5608,20 @@ RUN cp /out/foo /out/bar
|
||||
|
||||
FROM scratch
|
||||
COPY --from=mid /out/bar /
|
||||
`, `
|
||||
FROM nanoserver:latest AS base
|
||||
ONBUILD RUN cmd /S /C "mkdir C:\out && echo 11 > C:\out\foo"
|
||||
|
||||
FROM base AS mid
|
||||
RUN cmd /S /C "copy C:\out\foo C:\out\bar"
|
||||
|
||||
FROM nanoserver:latest
|
||||
COPY --from=mid C:\\out\\bar /bar
|
||||
`)
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateFile("Dockerfile", []byte(dockerfile), 0600),
|
||||
)
|
||||
|
||||
c, err := client.New(sb.Context(), sb.Address())
|
||||
@@ -5598,15 +5646,17 @@ COPY --from=mid /out/bar /
|
||||
|
||||
dt, err := os.ReadFile(filepath.Join(destDir, "bar"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "11", string(dt))
|
||||
expected := integration.UnixOrWindows("11", "11\r\n")
|
||||
require.Equal(t, expected, string(dt))
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testOnBuildInheritedStageWithFrom(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM alpine AS src
|
||||
RUN mkdir -p /in && echo -n 12 > /in/file
|
||||
|
||||
@@ -5618,7 +5668,19 @@ RUN cp /out/foo /out/bar
|
||||
|
||||
FROM scratch
|
||||
COPY --from=mid /out/bar /
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest AS src
|
||||
RUN cmd /S /C "mkdir C:\in && echo 12 > C:\in\file"
|
||||
|
||||
FROM nanoserver:latest AS base
|
||||
ONBUILD COPY --from=src C:\in\file C:\out\foo
|
||||
|
||||
FROM base AS mid
|
||||
RUN cmd /S /C "copy C:\out\foo C:\out\bar"
|
||||
|
||||
FROM nanoserver:latest
|
||||
COPY --from=mid C:\out\bar /bar
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -5647,7 +5709,8 @@ COPY --from=mid /out/bar /
|
||||
|
||||
dt, err := os.ReadFile(filepath.Join(destDir, "bar"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "12", string(dt))
|
||||
expected := integration.UnixOrWindows("12", "12\r\n")
|
||||
require.Equal(t, expected, string(dt))
|
||||
}
|
||||
|
||||
func testOnBuildNewDeps(t *testing.T, sb integration.Sandbox) {
|
||||
@@ -5798,8 +5861,9 @@ ONBUILD RUN --mount=type=bind,target=/in,from=inputstage mkdir /out && cat /in/f
|
||||
require.Equal(t, "bar3", string(dt))
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testOnBuildWithCacheMount(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
@@ -5809,10 +5873,13 @@ func testOnBuildWithCacheMount(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM busybox
|
||||
ONBUILD RUN --mount=type=cache,target=/cache echo -n 42 >> /cache/foo && echo -n 11 >> /bar
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest
|
||||
ONBUILD RUN --mount=type=cache,target=C:\cache mkdir C:\cache && echo 42 > C:\cache\foo && echo 11 > C:\bar
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -5842,9 +5909,14 @@ ONBUILD RUN --mount=type=cache,target=/cache echo -n 42 >> /cache/foo && echo -n
|
||||
}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile = fmt.Appendf(nil, `FROM %s
|
||||
dockerfile = integration.UnixOrWindows(
|
||||
fmt.Appendf(nil, `FROM %s
|
||||
RUN --mount=type=cache,target=/cache [ "$(cat /cache/foo)" = "42" ] && [ "$(cat /bar)" = "11" ]
|
||||
`, target)
|
||||
`, target),
|
||||
fmt.Appendf(nil, `FROM %s
|
||||
RUN --mount=type=cache,target=C:\cache type C:\cache\foo | findstr "42" && type C:\bar | findstr "11"
|
||||
`, target),
|
||||
)
|
||||
|
||||
dir = integration.Tmpdir(
|
||||
t,
|
||||
@@ -5988,8 +6060,9 @@ COPY --from=base arch /
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testImageManifestCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureCacheExport, workers.FeatureCacheBackendLocal)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
@@ -5999,7 +6072,7 @@ func testImageManifestCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM busybox AS base
|
||||
COPY foo const
|
||||
#RUN echo -n foobar > const
|
||||
@@ -6007,7 +6080,15 @@ RUN cat /dev/urandom | head -c 100 | sha256sum > unique
|
||||
FROM scratch
|
||||
COPY --from=base const /
|
||||
COPY --from=base unique /
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest AS base
|
||||
COPY foo const
|
||||
# RUN echo foobar > const
|
||||
RUN echo %RANDOM%%RANDOM% > unique
|
||||
FROM nanoserver:latest
|
||||
COPY --from=base const C:/
|
||||
COPY --from=base unique C:/
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -6091,8 +6172,9 @@ COPY --from=base unique /
|
||||
require.Equal(t, string(dt), string(dt2))
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureCacheExport, workers.FeatureCacheBackendLocal)
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
@@ -6102,7 +6184,7 @@ func testCacheImportExport(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM busybox AS base
|
||||
COPY foo const
|
||||
#RUN echo -n foobar > const
|
||||
@@ -6110,7 +6192,15 @@ RUN cat /dev/urandom | head -c 100 | sha256sum > unique
|
||||
FROM scratch
|
||||
COPY --from=base const /
|
||||
COPY --from=base unique /
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest AS base
|
||||
COPY foo const
|
||||
# RUN echo foobar > const
|
||||
RUN echo %RANDOM%%RANDOM% > unique
|
||||
FROM nanoserver:latest
|
||||
COPY --from=base const C:/
|
||||
COPY --from=base unique C:/
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -6257,8 +6347,9 @@ RUN echo bar > bar
|
||||
require.Equal(t, img.Target, img2.Target)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testImportExportReproducibleIDs(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
cdAddress := sb.ContainerdAddress()
|
||||
if cdAddress == "" {
|
||||
t.Skip("test requires containerd worker")
|
||||
@@ -6272,12 +6363,17 @@ func testImportExportReproducibleIDs(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM busybox
|
||||
ENV foo=bar
|
||||
COPY foo /
|
||||
RUN echo bar > bar
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest
|
||||
ENV foo=bar
|
||||
COPY foo C:/
|
||||
RUN echo bar > bar
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -6344,11 +6440,12 @@ RUN echo bar > bar
|
||||
require.Equal(t, img.Target, img2.Target)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testNoCache(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM busybox AS s0
|
||||
RUN cat /dev/urandom | head -c 100 | sha256sum | tee unique
|
||||
FROM busybox AS s1
|
||||
@@ -6356,7 +6453,15 @@ RUN cat /dev/urandom | head -c 100 | sha256sum | tee unique2
|
||||
FROM scratch
|
||||
COPY --from=s0 unique /
|
||||
COPY --from=s1 unique2 /
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest AS s0
|
||||
RUN echo %RANDOM%%RANDOM%%RANDOM% > unique
|
||||
FROM nanoserver:latest AS s1
|
||||
RUN echo %RANDOM%%RANDOM%%RANDOM% > unique2
|
||||
FROM nanoserver:latest
|
||||
COPY --from=s0 unique C:/
|
||||
COPY --from=s1 unique2 C:/
|
||||
`))
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -6954,7 +7059,6 @@ COPY badfile /
|
||||
}
|
||||
|
||||
func testFrontendInputs(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
c, err := client.New(sb.Context(), sb.Address())
|
||||
@@ -6963,9 +7067,15 @@ func testFrontendInputs(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
destDir := t.TempDir()
|
||||
|
||||
outMount := llb.Image("busybox").Run(
|
||||
llb.Shlex(`sh -c "cat /dev/urandom | head -c 100 | sha256sum > /out/foo"`),
|
||||
).AddMount("/out", llb.Scratch())
|
||||
baseImage := integration.UnixOrWindows("busybox", "nanoserver:latest")
|
||||
cmd := integration.UnixOrWindows(
|
||||
`sh -c "cat /dev/urandom | head -c 100 | sha256sum > /out/foo"`,
|
||||
`cmd /c "echo %RANDOM%%RANDOM%%RANDOM%%RANDOM% > C:\\out\\foo"`,
|
||||
)
|
||||
|
||||
mountPath := integration.UnixOrWindows("/out", "C:/out")
|
||||
|
||||
outMount := llb.Image(baseImage).Run(llb.Shlex(cmd)).AddMount(mountPath, llb.Scratch())
|
||||
|
||||
def, err := outMount.Marshal(sb.Context())
|
||||
require.NoError(t, err)
|
||||
@@ -6983,10 +7093,13 @@ func testFrontendInputs(t *testing.T, sb integration.Sandbox) {
|
||||
expected, err := os.ReadFile(filepath.Join(destDir, "foo"))
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := integration.UnixOrWindows([]byte(`
|
||||
FROM scratch
|
||||
COPY foo foo2
|
||||
`)
|
||||
`), []byte(`
|
||||
FROM nanoserver:latest
|
||||
COPY foo foo2
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -7348,20 +7461,41 @@ COPY --from=base /out /
|
||||
}
|
||||
|
||||
func testStepNames(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM busybox AS base
|
||||
WORKDIR /out
|
||||
RUN echo "base" > base
|
||||
FROM scratch
|
||||
COPY --from=base --chmod=0644 /out /out
|
||||
`)
|
||||
`,
|
||||
`
|
||||
FROM nanoserver:latest AS base
|
||||
WORKDIR /out
|
||||
RUN echo base > base
|
||||
FROM nanoserver:latest
|
||||
COPY --from=base --chmod=0644 /out /out
|
||||
`,
|
||||
))
|
||||
|
||||
expectedRunStep := integration.UnixOrWindows(
|
||||
`[base 3/3] RUN echo "base" > base`,
|
||||
`[base 3/3] RUN echo base > base`,
|
||||
)
|
||||
|
||||
// Step numbering differs between platforms due to base image characteristics:
|
||||
// - Unix uses 'scratch' (empty image) so COPY is step 1/1
|
||||
// - Windows uses 'nanoserver' (full image) which has internal setup steps, making COPY step 2/2
|
||||
expectedCopyStep := integration.UnixOrWindows(
|
||||
`[stage-1 1/1] COPY --from=base --chmod=0644 /out /out`,
|
||||
`[stage-1 2/2] COPY --from=base --chmod=0644 /out /out`,
|
||||
)
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -7396,9 +7530,9 @@ COPY --from=base --chmod=0644 /out /out
|
||||
visited[vtx.Name] = struct{}{}
|
||||
t.Logf("step: %q", vtx.Name)
|
||||
switch vtx.Name {
|
||||
case `[base 3/3] RUN echo "base" > base`:
|
||||
case expectedRunStep:
|
||||
hasRun = true
|
||||
case `[stage-1 1/1] COPY --from=base --chmod=0644 /out /out`:
|
||||
case expectedCopyStep:
|
||||
hasCopy = true
|
||||
}
|
||||
}
|
||||
@@ -7666,8 +7800,9 @@ func testNamedImageContextPlatform(t *testing.T, sb integration.Sandbox) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testNamedImageContextTimestamps(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
ctx := sb.Context()
|
||||
|
||||
@@ -7683,10 +7818,17 @@ func testNamedImageContextTimestamps(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM alpine
|
||||
RUN echo foo >> /test
|
||||
`)
|
||||
`,
|
||||
`
|
||||
FROM nanoserver:latest
|
||||
RUN echo foo >> C:\test
|
||||
`,
|
||||
))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -7715,15 +7857,29 @@ RUN echo foo >> /test
|
||||
img, err := testutil.ReadImage(sb.Context(), provider, desc)
|
||||
require.NoError(t, err)
|
||||
|
||||
dockerfileDerived := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM alpine
|
||||
RUN echo foo >> /test
|
||||
`,
|
||||
`
|
||||
FROM nanoserver
|
||||
RUN echo foo >> C:\test
|
||||
`,
|
||||
))
|
||||
|
||||
dirDerived := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateFile("Dockerfile", dockerfileDerived, 0600),
|
||||
)
|
||||
|
||||
targetDerived := registry + "/buildkit/testnamedimagecontexttimestampsderived:latest"
|
||||
|
||||
contextName := integration.UnixOrWindows("alpine", "nanoserver")
|
||||
|
||||
_, err = f.Solve(sb.Context(), c, client.SolveOpt{
|
||||
FrontendAttrs: map[string]string{
|
||||
"context:alpine": "docker-image://" + target,
|
||||
"context:" + contextName: "docker-image://" + target,
|
||||
},
|
||||
LocalMounts: map[string]fsutil.FS{
|
||||
dockerui.DefaultLocalNameDockerfile: dirDerived,
|
||||
@@ -8240,31 +8396,47 @@ FROM nonexistent AS base
|
||||
require.Contains(t, cfg.Config.Env, "foo=bar")
|
||||
}
|
||||
|
||||
// TODO: Re-enable the skipped test on Windows (see issue #6296)
|
||||
func testNamedInputContext(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
integration.SkipOnPlatform(t, "windows", "This test passed locally on windows, but failed on github action")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM alpine
|
||||
ENV FOO=bar
|
||||
RUN echo first > /out
|
||||
`)
|
||||
`,
|
||||
`
|
||||
FROM nanoserver:latest
|
||||
ENV FOO=bar
|
||||
RUN echo first>C:\out
|
||||
`,
|
||||
))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
)
|
||||
|
||||
dockerfile2 := []byte(`
|
||||
dockerfile2 := []byte(integration.UnixOrWindows(
|
||||
`
|
||||
FROM base AS build
|
||||
RUN echo "foo is $FOO" > /foo
|
||||
FROM scratch
|
||||
COPY --from=build /foo /out /
|
||||
`)
|
||||
`,
|
||||
`
|
||||
FROM base AS build
|
||||
RUN echo foo is %FOO%>C:\foo
|
||||
FROM nanoserver:latest
|
||||
COPY --from=build C:\foo C:\out .
|
||||
`,
|
||||
))
|
||||
|
||||
dir2 := integration.Tmpdir(
|
||||
t,
|
||||
@@ -8341,11 +8513,17 @@ COPY --from=build /foo /out /
|
||||
|
||||
dt, err := os.ReadFile(filepath.Join(destDir, "out"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "first\n", string(dt))
|
||||
|
||||
expectedOutContent := integration.UnixOrWindows("first\n", "first\r\n")
|
||||
|
||||
require.Equal(t, expectedOutContent, string(dt))
|
||||
|
||||
dt, err = os.ReadFile(filepath.Join(destDir, "foo"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "foo is bar\n", string(dt))
|
||||
|
||||
expectedFooContent := integration.UnixOrWindows("foo is bar\n", "foo is bar\r\n")
|
||||
|
||||
require.Equal(t, expectedFooContent, string(dt))
|
||||
}
|
||||
|
||||
func testNamedMultiplatformInputContext(t *testing.T, sb integration.Sandbox) {
|
||||
@@ -9592,7 +9770,6 @@ COPY --from=base /foo /foo
|
||||
}
|
||||
|
||||
func testBaseImagePlatformMismatch(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
ctx := sb.Context()
|
||||
|
||||
@@ -9608,10 +9785,13 @@ func testBaseImagePlatformMismatch(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(`
|
||||
FROM scratch
|
||||
COPY foo /foo
|
||||
`)
|
||||
`, `
|
||||
FROM nanoserver:latest
|
||||
COPY foo C:/foo
|
||||
`))
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
@@ -9619,10 +9799,14 @@ COPY foo /foo
|
||||
)
|
||||
|
||||
// choose target platform that is different from the current platform
|
||||
targetPlatform := runtime.GOOS + "/arm64"
|
||||
if runtime.GOARCH == "arm64" {
|
||||
targetPlatform = runtime.GOOS + "/amd64"
|
||||
}
|
||||
targetPlatform := integration.UnixOrWindows(
|
||||
runtime.GOOS+"/"+map[bool]string{true: "amd64", false: "arm64"}[runtime.GOARCH == "arm64"],
|
||||
"windows/amd64",
|
||||
)
|
||||
expectedCurrentPlatform := integration.UnixOrWindows(
|
||||
runtime.GOOS+"/"+runtime.GOARCH,
|
||||
"windows/arm64", // Force different expected platform
|
||||
)
|
||||
|
||||
target := registry + "/buildkit/testbaseimageplatform:latest"
|
||||
_, err = f.Solve(sb.Context(), c, client.SolveOpt{
|
||||
@@ -9650,19 +9834,37 @@ FROM %s
|
||||
ENV foo=bar
|
||||
`, target)
|
||||
|
||||
checkLinterWarnings(t, sb, &lintTestParams{
|
||||
Dockerfile: dockerfile,
|
||||
Warnings: []expectedLintWarning{
|
||||
{
|
||||
RuleName: "InvalidBaseImagePlatform",
|
||||
Description: "Base image platform does not match expected target platform",
|
||||
Detail: fmt.Sprintf("Base image %s was pulled with platform %q, expected %q for current build", target, targetPlatform, runtime.GOOS+"/"+runtime.GOARCH),
|
||||
Level: 1,
|
||||
Line: 2,
|
||||
},
|
||||
integration.UnixOrWindows(
|
||||
func() {
|
||||
// Unix platforms use simple format like "linux/amd64"
|
||||
checkLinterWarnings(t, sb, &lintTestParams{
|
||||
Dockerfile: dockerfile,
|
||||
Warnings: []expectedLintWarning{
|
||||
{
|
||||
RuleName: "InvalidBaseImagePlatform",
|
||||
Description: "Base image platform does not match expected target platform",
|
||||
Detail: fmt.Sprintf("Base image %s was pulled with platform %q, expected %q for current build", target, targetPlatform, expectedCurrentPlatform),
|
||||
Level: 1,
|
||||
Line: 2,
|
||||
},
|
||||
},
|
||||
FrontendAttrs: map[string]string{
|
||||
"platform": expectedCurrentPlatform, // Explicitly set different platform to trigger mismatch
|
||||
},
|
||||
})
|
||||
},
|
||||
FrontendAttrs: map[string]string{},
|
||||
})
|
||||
func() {
|
||||
// Windows platforms include OS version like "windows(10.0.20348.4171)/amd64"
|
||||
// Use StreamBuildErrRegexp to match the pattern instead of exact Detail
|
||||
checkLinterWarnings(t, sb, &lintTestParams{
|
||||
Dockerfile: dockerfile,
|
||||
StreamBuildErrRegexp: regexp.MustCompile(fmt.Sprintf(`InvalidBaseImagePlatform: Base image %s was pulled with platform "windows\([^)]+\)/amd64", expected "%s" for current build \(line 2\)`, regexp.QuoteMeta(target), expectedCurrentPlatform)),
|
||||
FrontendAttrs: map[string]string{
|
||||
"platform": expectedCurrentPlatform, // Explicitly set different platform to trigger mismatch
|
||||
},
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func testHistoryError(t *testing.T, sb integration.Sandbox) {
|
||||
@@ -10013,7 +10215,6 @@ EOF
|
||||
}
|
||||
|
||||
func testMaintainBaseOSVersion(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
|
||||
ctx := sb.Context()
|
||||
@@ -10026,7 +10227,7 @@ func testMaintainBaseOSVersion(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
p1 := ocispecs.Platform{
|
||||
OS: "windows",
|
||||
OSVersion: "10.20.30",
|
||||
OSVersion: "10.0.20348.1006",
|
||||
Architecture: "amd64",
|
||||
}
|
||||
p1Str := platforms.FormatAll(p1)
|
||||
@@ -10038,13 +10239,19 @@ func testMaintainBaseOSVersion(t *testing.T, sb integration.Sandbox) {
|
||||
require.NoError(t, err)
|
||||
target := registry + "/buildkit/testplatformwithosversion-1:latest"
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(`
|
||||
FROM scratch
|
||||
ARG TARGETPLATFORM
|
||||
COPY <<EOF /platform
|
||||
${TARGETPLATFORM}
|
||||
EOF
|
||||
`)
|
||||
`, `
|
||||
FROM nanoserver:latest
|
||||
ARG TARGETPLATFORM
|
||||
COPY <<EOF C:\platform
|
||||
${TARGETPLATFORM}
|
||||
EOF
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
@@ -10081,12 +10288,17 @@ EOF
|
||||
require.Len(t, info.Images, 1)
|
||||
require.Equal(t, info.Images[0].Img.OSVersion, p1.OSVersion)
|
||||
|
||||
dockerfile = fmt.Appendf(nil, `
|
||||
dockerfile = []byte(integration.UnixOrWindows(fmt.Sprintf(`
|
||||
FROM %s
|
||||
COPY <<EOF /other
|
||||
hello
|
||||
EOF
|
||||
`, target)
|
||||
`, target), fmt.Sprintf(`
|
||||
FROM %s
|
||||
COPY <<EOF C:/other
|
||||
hello
|
||||
EOF
|
||||
`, target)))
|
||||
|
||||
dir = integration.Tmpdir(
|
||||
t,
|
||||
@@ -10126,7 +10338,6 @@ EOF
|
||||
}
|
||||
|
||||
func testTargetMistype(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
|
||||
|
||||
ctx := sb.Context()
|
||||
@@ -10137,13 +10348,19 @@ func testTargetMistype(t *testing.T, sb integration.Sandbox) {
|
||||
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
dockerfile := []byte(integration.UnixOrWindows(`
|
||||
FROM scratch AS build
|
||||
COPY Dockerfile /out
|
||||
|
||||
FROM scratch
|
||||
COPY --from=build /out /
|
||||
`)
|
||||
`, `
|
||||
FROM nanoserver:latest AS build
|
||||
COPY Dockerfile C:\out
|
||||
|
||||
FROM nanoserver:latest
|
||||
COPY --from=build C:\out C:\
|
||||
`))
|
||||
|
||||
dir := integration.Tmpdir(
|
||||
t,
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
)
|
||||
|
||||
func testErrorsSourceMap(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
tcases := []struct {
|
||||
|
||||
@@ -60,7 +60,6 @@ func testReturnNil(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testRefReadFile(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
@@ -125,7 +124,6 @@ func testRefReadFile(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testRefReadDir(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
@@ -241,7 +239,6 @@ func testRefReadDir(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testRefStatFile(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
@@ -294,7 +291,6 @@ func testRefStatFile(t *testing.T, sb integration.Sandbox) {
|
||||
}
|
||||
|
||||
func testRefEvaluate(t *testing.T, sb integration.Sandbox) {
|
||||
integration.SkipOnPlatform(t, "windows")
|
||||
ctx := sb.Context()
|
||||
|
||||
c, err := client.New(ctx, sb.Address())
|
||||
|
||||
@@ -531,7 +531,7 @@ func prepareValueMatrix(tc testConf) []matrixValue {
|
||||
}
|
||||
|
||||
// Skips tests on platform
|
||||
func SkipOnPlatform(t *testing.T, goos string) {
|
||||
func SkipOnPlatform(t *testing.T, goos string, reason ...string) {
|
||||
skip := false
|
||||
// support for negation
|
||||
if after, ok := strings.CutPrefix(goos, "!"); ok {
|
||||
@@ -542,7 +542,11 @@ func SkipOnPlatform(t *testing.T, goos string) {
|
||||
}
|
||||
|
||||
if skip {
|
||||
t.Skipf("Skipped on %s", goos)
|
||||
if len(reason) > 0 {
|
||||
t.Skipf("Skipped on %s: %s", goos, strings.Join(reason, " "))
|
||||
} else {
|
||||
t.Skipf("Skipped on %s", goos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user