Add --help to "docker volume inspect --help" output

Closes #16146

While in there, modified the testing infrastructure for the help text
so that we can get commands with nested commands - like "volume".

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: 87255b6721f4dc02ae34696f2013537fdc967a99
Component: engine
This commit is contained in:
Doug Davis
2015-09-08 14:24:00 -07:00
parent 03dac92f8b
commit d879adf33b
2 changed files with 31 additions and 12 deletions
@@ -101,9 +101,10 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
// Skip first line
helpOut = helpOut[1:]
}
for _, cmd := range helpOut {
var stderr string
// Create the list of commands we want to test
cmdsToTest := []string{}
for _, cmd := range helpOut {
// Stop on blank line or non-idented line
if cmd == "" || !unicode.IsSpace(rune(cmd[0])) {
break
@@ -111,10 +112,25 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
// Grab just the first word of each line
cmd = strings.Split(strings.TrimSpace(cmd), " ")[0]
cmds = append(cmds, cmd)
cmds = append(cmds, cmd) // Saving count for later
cmdsToTest = append(cmdsToTest, cmd)
}
// Add some 'two word' commands - would be nice to automatically
// calculate this list - somehow
cmdsToTest = append(cmdsToTest, "volume create")
cmdsToTest = append(cmdsToTest, "volume inspect")
cmdsToTest = append(cmdsToTest, "volume ls")
cmdsToTest = append(cmdsToTest, "volume rm")
for _, cmd := range cmdsToTest {
var stderr string
args := strings.Split(cmd+" --help", " ")
// Check the full usage text
helpCmd := exec.Command(dockerBinary, cmd, "--help")
helpCmd := exec.Command(dockerBinary, args...)
helpCmd.Env = newEnvs
out, stderr, ec, err = runCommandWithStdoutStderr(helpCmd)
if len(stderr) != 0 {
@@ -168,7 +184,9 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
// For each command make sure we generate an error
// if we give a bad arg
dCmd := exec.Command(dockerBinary, cmd, "--badArg")
args = strings.Split(cmd+" --badArg", " ")
dCmd := exec.Command(dockerBinary, args...)
out, stderr, ec, err = runCommandWithStdoutStderr(dCmd)
if len(out) != 0 || len(stderr) == 0 || ec == 0 || err == nil {
c.Fatalf("Bad results from 'docker %s --badArg'\nec:%d\nstdout:%s\nstderr:%s\nerr:%q", cmd, ec, out, stderr, err)
@@ -209,14 +227,14 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
ec = 0
if _, ok := skipNoArgs[cmd]; !ok {
args = []string{cmd}
args = strings.Split(cmd, " ")
dCmd = exec.Command(dockerBinary, args...)
stdout, stderr, ec, err = runCommandWithStdoutStderr(dCmd)
}
// If its ok w/o any args then try again with an arg
if ec == 0 {
args = []string{cmd, "badArg"}
args = strings.Split(cmd+" badArg", " ")
dCmd = exec.Command(dockerBinary, args...)
stdout, stderr, ec, err = runCommandWithStdoutStderr(dCmd)
}