Browse code

Remove use of 'bash' from our tests

Not 100% sure why our Windows test don't complain about some of these,
I'm guessing it because we have bash as part of some git package, but
either way we really shouldn't require bash to run our tests unless we
really need to - which in these cases we don't

Signed-off-by: Doug Davis <dug@us.ibm.com>

Doug Davis authored on 2015/05/17 03:04:25
Showing 3 changed files
... ...
@@ -69,7 +69,8 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *check.C) {
69 69
 }
70 70
 
71 71
 func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) {
72
-	runCmd := exec.Command("bash", "-c", `echo "blahblah" | docker run -i -a stdin busybox cat`)
72
+	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat")
73
+	runCmd.Stdin = strings.NewReader("blahblah")
73 74
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
74 75
 	if err != nil {
75 76
 		c.Fatalf("failed to run container: %v, output: %q", err, out)
... ...
@@ -179,7 +179,8 @@ func (s *DockerSuite) TestRunExitCodeOne(c *check.C) {
179 179
 // it should be possible to pipe in data via stdin to a process running in a container
180 180
 // some versions of lxc might make this test fail
181 181
 func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
182
-	runCmd := exec.Command("bash", "-c", `echo "blahblah" | docker run -i -a stdin busybox cat`)
182
+	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat")
183
+	runCmd.Stdin = strings.NewReader("blahblah")
183 184
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
184 185
 	if err != nil {
185 186
 		c.Fatalf("failed to run container: %v, output: %q", err, out)
... ...
@@ -4,7 +4,7 @@ package main
4 4
 
5 5
 import (
6 6
 	"bytes"
7
-	"fmt"
7
+	"io/ioutil"
8 8
 	"os"
9 9
 	"os/exec"
10 10
 	"strings"
... ...
@@ -41,17 +41,25 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
41 41
 		c.Fatalf("the repo should exist before saving it: %s, %v", before, err)
42 42
 	}
43 43
 
44
-	saveCmdTemplate := `%v save %v > /tmp/foobar-save-load-test.tar`
45
-	saveCmdFinal := fmt.Sprintf(saveCmdTemplate, dockerBinary, repoName)
46
-	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
47
-	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
48
-		c.Fatalf("failed to save repo: %s, %v", out, err)
44
+	tmpFile, err := ioutil.TempFile("", "foobar-save-load-test.tar")
45
+	c.Assert(err, check.IsNil)
46
+	defer os.Remove(tmpFile.Name())
47
+
48
+	saveCmd := exec.Command(dockerBinary, "save", repoName)
49
+	saveCmd.Stdout = tmpFile
50
+
51
+	if _, err = runCommand(saveCmd); err != nil {
52
+		c.Fatalf("failed to save repo: %v", err)
49 53
 	}
50 54
 
55
+	tmpFile, err = os.Open(tmpFile.Name())
56
+	c.Assert(err, check.IsNil)
57
+
51 58
 	deleteImages(repoName)
52 59
 
53
-	loadCmdFinal := `cat /tmp/foobar-save-load-test.tar | docker load`
54
-	loadCmd := exec.Command("bash", "-c", loadCmdFinal)
60
+	loadCmd := exec.Command(dockerBinary, "load")
61
+	loadCmd.Stdin = tmpFile
62
+
55 63
 	if out, _, err = runCommandWithOutput(loadCmd); err != nil {
56 64
 		c.Fatalf("failed to load repo: %s, %v", out, err)
57 65
 	}
... ...
@@ -69,8 +77,6 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
69 69
 	deleteContainer(cleanedContainerID)
70 70
 	deleteImages(repoName)
71 71
 
72
-	os.Remove("/tmp/foobar-save-load-test.tar")
73
-
74 72
 	pty, tty, err := pty.Open()
75 73
 	if err != nil {
76 74
 		c.Fatalf("Could not open pty: %v", err)