Skip to content

Commit c234dd9

Browse files
authored
Merge pull request moby#5382 from danielGithinji/integration-tests
tests: frontend/dockerfile: update integration tests for windows/wcow
2 parents 83b43c6 + 3f9afc0 commit c234dd9

File tree

1 file changed

+72
-29
lines changed

1 file changed

+72
-29
lines changed

frontend/dockerfile/dockerfile_test.go

+72-29
Original file line numberDiff line numberDiff line change
@@ -1372,13 +1372,18 @@ RUN [ "$(stat -c "%U %G" /dest01)" == "user01 user" ]
13721372
}
13731373

13741374
func testCopyThroughSymlinkContext(t *testing.T, sb integration.Sandbox) {
1375-
integration.SkipOnPlatform(t, "windows")
13761375
f := getFrontend(t, sb)
13771376

1378-
dockerfile := []byte(`
1377+
dockerfile := []byte(integration.UnixOrWindows(
1378+
`
13791379
FROM scratch
13801380
COPY link/foo .
1381-
`)
1381+
`,
1382+
`
1383+
FROM nanoserver AS build
1384+
COPY link/foo .
1385+
`,
1386+
))
13821387

13831388
dir := integration.Tmpdir(
13841389
t,
@@ -1497,14 +1502,20 @@ COPY . /
14971502
}
14981503

14991504
func testIgnoreEntrypoint(t *testing.T, sb integration.Sandbox) {
1500-
integration.SkipOnPlatform(t, "windows")
15011505
f := getFrontend(t, sb)
15021506

1503-
dockerfile := []byte(`
1507+
dockerfile := []byte(integration.UnixOrWindows(
1508+
`
15041509
FROM busybox
15051510
ENTRYPOINT ["/nosuchcmd"]
15061511
RUN ["ls"]
1507-
`)
1512+
`,
1513+
`
1514+
FROM nanoserver AS build
1515+
ENTRYPOINT ["nosuchcmd.exe"]
1516+
RUN dir
1517+
`,
1518+
))
15081519

15091520
dir := integration.Tmpdir(
15101521
t,
@@ -1525,10 +1536,10 @@ RUN ["ls"]
15251536
}
15261537

15271538
func testQuotedMetaArgs(t *testing.T, sb integration.Sandbox) {
1528-
integration.SkipOnPlatform(t, "windows")
15291539
f := getFrontend(t, sb)
15301540

1531-
dockerfile := []byte(`
1541+
dockerfile := []byte(integration.UnixOrWindows(
1542+
`
15321543
ARG a1="box"
15331544
ARG a2="$a1-foo"
15341545
FROM busy$a1 AS build
@@ -1537,7 +1548,19 @@ ARG a3="bar-$a2"
15371548
RUN echo -n $a3 > /out
15381549
FROM scratch
15391550
COPY --from=build /out .
1540-
`)
1551+
`,
1552+
`
1553+
ARG a1="server"
1554+
ARG a2="$a1-foo"
1555+
FROM nano$a1 AS build
1556+
USER ContainerAdministrator
1557+
ARG a2
1558+
ARG a3="bar-$a2"
1559+
RUN echo %a3% > /out
1560+
FROM nanoserver
1561+
COPY --from=build /out .
1562+
`,
1563+
))
15411564

15421565
dir := integration.Tmpdir(
15431566
t,
@@ -1566,7 +1589,10 @@ COPY --from=build /out .
15661589

15671590
dt, err := os.ReadFile(filepath.Join(destDir, "out"))
15681591
require.NoError(t, err)
1569-
require.Equal(t, "bar-box-foo", string(dt))
1592+
1593+
testString := string([]byte(integration.UnixOrWindows("bar-box-foo", "bar-server-foo \r\n")))
1594+
1595+
require.Equal(t, testString, string(dt))
15701596
}
15711597

15721598
func testGlobalArgErrors(t *testing.T, sb integration.Sandbox) {
@@ -6641,14 +6667,19 @@ COPY Dockerfile Dockerfile
66416667

66426668
// moby/buildkit#1301
66436669
func testDockerfileCheckHostname(t *testing.T, sb integration.Sandbox) {
6644-
integration.SkipOnPlatform(t, "windows")
66456670
f := getFrontend(t, sb)
6646-
dockerfile := []byte(`
6671+
dockerfile := []byte(integration.UnixOrWindows(
6672+
`
66476673
FROM busybox
66486674
RUN cat /etc/hosts | grep foo
66496675
RUN echo $HOSTNAME | grep foo
66506676
RUN echo $(hostname) | grep foo
6651-
`)
6677+
`,
6678+
`
6679+
FROM nanoserver
6680+
RUN reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname | findstr "foo"
6681+
`,
6682+
))
66526683

66536684
dir := integration.Tmpdir(
66546685
t,
@@ -6699,11 +6730,8 @@ RUN echo $(hostname) | grep foo
66996730
}
67006731

67016732
func testEmptyStages(t *testing.T, sb integration.Sandbox) {
6702-
integration.SkipOnPlatform(t, "windows")
67036733
f := getFrontend(t, sb)
6704-
dockerfile := []byte(`
6705-
ARG foo=bar
6706-
`)
6734+
dockerfile := []byte(`ARG foo=bar`)
67076735

67086736
dir := integration.Tmpdir(
67096737
t,
@@ -7022,7 +7050,6 @@ COPY --from=base /env_foobar /
70227050
}
70237051

70247052
func testNamedImageContextPlatform(t *testing.T, sb integration.Sandbox) {
7025-
integration.SkipOnPlatform(t, "windows")
70267053
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
70277054
ctx := sb.Context()
70287055

@@ -7037,7 +7064,13 @@ func testNamedImageContextPlatform(t *testing.T, sb integration.Sandbox) {
70377064
require.NoError(t, err)
70387065

70397066
// Build a base image and force buildkit to generate a manifest list.
7040-
dockerfile := []byte(`FROM --platform=$BUILDPLATFORM alpine:latest`)
7067+
baseImage := integration.UnixOrWindows(
7068+
"alpine",
7069+
"nanoserver",
7070+
)
7071+
7072+
dockerfile := []byte(fmt.Sprintf(`FROM --platform=$BUILDPLATFORM %s:latest`, baseImage))
7073+
70417074
target := registry + "/buildkit/testnamedimagecontextplatform:latest"
70427075

70437076
dir := integration.Tmpdir(
@@ -7067,10 +7100,10 @@ func testNamedImageContextPlatform(t *testing.T, sb integration.Sandbox) {
70677100
}, nil)
70687101
require.NoError(t, err)
70697102

7070-
dockerfile = []byte(`
7071-
FROM --platform=$BUILDPLATFORM busybox AS target
7072-
RUN echo hello
7073-
`)
7103+
dockerfile = []byte(fmt.Sprintf(`
7104+
FROM --platform=$BUILDPLATFORM %s AS target
7105+
RUN echo hello
7106+
`, baseImage))
70747107

70757108
dir = integration.Tmpdir(
70767109
t,
@@ -7181,19 +7214,20 @@ RUN echo foo >> /test
71817214
}
71827215

71837216
func testNamedImageContextScratch(t *testing.T, sb integration.Sandbox) {
7184-
integration.SkipOnPlatform(t, "windows")
71857217
ctx := sb.Context()
71867218

71877219
c, err := client.New(ctx, sb.Address())
71887220
require.NoError(t, err)
71897221
defer c.Close()
71907222

7191-
dockerfile := []byte(`
7192-
FROM busybox
7223+
dockerfile := []byte(fmt.Sprintf(
7224+
`
7225+
FROM %s AS build
71937226
COPY <<EOF /out
71947227
hello world!
71957228
EOF
7196-
`)
7229+
`,
7230+
integration.UnixOrWindows("busybox", "nanoserver")))
71977231

71987232
dir := integration.Tmpdir(
71997233
t,
@@ -7222,9 +7256,18 @@ EOF
72227256
require.NoError(t, err)
72237257

72247258
items, err := os.ReadDir(destDir)
7259+
7260+
fileNames := []string{}
7261+
7262+
for _, item := range items {
7263+
if item.Name() == "out" {
7264+
fileNames = append(fileNames, item.Name())
7265+
}
7266+
}
7267+
72257268
require.NoError(t, err)
7226-
require.Equal(t, 1, len(items))
7227-
require.Equal(t, "out", items[0].Name())
7269+
require.Equal(t, 1, len(fileNames))
7270+
require.Equal(t, "out", fileNames[0])
72287271

72297272
dt, err := os.ReadFile(filepath.Join(destDir, "out"))
72307273
require.NoError(t, err)

0 commit comments

Comments
 (0)