@@ -41,6 +41,37 @@ var _ = Describe("Podman build", func() {
41
41
Expect (session ).Should (ExitCleanly ())
42
42
})
43
43
44
+ It ("podman image prune should clean build cache" , Serial , func () {
45
+ // try writing something to persistent cache
46
+ session := podmanTest .Podman ([]string {"build" , "-f" , "build/buildkit-mount/Containerfilecachewrite" })
47
+ session .WaitWithDefaultTimeout ()
48
+ Expect (session ).Should (ExitCleanly ())
49
+
50
+ // try reading something from persistent cache
51
+ session = podmanTest .Podman ([]string {"build" , "-f" , "build/buildkit-mount/Containerfilecacheread" })
52
+ session .WaitWithDefaultTimeout ()
53
+ Expect (session ).Should (ExitCleanly ())
54
+ Expect (session .OutputToString ()).To (ContainSubstring ("hello" ))
55
+
56
+ // Prune build cache
57
+ session = podmanTest .Podman ([]string {"image" , "prune" , "-f" , "--build-cache" })
58
+ session .WaitWithDefaultTimeout ()
59
+ Expect (session ).Should (ExitCleanly ())
60
+
61
+ expectedErr := "open '/test/world': No such file or directory"
62
+ // try reading something from persistent cache should fail
63
+ session = podmanTest .Podman ([]string {"build" , "-f" , "build/buildkit-mount/Containerfilecacheread" })
64
+ session .WaitWithDefaultTimeout ()
65
+ if IsRemote () {
66
+ // In the case of podman remote the error from build is not being propogated to `stderr` instead it appears
67
+ // on the `stdout` this could be a potential bug in `remote build` which needs to be fixed and visited.
68
+ Expect (session .OutputToString ()).To (ContainSubstring (expectedErr ))
69
+ Expect (session ).Should (ExitWithError (1 , "exit status 1" ))
70
+ } else {
71
+ Expect (session ).Should (ExitWithError (1 , expectedErr ))
72
+ }
73
+ })
74
+
44
75
It ("podman build and remove basic alpine with TMPDIR as relative" , func () {
45
76
// preserve TMPDIR if it was originally set
46
77
if cacheDir , found := os .LookupEnv ("TMPDIR" ); found {
0 commit comments