diff --git a/frontend/dockerfile/dockerfile_mount_test.go b/frontend/dockerfile/dockerfile_mount_test.go new file mode 100644 index 00000000..cde23c60 --- /dev/null +++ b/frontend/dockerfile/dockerfile_mount_test.go @@ -0,0 +1,51 @@ +// +build dfrunmount + +package dockerfile + +import ( + "context" + "os" + "testing" + + "github.com/containerd/continuity/fs/fstest" + "github.com/moby/buildkit/client" + "github.com/moby/buildkit/frontend/dockerfile/builder" + "github.com/moby/buildkit/util/testutil/integration" + "github.com/stretchr/testify/require" +) + +var mountTests = []integration.Test{ + testMountContext, +} + +func init() { + allTests = append(allTests, mountTests...) +} + +func testMountContext(t *testing.T, sb integration.Sandbox) { + f := getFrontend(t, sb) + + dockerfile := []byte(` +FROM busybox +RUN --mount=target=/context [ "$(cat /context/testfile)" == "contents0" ] +`) + + dir, err := tmpdir( + fstest.CreateFile("Dockerfile", dockerfile, 0600), + fstest.CreateFile("testfile", []byte("contents0"), 0600), + ) + require.NoError(t, err) + defer os.RemoveAll(dir) + + c, err := client.New(context.TODO(), sb.Address()) + require.NoError(t, err) + defer c.Close() + + _, err = f.Solve(context.TODO(), c, client.SolveOpt{ + LocalDirs: map[string]string{ + builder.LocalNameDockerfile: dir, + builder.LocalNameContext: dir, + }, + }, nil) + require.NoError(t, err) +} diff --git a/frontend/dockerfile/dockerfile_test.go b/frontend/dockerfile/dockerfile_test.go index a2ed9cb6..8a778814 100644 --- a/frontend/dockerfile/dockerfile_test.go +++ b/frontend/dockerfile/dockerfile_test.go @@ -37,6 +37,51 @@ import ( "github.com/stretchr/testify/require" ) +var allTests = []integration.Test{ + testNoSnapshotLeak, + testCmdShell, + testGlobalArg, + testDockerfileDirs, + testDockerfileInvalidCommand, + testDockerfileADDFromURL, + testDockerfileAddArchive, + testDockerfileScratchConfig, + testExportedHistory, + testExposeExpansion, + testUser, + testDockerignore, + testDockerignoreInvalid, + testDockerfileFromGit, + testCopyChown, + testCopyWildcards, + testCopyOverrideFiles, + testMultiStageImplicitFrom, + testCopyVarSubstitution, + testMultiStageCaseInsensitive, + testLabels, + testCacheImportExport, + testReproducibleIDs, + testImportExportReproducibleIDs, + testNoCache, + testDockerfileFromHTTP, + testBuiltinArgs, + testPullScratch, + testSymlinkDestination, + testHTTPDockerfile, + testNoSnapshotLeak, + testCopySymlinks, + testContextChangeDirToFile, + testPlatformArgsImplicit, + testPlatformArgsExplicit, + testExportMultiPlatform, + testQuotedMetaArgs, + testIgnoreEntrypoint, + testCopyThroughSymlinkContext, + testCopyThroughSymlinkMultiStage, + testCopyChownCreateDest, + testEmptyDestDir, +} + var opts []integration.TestOpt type frontend interface { @@ -73,50 +118,7 @@ func init() { } func TestIntegration(t *testing.T) { - integration.Run(t, []integration.Test{ - testNoSnapshotLeak, - testCmdShell, - testGlobalArg, - testDockerfileDirs, - testDockerfileInvalidCommand, - testDockerfileADDFromURL, - testDockerfileAddArchive, - testDockerfileScratchConfig, - testExportedHistory, - testExposeExpansion, - testUser, - testDockerignore, - testDockerignoreInvalid, - testDockerfileFromGit, - testCopyChown, - testCopyWildcards, - testCopyOverrideFiles, - testMultiStageImplicitFrom, - testCopyVarSubstitution, - testMultiStageCaseInsensitive, - testLabels, - testCacheImportExport, - testReproducibleIDs, - testImportExportReproducibleIDs, - testNoCache, - testDockerfileFromHTTP, - testBuiltinArgs, - testPullScratch, - testSymlinkDestination, - testHTTPDockerfile, - testNoSnapshotLeak, - testCopySymlinks, - testContextChangeDirToFile, - testPlatformArgsImplicit, - testPlatformArgsExplicit, - testExportMultiPlatform, - testQuotedMetaArgs, - testIgnoreEntrypoint, - testCopyThroughSymlinkContext, - testCopyThroughSymlinkMultiStage, - testCopyChownCreateDest, - testEmptyDestDir, - }, opts...) + integration.Run(t, allTests, opts...) } func testEmptyDestDir(t *testing.T, sb integration.Sandbox) {