Browse code

Third set of TestBuild* CI enabling for Windows

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2016/01/29 05:40:52
Showing 1 changed files
... ...
@@ -1818,13 +1818,15 @@ func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *check.C) {
1818 1818
 }
1819 1819
 
1820 1820
 func (s *DockerSuite) TestBuildForceRm(c *check.C) {
1821
-	testRequires(c, DaemonIsLinux)
1822 1821
 	containerCountBefore, err := getContainerCount()
1823 1822
 	if err != nil {
1824 1823
 		c.Fatalf("failed to get the container count: %s", err)
1825 1824
 	}
1826 1825
 	name := "testbuildforcerm"
1827
-	ctx, err := fakeContext("FROM scratch\nRUN true\nRUN thiswillfail", nil)
1826
+
1827
+	ctx, err := fakeContext(`FROM `+minimalBaseImage()+`
1828
+	RUN true
1829
+	RUN thiswillfail`, nil)
1828 1830
 	if err != nil {
1829 1831
 		c.Fatal(err)
1830 1832
 	}
... ...
@@ -1844,9 +1846,11 @@ func (s *DockerSuite) TestBuildForceRm(c *check.C) {
1844 1844
 }
1845 1845
 
1846 1846
 func (s *DockerSuite) TestBuildRm(c *check.C) {
1847
-	testRequires(c, DaemonIsLinux)
1848 1847
 	name := "testbuildrm"
1849
-	ctx, err := fakeContext("FROM scratch\nADD foo /\nADD foo /", map[string]string{"foo": "bar"})
1848
+
1849
+	ctx, err := fakeContext(`FROM `+minimalBaseImage()+`
1850
+	ADD foo /
1851
+	ADD foo /`, map[string]string{"foo": "bar"})
1850 1852
 	if err != nil {
1851 1853
 		c.Fatal(err)
1852 1854
 	}
... ...
@@ -1924,7 +1928,7 @@ func (s *DockerSuite) TestBuildRm(c *check.C) {
1924 1924
 }
1925 1925
 
1926 1926
 func (s *DockerSuite) TestBuildWithVolumes(c *check.C) {
1927
-	testRequires(c, DaemonIsLinux)
1927
+	testRequires(c, DaemonIsLinux) // Invalid volume paths on Windows
1928 1928
 	var (
1929 1929
 		result   map[string]map[string]struct{}
1930 1930
 		name     = "testbuildvolumes"
... ...
@@ -1968,11 +1972,11 @@ func (s *DockerSuite) TestBuildWithVolumes(c *check.C) {
1968 1968
 }
1969 1969
 
1970 1970
 func (s *DockerSuite) TestBuildMaintainer(c *check.C) {
1971
-	testRequires(c, DaemonIsLinux)
1972 1971
 	name := "testbuildmaintainer"
1972
+
1973 1973
 	expected := "dockerio"
1974 1974
 	_, err := buildImage(name,
1975
-		`FROM scratch
1975
+		`FROM `+minimalBaseImage()+`
1976 1976
         MAINTAINER dockerio`,
1977 1977
 		true)
1978 1978
 	if err != nil {
... ...
@@ -2004,32 +2008,58 @@ func (s *DockerSuite) TestBuildUser(c *check.C) {
2004 2004
 }
2005 2005
 
2006 2006
 func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) {
2007
-	testRequires(c, DaemonIsLinux)
2008 2007
 	name := "testbuildrelativeworkdir"
2009
-	expected := "/test2/test3"
2008
+
2009
+	var (
2010
+		expected1     string
2011
+		expected2     string
2012
+		expected3     string
2013
+		expected4     string
2014
+		expectedFinal string
2015
+	)
2016
+	if daemonPlatform == "windows" {
2017
+		expected1 = `C:/Windows/system32`
2018
+		expected2 = `C:/test1`
2019
+		expected3 = `C:/test2`
2020
+		expected4 = `C:/test2/test3`
2021
+		expectedFinal = `\test2\test3`
2022
+	} else {
2023
+		expected1 = `/`
2024
+		expected2 = `/test1`
2025
+		expected3 = `/test2`
2026
+		expected4 = `/test2/test3`
2027
+		expectedFinal = `/test2/test3`
2028
+	}
2029
+
2010 2030
 	_, err := buildImage(name,
2011 2031
 		`FROM busybox
2012
-		RUN [ "$PWD" = '/' ]
2032
+		RUN sh -c "[ "$PWD" = '`+expected1+`' ]"
2013 2033
 		WORKDIR test1
2014
-		RUN [ "$PWD" = '/test1' ]
2034
+		RUN sh -c "[ "$PWD" = '`+expected2+`' ]"
2015 2035
 		WORKDIR /test2
2016
-		RUN [ "$PWD" = '/test2' ]
2036
+		RUN sh -c "[ "$PWD" = '`+expected3+`' ]"
2017 2037
 		WORKDIR test3
2018
-		RUN [ "$PWD" = '/test2/test3' ]`,
2038
+		RUN sh -c "[ "$PWD" = '`+expected4+`' ]"`,
2019 2039
 		true)
2020 2040
 	if err != nil {
2021 2041
 		c.Fatal(err)
2022 2042
 	}
2023 2043
 	res := inspectField(c, name, "Config.WorkingDir")
2024
-	if res != expected {
2025
-		c.Fatalf("Workdir %s, expected %s", res, expected)
2044
+	if res != expectedFinal {
2045
+		c.Fatalf("Workdir %s, expected %s", res, expectedFinal)
2026 2046
 	}
2027 2047
 }
2028 2048
 
2029 2049
 func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
2030
-	testRequires(c, DaemonIsLinux)
2031 2050
 	name := "testbuildworkdirwithenvvariables"
2032
-	expected := "/test1/test2"
2051
+
2052
+	var expected string
2053
+	if daemonPlatform == "windows" {
2054
+		expected = `\test1\test2`
2055
+	} else {
2056
+		expected = `/test1/test2`
2057
+	}
2058
+
2033 2059
 	_, err := buildImage(name,
2034 2060
 		`FROM busybox
2035 2061
 		ENV DIRPATH /test1
... ...
@@ -2049,30 +2079,37 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
2049 2049
 func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
2050 2050
 	// cat /test1/test2/foo gets permission denied for the user
2051 2051
 	testRequires(c, NotUserNamespace)
2052
-	testRequires(c, DaemonIsLinux)
2052
+
2053
+	var expected string
2054
+	if daemonPlatform == "windows" {
2055
+		expected = `C:/test1/test2`
2056
+	} else {
2057
+		expected = `/test1/test2`
2058
+	}
2059
+
2053 2060
 	name := "testbuildrelativecopy"
2054 2061
 	dockerfile := `
2055 2062
 		FROM busybox
2056 2063
 			WORKDIR /test1
2057 2064
 			WORKDIR test2
2058
-			RUN [ "$PWD" = '/test1/test2' ]
2065
+			RUN sh -c "[ "$PWD" = '` + expected + `' ]"
2059 2066
 			COPY foo ./
2060
-			RUN [ "$(cat /test1/test2/foo)" = 'hello' ]
2067
+			RUN sh -c "[ $(cat /test1/test2/foo) = 'hello' ]"
2061 2068
 			ADD foo ./bar/baz
2062
-			RUN [ "$(cat /test1/test2/bar/baz)" = 'hello' ]
2069
+			RUN sh -c "[ $(cat /test1/test2/bar/baz) = 'hello' ]"
2063 2070
 			COPY foo ./bar/baz2
2064
-			RUN [ "$(cat /test1/test2/bar/baz2)" = 'hello' ]
2071
+			RUN sh -c "[ $(cat /test1/test2/bar/baz2) = 'hello' ]"
2065 2072
 			WORKDIR ..
2066 2073
 			COPY foo ./
2067
-			RUN [ "$(cat /test1/foo)" = 'hello' ]
2074
+			RUN sh -c "[ $(cat /test1/foo) = 'hello' ]"
2068 2075
 			COPY foo /test3/
2069
-			RUN [ "$(cat /test3/foo)" = 'hello' ]
2076
+			RUN sh -c "[ $(cat /test3/foo) = 'hello' ]"
2070 2077
 			WORKDIR /test4
2071 2078
 			COPY . .
2072
-			RUN [ "$(cat /test4/foo)" = 'hello' ]
2079
+			RUN sh -c "[ $(cat /test4/foo) = 'hello' ]"
2073 2080
 			WORKDIR /test5/test6
2074 2081
 			COPY foo ../
2075
-			RUN [ "$(cat /test5/foo)" = 'hello' ]
2082
+			RUN sh -c "[ $(cat /test5/foo) = 'hello' ]"
2076 2083
 			`
2077 2084
 	ctx, err := fakeContext(dockerfile, map[string]string{
2078 2085
 		"foo": "hello",
... ...
@@ -2088,7 +2125,7 @@ func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
2088 2088
 }
2089 2089
 
2090 2090
 func (s *DockerSuite) TestBuildEnv(c *check.C) {
2091
-	testRequires(c, DaemonIsLinux)
2091
+	testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows
2092 2092
 	name := "testbuildenv"
2093 2093
 	expected := "[PATH=/test:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]"
2094 2094
 	_, err := buildImage(name,
... ...
@@ -2107,7 +2144,7 @@ func (s *DockerSuite) TestBuildEnv(c *check.C) {
2107 2107
 }
2108 2108
 
2109 2109
 func (s *DockerSuite) TestBuildPATH(c *check.C) {
2110
-	testRequires(c, DaemonIsLinux)
2110
+	testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows
2111 2111
 
2112 2112
 	defPath := "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
2113 2113
 
... ...
@@ -2191,11 +2228,11 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) {
2191 2191
 }
2192 2192
 
2193 2193
 func (s *DockerSuite) TestBuildCmd(c *check.C) {
2194
-	testRequires(c, DaemonIsLinux)
2195 2194
 	name := "testbuildcmd"
2195
+
2196 2196
 	expected := "{[/bin/echo Hello World]}"
2197 2197
 	_, err := buildImage(name,
2198
-		`FROM scratch
2198
+		`FROM `+minimalBaseImage()+`
2199 2199
         CMD ["/bin/echo", "Hello World"]`,
2200 2200
 		true)
2201 2201
 	if err != nil {
... ...
@@ -2208,7 +2245,7 @@ func (s *DockerSuite) TestBuildCmd(c *check.C) {
2208 2208
 }
2209 2209
 
2210 2210
 func (s *DockerSuite) TestBuildExpose(c *check.C) {
2211
-	testRequires(c, DaemonIsLinux)
2211
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2212 2212
 	name := "testbuildexpose"
2213 2213
 	expected := "map[2375/tcp:{}]"
2214 2214
 	_, err := buildImage(name,
... ...
@@ -2225,7 +2262,7 @@ func (s *DockerSuite) TestBuildExpose(c *check.C) {
2225 2225
 }
2226 2226
 
2227 2227
 func (s *DockerSuite) TestBuildExposeMorePorts(c *check.C) {
2228
-	testRequires(c, DaemonIsLinux)
2228
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2229 2229
 	// start building docker file with a large number of ports
2230 2230
 	portList := make([]string, 50)
2231 2231
 	line := make([]string, 100)
... ...
@@ -2277,7 +2314,7 @@ func (s *DockerSuite) TestBuildExposeMorePorts(c *check.C) {
2277 2277
 }
2278 2278
 
2279 2279
 func (s *DockerSuite) TestBuildExposeOrder(c *check.C) {
2280
-	testRequires(c, DaemonIsLinux)
2280
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2281 2281
 	buildID := func(name, exposed string) string {
2282 2282
 		_, err := buildImage(name, fmt.Sprintf(`FROM scratch
2283 2283
 		EXPOSE %s`, exposed), true)
... ...
@@ -2296,7 +2333,7 @@ func (s *DockerSuite) TestBuildExposeOrder(c *check.C) {
2296 2296
 }
2297 2297
 
2298 2298
 func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) {
2299
-	testRequires(c, DaemonIsLinux)
2299
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2300 2300
 	name := "testbuildexposeuppercaseproto"
2301 2301
 	expected := "map[5678/udp:{}]"
2302 2302
 	_, err := buildImage(name,
... ...
@@ -2313,7 +2350,6 @@ func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) {
2313 2313
 }
2314 2314
 
2315 2315
 func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
2316
-	testRequires(c, DaemonIsLinux)
2317 2316
 	name := "testbuildentrypointinheritance"
2318 2317
 	name2 := "testbuildentrypointinheritance2"
2319 2318
 
... ...
@@ -2349,7 +2385,6 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
2349 2349
 }
2350 2350
 
2351 2351
 func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) {
2352
-	testRequires(c, DaemonIsLinux)
2353 2352
 	name := "testbuildentrypoint"
2354 2353
 	expected := "{[]}"
2355 2354
 
... ...
@@ -2368,11 +2403,11 @@ func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) {
2368 2368
 }
2369 2369
 
2370 2370
 func (s *DockerSuite) TestBuildEntrypoint(c *check.C) {
2371
-	testRequires(c, DaemonIsLinux)
2372 2371
 	name := "testbuildentrypoint"
2372
+
2373 2373
 	expected := "{[/bin/echo]}"
2374 2374
 	_, err := buildImage(name,
2375
-		`FROM scratch
2375
+		`FROM `+minimalBaseImage()+`
2376 2376
         ENTRYPOINT ["/bin/echo"]`,
2377 2377
 		true)
2378 2378
 	if err != nil {
... ...
@@ -2387,7 +2422,6 @@ func (s *DockerSuite) TestBuildEntrypoint(c *check.C) {
2387 2387
 
2388 2388
 // #6445 ensure ONBUILD triggers aren't committed to grandchildren
2389 2389
 func (s *DockerSuite) TestBuildOnBuildLimitedInheritence(c *check.C) {
2390
-	testRequires(c, DaemonIsLinux)
2391 2390
 	var (
2392 2391
 		out2, out3 string
2393 2392
 	)
... ...
@@ -2456,7 +2490,7 @@ func (s *DockerSuite) TestBuildOnBuildLimitedInheritence(c *check.C) {
2456 2456
 }
2457 2457
 
2458 2458
 func (s *DockerSuite) TestBuildWithCache(c *check.C) {
2459
-	testRequires(c, DaemonIsLinux)
2459
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2460 2460
 	name := "testbuildwithcache"
2461 2461
 	id1, err := buildImage(name,
2462 2462
 		`FROM scratch
... ...
@@ -2482,7 +2516,7 @@ func (s *DockerSuite) TestBuildWithCache(c *check.C) {
2482 2482
 }
2483 2483
 
2484 2484
 func (s *DockerSuite) TestBuildWithoutCache(c *check.C) {
2485
-	testRequires(c, DaemonIsLinux)
2485
+	testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
2486 2486
 	name := "testbuildwithoutcache"
2487 2487
 	name2 := "testbuildwithoutcache2"
2488 2488
 	id1, err := buildImage(name,
... ...
@@ -2510,7 +2544,6 @@ func (s *DockerSuite) TestBuildWithoutCache(c *check.C) {
2510 2510
 }
2511 2511
 
2512 2512
 func (s *DockerSuite) TestBuildConditionalCache(c *check.C) {
2513
-	testRequires(c, DaemonIsLinux)
2514 2513
 	name := "testbuildconditionalcache"
2515 2514
 
2516 2515
 	dockerfile := `
... ...
@@ -2553,14 +2586,13 @@ func (s *DockerSuite) TestBuildConditionalCache(c *check.C) {
2553 2553
 func (s *DockerSuite) TestBuildAddLocalFileWithCache(c *check.C) {
2554 2554
 	// local files are not owned by the correct user
2555 2555
 	testRequires(c, NotUserNamespace)
2556
-	testRequires(c, DaemonIsLinux)
2557 2556
 	name := "testbuildaddlocalfilewithcache"
2558 2557
 	name2 := "testbuildaddlocalfilewithcache2"
2559 2558
 	dockerfile := `
2560 2559
 		FROM busybox
2561 2560
         MAINTAINER dockerio
2562 2561
         ADD foo /usr/lib/bla/bar
2563
-		RUN [ "$(cat /usr/lib/bla/bar)" = "hello" ]`
2562
+		RUN sh -c "[ $(cat /usr/lib/bla/bar) = "hello" ]"`
2564 2563
 	ctx, err := fakeContext(dockerfile, map[string]string{
2565 2564
 		"foo": "hello",
2566 2565
 	})
... ...
@@ -2582,14 +2614,13 @@ func (s *DockerSuite) TestBuildAddLocalFileWithCache(c *check.C) {
2582 2582
 }
2583 2583
 
2584 2584
 func (s *DockerSuite) TestBuildAddMultipleLocalFileWithCache(c *check.C) {
2585
-	testRequires(c, DaemonIsLinux)
2586 2585
 	name := "testbuildaddmultiplelocalfilewithcache"
2587 2586
 	name2 := "testbuildaddmultiplelocalfilewithcache2"
2588 2587
 	dockerfile := `
2589 2588
 		FROM busybox
2590 2589
         MAINTAINER dockerio
2591 2590
         ADD foo Dockerfile /usr/lib/bla/
2592
-		RUN [ "$(cat /usr/lib/bla/foo)" = "hello" ]`
2591
+		RUN sh -c "[ $(cat /usr/lib/bla/foo) = "hello" ]"`
2593 2592
 	ctx, err := fakeContext(dockerfile, map[string]string{
2594 2593
 		"foo": "hello",
2595 2594
 	})
... ...
@@ -2613,14 +2644,13 @@ func (s *DockerSuite) TestBuildAddMultipleLocalFileWithCache(c *check.C) {
2613 2613
 func (s *DockerSuite) TestBuildAddLocalFileWithoutCache(c *check.C) {
2614 2614
 	// local files are not owned by the correct user
2615 2615
 	testRequires(c, NotUserNamespace)
2616
-	testRequires(c, DaemonIsLinux)
2617 2616
 	name := "testbuildaddlocalfilewithoutcache"
2618 2617
 	name2 := "testbuildaddlocalfilewithoutcache2"
2619 2618
 	dockerfile := `
2620 2619
 		FROM busybox
2621 2620
         MAINTAINER dockerio
2622 2621
         ADD foo /usr/lib/bla/bar
2623
-		RUN [ "$(cat /usr/lib/bla/bar)" = "hello" ]`
2622
+		RUN sh -c "[ $(cat /usr/lib/bla/bar) = "hello" ]"`
2624 2623
 	ctx, err := fakeContext(dockerfile, map[string]string{
2625 2624
 		"foo": "hello",
2626 2625
 	})
... ...
@@ -2642,11 +2672,11 @@ func (s *DockerSuite) TestBuildAddLocalFileWithoutCache(c *check.C) {
2642 2642
 }
2643 2643
 
2644 2644
 func (s *DockerSuite) TestBuildCopyDirButNotFile(c *check.C) {
2645
-	testRequires(c, DaemonIsLinux)
2646 2645
 	name := "testbuildcopydirbutnotfile"
2647 2646
 	name2 := "testbuildcopydirbutnotfile2"
2647
+
2648 2648
 	dockerfile := `
2649
-        FROM scratch
2649
+        FROM ` + minimalBaseImage() + `
2650 2650
         COPY dir /tmp/`
2651 2651
 	ctx, err := fakeContext(dockerfile, map[string]string{
2652 2652
 		"dir/foo": "hello",