Skip to content

Commit 704268a

Browse files
Add test to check that client.SolveOpt.LocalDirs still works
It will need to be removed in a follow up PR. Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
1 parent b3d99d6 commit 704268a

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

client/client_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ var allTests = []func(t *testing.T, sb integration.Sandbox){
211211
testSnapshotWithMultipleBlobs,
212212
testExportLocalNoPlatformSplit,
213213
testExportLocalNoPlatformSplitOverwrite,
214+
testSolverOptLocalDirsStillWorks,
214215
}
215216

216217
func TestIntegration(t *testing.T) {
@@ -1555,6 +1556,49 @@ func testRelativeWorkDir(t *testing.T, sb integration.Sandbox) {
15551556
require.Equal(t, []byte("/test1/test2\n"), dt)
15561557
}
15571558

1559+
// TODO: remove this test once `client.SolveOpt.LocalDirs`, now marked as deprecated, is removed.
1560+
// For more context on this test, please check:
1561+
// https://github.com/moby/buildkit/pull/4583#pullrequestreview-1847043452
1562+
func testSolverOptLocalDirsStillWorks(t *testing.T, sb integration.Sandbox) {
1563+
integration.SkipOnPlatform(t, "windows")
1564+
1565+
c, err := New(sb.Context(), sb.Address())
1566+
require.NoError(t, err)
1567+
defer c.Close()
1568+
1569+
out := llb.Image("docker.io/library/busybox:latest").
1570+
File(llb.Copy(llb.Local("mylocal"), "input.txt", "input.txt")).
1571+
Run(llb.Shlex(`sh -c "/bin/rev < input.txt > /out/output.txt"`)).
1572+
AddMount(`/out`, llb.Scratch())
1573+
1574+
def, err := out.Marshal(sb.Context())
1575+
require.NoError(t, err)
1576+
1577+
srcDir := integration.Tmpdir(t,
1578+
fstest.CreateFile("input.txt", []byte("Hello World"), 0600),
1579+
)
1580+
1581+
destDir := integration.Tmpdir(t)
1582+
1583+
_, err = c.Solve(sb.Context(), def, SolveOpt{
1584+
LocalDirs: map[string]string{
1585+
"mylocal": srcDir.Name,
1586+
},
1587+
Exports: []ExportEntry{
1588+
{
1589+
Type: ExporterLocal,
1590+
OutputDir: destDir.Name,
1591+
},
1592+
},
1593+
}, nil)
1594+
1595+
require.NoError(t, err)
1596+
1597+
dt, err := os.ReadFile(filepath.Join(destDir.Name, "output.txt"))
1598+
require.NoError(t, err)
1599+
require.Equal(t, []byte("dlroW olleH"), dt)
1600+
}
1601+
15581602
func testFileOpMkdirMkfile(t *testing.T, sb integration.Sandbox) {
15591603
requiresLinux(t)
15601604
c, err := New(sb.Context(), sb.Address())

0 commit comments

Comments
 (0)