|
@@ -731,6 +731,31 @@ func TestBuildContextCleanup(t *testing.T) {
|
|
|
logDone("build - verify context cleanup works properly")
|
|
|
}
|
|
|
|
|
|
+func TestBuildContextCleanupFailedBuild(t *testing.T) {
|
|
|
+ name := "testbuildcontextcleanup"
|
|
|
+ defer deleteImages(name)
|
|
|
+ entries, err := ioutil.ReadDir("/var/lib/docker/tmp")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("failed to list contents of tmp dir: %s", err)
|
|
|
+ }
|
|
|
+ _, err = buildImage(name,
|
|
|
+ `FROM scratch
|
|
|
+ RUN /non/existing/command`,
|
|
|
+ true)
|
|
|
+ if err == nil {
|
|
|
+ t.Fatalf("expected build to fail, but it didn't")
|
|
|
+ }
|
|
|
+ entriesFinal, err := ioutil.ReadDir("/var/lib/docker/tmp")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("failed to list contents of tmp dir: %s", err)
|
|
|
+ }
|
|
|
+ if err = compareDirectoryEntries(entries, entriesFinal); err != nil {
|
|
|
+ t.Fatalf("context should have been deleted, but wasn't")
|
|
|
+ }
|
|
|
+
|
|
|
+ logDone("build - verify context cleanup works properly after a failed build")
|
|
|
+}
|
|
|
+
|
|
|
func TestBuildCmd(t *testing.T) {
|
|
|
name := "testbuildcmd"
|
|
|
expected := "[/bin/echo Hello World]"
|