Kaynağa Gözat

Merge pull request #17875 from tonistiigi/17827-builder-root-source

Add test for builder cache with root source path
Antonio Murdaca 9 yıl önce
ebeveyn
işleme
75c0cc2f10
1 değiştirilmiş dosya ile 27 ekleme ve 0 silme
  1. 27 0
      integration-cli/docker_cli_build_test.go

+ 27 - 0
integration-cli/docker_cli_build_test.go

@@ -6408,3 +6408,30 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *check.C) {
 	c.Assert(out, checker.Matches, "bar")
 	c.Assert(out, checker.Matches, "bar")
 
 
 }
 }
+
+// #17827
+func (s *DockerSuite) TestBuildCacheRootSource(c *check.C) {
+	testRequires(c, DaemonIsLinux)
+	name := "testbuildrootsource"
+	ctx, err := fakeContext(`
+	FROM busybox
+	COPY / /data`,
+		map[string]string{
+			"foo": "bar",
+		})
+	c.Assert(err, checker.IsNil)
+	defer ctx.Close()
+
+	// warm up cache
+	_, err = buildImageFromContext(name, ctx, true)
+	c.Assert(err, checker.IsNil)
+
+	// change file, should invalidate cache
+	err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
+	c.Assert(err, checker.IsNil)
+
+	_, out, err := buildImageFromContextWithOut(name, ctx, true)
+	c.Assert(err, checker.IsNil)
+
+	c.Assert(out, checker.Not(checker.Contains), "Using cache")
+}