Fix tests and windows service.
Support args to RunCommand Fix docker help text test. Fix for ipv6 tests. Fix TLSverify option. Fix TestDaemonDiscoveryBackendConfigReload Use tempfile for another test. Restore missing flag. Fix tests for removal of shlex. Signed-off-by: Daniel Nephin <dnephin@docker.com> Upstream-commit: 6e7405ebd4df360bc84f651c977ece31283eb3ee Component: engine
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
icmd "github.com/docker/docker/pkg/integration/cmd"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
@ -56,12 +57,7 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
|
||||
out, _, err := runCommandWithOutput(helpCmd)
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
lines := strings.Split(out, "\n")
|
||||
foundTooLongLine := false
|
||||
for _, line := range lines {
|
||||
if !foundTooLongLine && len(line) > 80 {
|
||||
c.Logf("Line is too long:\n%s", line)
|
||||
foundTooLongLine = true
|
||||
}
|
||||
// All lines should not end with a space
|
||||
c.Assert(line, checker.Not(checker.HasSuffix), " ", check.Commentf("Line should not end with a space"))
|
||||
|
||||
@ -229,14 +225,6 @@ func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) er
|
||||
// Check each line for lots of stuff
|
||||
lines := strings.Split(out, "\n")
|
||||
for _, line := range lines {
|
||||
if len(line) > 107 {
|
||||
return fmt.Errorf("Help for %q is too long:\n%s\n", cmd, line)
|
||||
}
|
||||
|
||||
if scanForHome && strings.Contains(line, `"`+home) {
|
||||
return fmt.Errorf("Help for %q should use ~ instead of %q on:\n%s\n",
|
||||
cmd, home, line)
|
||||
}
|
||||
i := strings.Index(line, "~")
|
||||
if i >= 0 && i != len(line)-1 && line[i+1] != '/' {
|
||||
return fmt.Errorf("Help for %q should not have used ~:\n%s", cmd, line)
|
||||
@ -290,10 +278,6 @@ func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) er
|
||||
}
|
||||
|
||||
if _, ok := noShortUsage[cmd]; !ok {
|
||||
// For each command run it w/o any args. It will either return
|
||||
// valid output or print a short-usage
|
||||
var dCmd *exec.Cmd
|
||||
|
||||
// skipNoArgs are ones that we don't want to try w/o
|
||||
// any args. Either because it'll hang the test or
|
||||
// lead to incorrect test result (like false negative).
|
||||
@ -305,33 +289,31 @@ func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) er
|
||||
"load": {},
|
||||
}
|
||||
|
||||
ec := 0
|
||||
var result *icmd.Result
|
||||
if _, ok := skipNoArgs[cmd]; !ok {
|
||||
args = strings.Split(cmd, " ")
|
||||
dCmd = exec.Command(dockerBinary, args...)
|
||||
out, stderr, ec, err = runCommandWithStdoutStderr(dCmd)
|
||||
result = dockerCmdWithResult(strings.Split(cmd, " ")...)
|
||||
}
|
||||
|
||||
// If its ok w/o any args then try again with an arg
|
||||
if ec == 0 {
|
||||
args = strings.Split(cmd+" badArg", " ")
|
||||
dCmd = exec.Command(dockerBinary, args...)
|
||||
out, stderr, ec, err = runCommandWithStdoutStderr(dCmd)
|
||||
if result == nil || result.ExitCode == 0 {
|
||||
result = dockerCmdWithResult(strings.Split(cmd+" badArg", " ")...)
|
||||
}
|
||||
|
||||
if len(out) != 0 || len(stderr) == 0 || ec == 0 || err == nil {
|
||||
return fmt.Errorf("Bad output from %q\nstdout:%q\nstderr:%q\nec:%d\nerr:%q\n", args, out, stderr, ec, err)
|
||||
if err := result.Compare(icmd.Expected{
|
||||
Out: icmd.None,
|
||||
Err: "\nUsage:",
|
||||
ExitCode: 1,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
// Should have just short usage
|
||||
if !strings.Contains(stderr, "\nUsage:") {
|
||||
return fmt.Errorf("Missing short usage on %q\n:%#v", args, stderr)
|
||||
}
|
||||
// But shouldn't have full usage
|
||||
|
||||
stderr := result.Stderr()
|
||||
// Shouldn't have full usage
|
||||
if strings.Contains(stderr, "--help=false") {
|
||||
return fmt.Errorf("Should not have full usage on %q\n", args)
|
||||
return fmt.Errorf("Should not have full usage on %q:%v", result.Cmd.Args, stderr)
|
||||
}
|
||||
if strings.HasSuffix(stderr, "\n\n") {
|
||||
return fmt.Errorf("Should not have a blank line on %q\n%v", args, stderr)
|
||||
return fmt.Errorf("Should not have a blank line on %q\n%v", result.Cmd.Args, stderr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user