Browse code

Move test out of the windows build.

Because it can still run on windows server and fail because it doesn't
have `chown`.

Signed-off-by: David Calavera <david.calavera@gmail.com>

David Calavera authored on 2015/12/31 06:36:48
Showing 2 changed files
... ...
@@ -3240,46 +3240,6 @@ func (s *DockerSuite) TestBuildAddFileNotFound(c *check.C) {
3240 3240
 	}
3241 3241
 }
3242 3242
 
3243
-func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
3244
-	testRequires(c, DaemonIsLinux)
3245
-	name := "testbuildaddown"
3246
-
3247
-	ctx := func() *FakeContext {
3248
-		dockerfile := `
3249
-			FROM busybox
3250
-			ADD foo /bar/
3251
-			RUN [ $(stat -c %U:%G "/bar") = 'root:root' ]
3252
-			RUN [ $(stat -c %U:%G "/bar/foo") = 'root:root' ]
3253
-			`
3254
-		tmpDir, err := ioutil.TempDir("", "fake-context")
3255
-		c.Assert(err, check.IsNil)
3256
-		testFile, err := os.Create(filepath.Join(tmpDir, "foo"))
3257
-		if err != nil {
3258
-			c.Fatalf("failed to create foo file: %v", err)
3259
-		}
3260
-		defer testFile.Close()
3261
-
3262
-		chownCmd := exec.Command("chown", "daemon:daemon", "foo")
3263
-		chownCmd.Dir = tmpDir
3264
-		out, _, err := runCommandWithOutput(chownCmd)
3265
-		if err != nil {
3266
-			c.Fatal(err, out)
3267
-		}
3268
-
3269
-		if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
3270
-			c.Fatalf("failed to open destination dockerfile: %v", err)
3271
-		}
3272
-		return fakeContextFromDir(tmpDir)
3273
-	}()
3274
-
3275
-	defer ctx.Close()
3276
-
3277
-	if _, err := buildImageFromContext(name, ctx, true); err != nil {
3278
-		c.Fatalf("build failed to complete for TestBuildAddChangeOwnership: %v", err)
3279
-	}
3280
-
3281
-}
3282
-
3283 3243
 func (s *DockerSuite) TestBuildInheritance(c *check.C) {
3284 3244
 	testRequires(c, DaemonIsLinux)
3285 3245
 	name := "testbuildinheritance"
... ...
@@ -4,6 +4,10 @@ package main
4 4
 
5 5
 import (
6 6
 	"encoding/json"
7
+	"io/ioutil"
8
+	"os"
9
+	"os/exec"
10
+	"path/filepath"
7 11
 	"strings"
8 12
 
9 13
 	"github.com/docker/docker/pkg/integration/checker"
... ...
@@ -73,3 +77,43 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
73 73
 	c.Assert(c2.CPUQuota, check.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota"))
74 74
 	c.Assert(c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits"))
75 75
 }
76
+
77
+func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
78
+	testRequires(c, DaemonIsLinux)
79
+	name := "testbuildaddown"
80
+
81
+	ctx := func() *FakeContext {
82
+		dockerfile := `
83
+			FROM busybox
84
+			ADD foo /bar/
85
+			RUN [ $(stat -c %U:%G "/bar") = 'root:root' ]
86
+			RUN [ $(stat -c %U:%G "/bar/foo") = 'root:root' ]
87
+			`
88
+		tmpDir, err := ioutil.TempDir("", "fake-context")
89
+		c.Assert(err, check.IsNil)
90
+		testFile, err := os.Create(filepath.Join(tmpDir, "foo"))
91
+		if err != nil {
92
+			c.Fatalf("failed to create foo file: %v", err)
93
+		}
94
+		defer testFile.Close()
95
+
96
+		chownCmd := exec.Command("chown", "daemon:daemon", "foo")
97
+		chownCmd.Dir = tmpDir
98
+		out, _, err := runCommandWithOutput(chownCmd)
99
+		if err != nil {
100
+			c.Fatal(err, out)
101
+		}
102
+
103
+		if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
104
+			c.Fatalf("failed to open destination dockerfile: %v", err)
105
+		}
106
+		return fakeContextFromDir(tmpDir)
107
+	}()
108
+
109
+	defer ctx.Close()
110
+
111
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
112
+		c.Fatalf("build failed to complete for TestBuildAddChangeOwnership: %v", err)
113
+	}
114
+
115
+}