-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32b557d
commit 8569e69
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package dockerfile | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/containerd/continuity/fs/fstest" | ||
"github.com/moby/buildkit/client" | ||
"github.com/moby/buildkit/frontend/dockerui" | ||
"github.com/moby/buildkit/util/testutil/integration" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func testNamedFilteredContext(t *testing.T, sb integration.Sandbox) { | ||
// need to test | ||
// using run --mount, copy --from, and as image source | ||
// the above | ||
ctx := sb.Context() | ||
|
||
c, err := client.New(ctx, sb.Address()) | ||
require.NoError(t, err) | ||
defer c.Close() | ||
|
||
dockerfile := []byte(` | ||
FROM alpine AS foo | ||
RUN echo test > /foo | ||
FROM scratch AS copy_from | ||
COPY --from=foo /foo / | ||
FROM alpine AS run_mount | ||
RUN --mount=from=foo,target=/in cp /in/foo /foo | ||
FROM foo AS image_source | ||
RUN cat /foo > /bar | ||
FROM scratch AS all | ||
COPY --link --from=b /foo /foo.b | ||
COPY --link --from=c /foo /foo.c | ||
COPY --link --from=d /bar /foo.d | ||
`) | ||
|
||
dir := integration.Tmpdir( | ||
t, | ||
fstest.CreateFile("Dockerfile", dockerfile, 0600), | ||
) | ||
|
||
dir2 := integration.Tmpdir(t) | ||
|
||
f := getFrontend(t, sb) | ||
|
||
runTest := func(t *testing.T, target string, maxTransfer float64) { | ||
t.Run(target, func(t *testing.T) { | ||
_, err := f.Solve(ctx, c, client.SolveOpt{ | ||
FrontendAttrs: map[string]string{ | ||
"context:a": "local:a", | ||
"target": target, | ||
}, | ||
LocalDirs: map[string]string{ | ||
dockerui.DefaultDockerfileName: dir, | ||
dockerui.DefaultLocalNameContext: dir, | ||
"a": dir2, | ||
}, | ||
}, nil) | ||
require.NoError(t, err) | ||
}) | ||
} | ||
|
||
runTest(t, "run_mount", 0) | ||
runTest(t, "copy_from", 0) | ||
runTest(t, "image_source", 0) | ||
runTest(t, "all", 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters