Browse code

integ-cli: Skip some unix-specific cli tests

Skipping some of the tests closely tied to running in a
unix environment. Windows does not support chmod/chown
and this causes some tests to fail creating desired
behavior.

- `TestBuildWithInaccessibleFilesInContext`: uses chown/chmod
- `TestBuildDockerfileOutsideContext`: uses os.Symlink, not implemented on
windows
- `TestCpUnprivilegedUser`: uses chmod, and requires 'unprivilegeduser'
created by Dockerfile (and thus requires to run inside container)
- `TestBuildChownSingleFile`: uses chown

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>

Ahmet Alp Balkan authored on 2015/02/20 18:37:27
Showing 5 changed files
... ...
@@ -1673,6 +1673,8 @@ func TestBuildAddBadLinksVolume(t *testing.T) {
1673 1673
 // Issue #5270 - ensure we throw a better error than "unexpected EOF"
1674 1674
 // when we can't access files in the context.
1675 1675
 func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
1676
+	testRequires(t, UnixCli) // test uses chown/chmod: not available on windows
1677
+
1676 1678
 	{
1677 1679
 		name := "testbuildinaccessiblefiles"
1678 1680
 		defer deleteImages(name)
... ...
@@ -4387,6 +4389,8 @@ func TestBuildStderr(t *testing.T) {
4387 4387
 }
4388 4388
 
4389 4389
 func TestBuildChownSingleFile(t *testing.T) {
4390
+	testRequires(t, UnixCli) // test uses chown: not available on windows
4391
+
4390 4392
 	name := "testbuildchownsinglefile"
4391 4393
 	defer deleteImages(name)
4392 4394
 
... ...
@@ -4658,6 +4662,8 @@ func TestBuildFromOfficialNames(t *testing.T) {
4658 4658
 }
4659 4659
 
4660 4660
 func TestBuildDockerfileOutsideContext(t *testing.T) {
4661
+	testRequires(t, UnixCli) // uses os.Symlink: not implemented in windows at the time of writing (go-1.4.2)
4662
+
4661 4663
 	name := "testbuilddockerfileoutsidecontext"
4662 4664
 	tmpdir, err := ioutil.TempDir("", name)
4663 4665
 	if err != nil {
... ...
@@ -347,6 +347,8 @@ func TestCpSymlinkComponent(t *testing.T) {
347 347
 
348 348
 // Check that cp with unprivileged user doesn't return any error
349 349
 func TestCpUnprivilegedUser(t *testing.T) {
350
+	testRequires(t, UnixCli) // uses chmod/su: not available on windows
351
+
350 352
 	out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName)
351 353
 	if err != nil || exitCode != 0 {
352 354
 		t.Fatal("failed to create a container", out, err)
... ...
@@ -17,6 +17,10 @@ var (
17 17
 		func() bool { return isLocalDaemon },
18 18
 		"Test requires docker daemon to runs on the same machine as CLI",
19 19
 	}
20
+	UnixCli = TestRequirement{
21
+		func() bool { return isUnixCli },
22
+		"Test requires posix utilities or functionality to run.",
23
+	}
20 24
 )
21 25
 
22 26
 // testRequires checks if the environment satisfies the requirements
23 27
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+const (
5
+	// idetifies if test suite is running on a unix platform
6
+	isUnixCli = true
7
+)
0 8
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+// +build windows
1
+
2
+package main
3
+
4
+const (
5
+	// idetifies if test suite is running on a unix platform
6
+	isUnixCli = false
7
+)