@@ -5,13 +5,15 @@ package integration
55import (
66 "bytes"
77 "fmt"
8+ "io"
89 "os"
910 "os/exec"
1011 "path/filepath"
1112 "runtime"
1213 "strings"
1314
1415 "github.com/containers/buildah/define"
16+ "github.com/containers/podman/v6/test/utils"
1517 . "github.com/containers/podman/v6/test/utils"
1618 . "github.com/onsi/ginkgo/v2"
1719 . "github.com/onsi/gomega"
@@ -1378,4 +1380,59 @@ COPY --from=img2 /etc/alpine-release /prefix-test/container-prefix.txt`
13781380 session .WaitWithDefaultTimeout ()
13791381 Expect (session ).Should (ExitCleanly ())
13801382 })
1383+
1384+ It ("podman build --output ./folder" , func () {
1385+ session := podmanTest .Podman ([]string {"build" , "-f" , "build/basicalpine/Containerfile" , "--output" , podmanTest .TempDir })
1386+ session .WaitWithDefaultTimeout ()
1387+ Expect (session ).Should (ExitCleanly ())
1388+
1389+ files , err := os .ReadDir (podmanTest .TempDir )
1390+ Expect (err ).ToNot (HaveOccurred ())
1391+ Expect (len (files )).To (BeNumerically (">" , 1 ))
1392+ })
1393+
1394+ It ("podman build --output type=local,dest=./folder" , func () {
1395+ session := podmanTest .Podman ([]string {"build" , "-f" , "build/basicalpine/Containerfile" , "--output" , fmt .Sprintf ("type=local,dest=%v" , podmanTest .TempDir )})
1396+ session .WaitWithDefaultTimeout ()
1397+ Expect (session ).Should (ExitCleanly ())
1398+
1399+ files , err := os .ReadDir (podmanTest .TempDir )
1400+ Expect (err ).ToNot (HaveOccurred ())
1401+ Expect (len (files )).To (BeNumerically (">" , 1 ))
1402+ })
1403+
1404+ It ("podman build --output type=tar,dest=./folder/file.tar" , func () {
1405+ session := podmanTest .Podman ([]string {"build" , "-f" , "build/basicalpine/Containerfile" , "--output" , fmt .Sprintf ("type=tar,dest=%v/file.tar" , podmanTest .TempDir )})
1406+ session .WaitWithDefaultTimeout ()
1407+ Expect (session ).Should (ExitCleanly ())
1408+
1409+ tarFile := filepath .Join (podmanTest .TempDir , "file.tar" )
1410+ _ , err := os .Stat (tarFile )
1411+ Expect (err ).ToNot (HaveOccurred ())
1412+ })
1413+
1414+ It ("podman build --output -" , func () {
1415+ // Capture output to buffer manually, to avoid binary output leaking into test logs
1416+ session := podmanTest .PodmanWithOptions (utils.PodmanExecOptions {
1417+ FullOutputWriter : io .Discard ,
1418+ }, "build" , "-f" , "build/basicalpine/Containerfile" , "--output" , "-" )
1419+ session .WaitWithDefaultTimeout ()
1420+ Expect (session ).Should (ExitCleanly ())
1421+
1422+ // Check for tar header magic number
1423+ Expect (session .OutputToString ()).To (ContainSubstring ("ustar" ))
1424+ })
1425+
1426+ It ("podman build --output type=tar,dest=-" , func () {
1427+ // Capture output to buffer manually, to avoid binary output leaking into test logs
1428+ session := podmanTest .PodmanWithOptions (utils.PodmanExecOptions {
1429+ FullOutputWriter : io .Discard ,
1430+ }, "build" , "-f" , "build/basicalpine/Containerfile" , "--output" , "type=tar,dest=-" )
1431+ session .WaitWithDefaultTimeout ()
1432+ Expect (session ).Should (ExitCleanly ())
1433+
1434+ // Check for tar header magic number
1435+ Expect (session .OutputToString ()).To (ContainSubstring ("ustar" ))
1436+ })
1437+
13811438})
0 commit comments