Skip to content

Commit e91be04

Browse files
authored
Merge pull request #5474 from profnandaa/tests-client-int-test-setup
tests: client: set up for wcow integration tests
2 parents 354f2d1 + dfe57c3 commit e91be04

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

client/client_test.go

+26-19
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"os"
2020
"path"
2121
"path/filepath"
22-
"runtime"
2322
"strconv"
2423
"strings"
2524
"syscall"
@@ -229,15 +228,21 @@ func TestIntegration(t *testing.T) {
229228
}
230229

231230
func testIntegration(t *testing.T, funcs ...func(t *testing.T, sb integration.Sandbox)) {
232-
mirroredImages := integration.OfficialImages("busybox:latest", "alpine:latest")
233-
mirroredImages["tonistiigi/test:nolayers"] = "docker.io/tonistiigi/test:nolayers"
234-
mirroredImages["cpuguy83/buildkit-foreign:latest"] = "docker.io/cpuguy83/buildkit-foreign:latest"
231+
mirroredImagesUnix := integration.OfficialImages("busybox:latest", "alpine:latest")
232+
mirroredImagesUnix["tonistiigi/test:nolayers"] = "docker.io/tonistiigi/test:nolayers"
233+
mirroredImagesUnix["cpuguy83/buildkit-foreign:latest"] = "docker.io/cpuguy83/buildkit-foreign:latest"
234+
mirroredImagesWin := integration.OfficialImages("nanoserver:latest", "nanoserver:plus")
235+
236+
mirroredImages := integration.UnixOrWindows(mirroredImagesUnix, mirroredImagesWin)
235237
mirrors := integration.WithMirroredImages(mirroredImages)
236238

237239
tests := integration.TestFuncs(funcs...)
238240
tests = append(tests, diffOpTestCases()...)
239241
integration.Run(t, tests, mirrors)
240242

243+
// the rest of the tests are meant for non-Windows, skipping on Windows.
244+
integration.SkipOnPlatform(t, "windows")
245+
241246
integration.Run(t, integration.TestFuncs(
242247
testSecurityMode,
243248
testSecurityModeSysfs,
@@ -260,16 +265,14 @@ func testIntegration(t *testing.T, funcs ...func(t *testing.T, sb integration.Sa
260265
}),
261266
)
262267

263-
if runtime.GOOS != "windows" {
264-
integration.Run(
265-
t,
266-
integration.TestFuncs(testBridgeNetworkingDNSNoRootless),
267-
mirrors,
268-
integration.WithMatrix("netmode", map[string]interface{}{
269-
"dns": bridgeDNSNetwork,
270-
}),
271-
)
272-
}
268+
integration.Run(
269+
t,
270+
integration.TestFuncs(testBridgeNetworkingDNSNoRootless),
271+
mirrors,
272+
integration.WithMatrix("netmode", map[string]interface{}{
273+
"dns": bridgeDNSNetwork,
274+
}),
275+
)
273276
}
274277

275278
func newContainerd(cdAddress string) (*containerd.Client, error) {
@@ -414,7 +417,6 @@ func testHostNetworking(t *testing.T, sb integration.Sandbox) {
414417
}
415418

416419
func testExportedImageLabels(t *testing.T, sb integration.Sandbox) {
417-
integration.SkipOnPlatform(t, "windows")
418420
c, err := New(sb.Context(), sb.Address())
419421
require.NoError(t, err)
420422
defer c.Close()
@@ -426,7 +428,14 @@ func testExportedImageLabels(t *testing.T, sb integration.Sandbox) {
426428

427429
ctx := sb.Context()
428430

429-
def, err := llb.Image("busybox").Run(llb.Shlexf("echo foo > /foo")).Marshal(ctx)
431+
imgName := integration.UnixOrWindows("busybox", "nanoserver")
432+
prefix := integration.UnixOrWindows(
433+
"",
434+
"cmd /C ", // TODO(profnandaa): currently needs the shell prefix, to be fixed
435+
)
436+
def, err := llb.Image(imgName).
437+
Run(llb.Shlexf(fmt.Sprintf("%secho foo > /foo", prefix))).
438+
Marshal(ctx)
430439
require.NoError(t, err)
431440

432441
target := "docker.io/buildkit/build/exporter:labels"
@@ -7766,9 +7775,7 @@ func chainRunShells(base llb.State, cmdss ...[]string) llb.State {
77667775
}
77677776

77687777
func requiresLinux(t *testing.T) {
7769-
if runtime.GOOS != "linux" {
7770-
t.Skipf("unsupported GOOS: %s", runtime.GOOS)
7771-
}
7778+
integration.SkipOnPlatform(t, "!linux")
77727779
}
77737780

77747781
// ensurePruneAll tries to ensure Prune completes with retries.

util/testutil/integration/run.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,16 @@ func prepareValueMatrix(tc testConf) []matrixValue {
427427

428428
// Skips tests on platform
429429
func SkipOnPlatform(t *testing.T, goos string) {
430-
if runtime.GOOS == goos {
430+
skip := false
431+
// support for negation
432+
if strings.HasPrefix(goos, "!") {
433+
goos = strings.TrimPrefix(goos, "!")
434+
skip = runtime.GOOS != goos
435+
} else {
436+
skip = runtime.GOOS == goos
437+
}
438+
439+
if skip {
431440
t.Skipf("Skipped on %s", goos)
432441
}
433442
}

0 commit comments

Comments
 (0)