mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
commit
240fad4974
4 changed files with 46 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
FROM busybox
|
||||
ADD https://index.docker.io/robots.txt /
|
|
@ -0,0 +1,2 @@
|
|||
FROM busybox
|
||||
ADD http://example.com/index.html /
|
|
@ -9,6 +9,37 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildCacheADD(t *testing.T) {
|
||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "1")
|
||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "testcacheadd1", ".")
|
||||
buildCmd.Dir = buildDirectory
|
||||
exitCode, err := runCommand(buildCmd)
|
||||
errorOut(err, t, fmt.Sprintf("build failed to complete: %v", err))
|
||||
|
||||
if err != nil || exitCode != 0 {
|
||||
t.Fatal("failed to build the image")
|
||||
}
|
||||
|
||||
buildDirectory = filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "2")
|
||||
buildCmd = exec.Command(dockerBinary, "build", "-t", "testcacheadd2", ".")
|
||||
buildCmd.Dir = buildDirectory
|
||||
out, exitCode, err := runCommandWithOutput(buildCmd)
|
||||
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
||||
|
||||
if err != nil || exitCode != 0 {
|
||||
t.Fatal("failed to build the image")
|
||||
}
|
||||
|
||||
if strings.Contains(out, "Using cache") {
|
||||
t.Fatal("2nd build used cache on ADD, it shouldn't")
|
||||
}
|
||||
|
||||
deleteImages("testcacheadd1")
|
||||
deleteImages("testcacheadd2")
|
||||
|
||||
logDone("build - build two images with ADD")
|
||||
}
|
||||
|
||||
func TestBuildSixtySteps(t *testing.T) {
|
||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildSixtySteps")
|
||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "foobuildsixtysteps", ".")
|
||||
|
|
|
@ -16,11 +16,13 @@ import (
|
|||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/dotcloud/docker/archive"
|
||||
"github.com/dotcloud/docker/daemon"
|
||||
"github.com/dotcloud/docker/nat"
|
||||
"github.com/dotcloud/docker/pkg/symlink"
|
||||
"github.com/dotcloud/docker/pkg/system"
|
||||
"github.com/dotcloud/docker/registry"
|
||||
"github.com/dotcloud/docker/runconfig"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
|
@ -563,6 +565,11 @@ func (b *buildFile) CmdAdd(args string) error {
|
|||
}
|
||||
tmpFile.Close()
|
||||
|
||||
// Remove the mtime of the newly created tmp file
|
||||
if err := system.UtimesNano(tmpFileName, make([]syscall.Timespec, 2)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
origPath = path.Join(filepath.Base(tmpDirName), filepath.Base(tmpFileName))
|
||||
|
||||
// Process the checksum
|
||||
|
@ -570,7 +577,10 @@ func (b *buildFile) CmdAdd(args string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tarSum := utils.TarSum{Reader: r, DisableCompression: true}
|
||||
tarSum := &utils.TarSum{Reader: r, DisableCompression: true}
|
||||
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
|
||||
return err
|
||||
}
|
||||
remoteHash = tarSum.Sum(nil)
|
||||
r.Close()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue