@@ -1568,15 +1568,22 @@ func testLocalSymlinkEscape(t *testing.T, sb integration.Sandbox) {
1568
1568
}
1569
1569
1570
1570
func testRelativeWorkDir (t * testing.T , sb integration.Sandbox ) {
1571
- requiresLinux (t )
1572
1571
c , err := New (sb .Context (), sb .Address ())
1573
1572
require .NoError (t , err )
1574
1573
defer c .Close ()
1575
1574
1576
- pwd := llb .Image ("docker.io/library/busybox:latest" ).
1575
+ imgName := integration .UnixOrWindows (
1576
+ "docker.io/library/busybox:latest" ,
1577
+ "mcr.microsoft.com/windows/nanoserver:ltsc2022" ,
1578
+ )
1579
+ cmdStr := integration .UnixOrWindows (
1580
+ `sh -c "pwd > /out/pwd"` ,
1581
+ `cmd /C "cd > /out/pwd"` ,
1582
+ )
1583
+ pwd := llb .Image (imgName ).
1577
1584
Dir ("test1" ).
1578
1585
Dir ("test2" ).
1579
- Run (llb .Shlex (`sh -c "pwd > /out/pwd"` )).
1586
+ Run (llb .Shlex (cmdStr )).
1580
1587
AddMount ("/out" , llb .Scratch ())
1581
1588
1582
1589
def , err := pwd .Marshal (sb .Context ())
@@ -1596,22 +1603,32 @@ func testRelativeWorkDir(t *testing.T, sb integration.Sandbox) {
1596
1603
1597
1604
dt , err := os .ReadFile (filepath .Join (destDir , "pwd" ))
1598
1605
require .NoError (t , err )
1599
- require .Equal (t , []byte ("/test1/test2\n " ), dt )
1606
+ pathStr := integration .UnixOrWindows (
1607
+ "/test1/test2\n " ,
1608
+ "C:\\ test1\\ test2\r \n " ,
1609
+ )
1610
+ require .Equal (t , []byte (pathStr ), dt )
1600
1611
}
1601
1612
1602
1613
// TODO: remove this test once `client.SolveOpt.LocalDirs`, now marked as deprecated, is removed.
1603
1614
// For more context on this test, please check:
1604
1615
// https://github.com/moby/buildkit/pull/4583#pullrequestreview-1847043452
1605
1616
func testSolverOptLocalDirsStillWorks (t * testing.T , sb integration.Sandbox ) {
1606
- integration .SkipOnPlatform (t , "windows" )
1607
-
1608
1617
c , err := New (sb .Context (), sb .Address ())
1609
1618
require .NoError (t , err )
1610
1619
defer c .Close ()
1611
1620
1612
- out := llb .Image ("docker.io/library/busybox:latest" ).
1621
+ imgName := integration .UnixOrWindows (
1622
+ "docker.io/library/busybox:latest" ,
1623
+ "mcr.microsoft.com/windows/nanoserver:ltsc2022" ,
1624
+ )
1625
+ cmdStr := integration .UnixOrWindows (
1626
+ `sh -c "/bin/rev < input.txt > /out/output.txt"` ,
1627
+ `cmd /C "type input.txt > /out/output.txt"` ,
1628
+ )
1629
+ out := llb .Image (imgName ).
1613
1630
File (llb .Copy (llb .Local ("mylocal" ), "input.txt" , "input.txt" )).
1614
- Run (llb .Shlex (`sh -c "/bin/rev < input.txt > /out/output.txt"` )).
1631
+ Run (llb .Shlex (cmdStr )).
1615
1632
AddMount (`/out` , llb .Scratch ())
1616
1633
1617
1634
def , err := out .Marshal (sb .Context ())
@@ -1639,7 +1656,12 @@ func testSolverOptLocalDirsStillWorks(t *testing.T, sb integration.Sandbox) {
1639
1656
1640
1657
dt , err := os .ReadFile (filepath .Join (destDir .Name , "output.txt" ))
1641
1658
require .NoError (t , err )
1642
- require .Equal (t , []byte ("dlroW olleH" ), dt )
1659
+ // not reversed on Windows since there's no handy rev utility
1660
+ revStr := integration .UnixOrWindows (
1661
+ "dlroW olleH" ,
1662
+ "Hello World" ,
1663
+ )
1664
+ require .Equal (t , []byte (revStr ), dt )
1643
1665
}
1644
1666
1645
1667
func testFileOpMkdirMkfile (t * testing.T , sb integration.Sandbox ) {
@@ -6836,12 +6858,19 @@ func testCacheMountNoCache(t *testing.T, sb integration.Sandbox) {
6836
6858
}
6837
6859
6838
6860
func testCopyFromEmptyImage (t * testing.T , sb integration.Sandbox ) {
6839
- requiresLinux (t )
6840
6861
c , err := New (sb .Context (), sb .Address ())
6841
6862
require .NoError (t , err )
6842
6863
defer c .Close ()
6843
6864
6844
- for _ , image := range []llb.State {llb .Scratch (), llb .Image ("tonistiigi/test:nolayers" )} {
6865
+ // On Windows, the error messages are different for the Scratch image
6866
+ // (which is coming from the OS). While the one for the no-layers image
6867
+ // is being returned by Buildkit (in unix style).
6868
+ winErrMsgs := []string {
6869
+ "foo: The system cannot find the file specified" , // for llb.Scratch()
6870
+ "/foo: no such file or directory" , // for tonistiigi/test:nolayers
6871
+ }
6872
+
6873
+ for i , image := range []llb.State {llb .Scratch (), llb .Image ("tonistiigi/test:nolayers" )} {
6845
6874
st := llb .Scratch ().File (llb .Copy (image , "/" , "/" ))
6846
6875
def , err := st .Marshal (sb .Context ())
6847
6876
require .NoError (t , err )
@@ -6855,11 +6884,23 @@ func testCopyFromEmptyImage(t *testing.T, sb integration.Sandbox) {
6855
6884
6856
6885
_ , err = c .Solve (sb .Context (), def , SolveOpt {}, nil )
6857
6886
require .Error (t , err )
6858
- require .Contains (t , err .Error (), "/foo: no such file or directory" )
6887
+ errMsg := integration .UnixOrWindows (
6888
+ "/foo: no such file or directory" ,
6889
+ winErrMsgs [i ],
6890
+ )
6891
+ require .Contains (t , err .Error (), errMsg )
6859
6892
6860
- busybox := llb .Image ("busybox:latest" )
6893
+ imgName := integration .UnixOrWindows (
6894
+ "busybox:latest" ,
6895
+ "mcr.microsoft.com/windows/nanoserver:ltsc2022" ,
6896
+ )
6897
+ busybox := llb .Image (imgName )
6861
6898
6862
- out := busybox .Run (llb .Shlex (`sh -e -c '[ $(ls /scratch | wc -l) = '0' ]'` ))
6899
+ cmdStr := integration .UnixOrWindows (
6900
+ `sh -e -c '[ $(ls /scratch | wc -l) = '0' ]'` ,
6901
+ `cmd /C dir \scratch` ,
6902
+ )
6903
+ out := busybox .Run (llb .Shlex (cmdStr ))
6863
6904
out .AddMount ("/scratch" , image , llb .Readonly )
6864
6905
6865
6906
def , err = out .Marshal (sb .Context ())
0 commit comments