1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix 'docker ps --help' so the options don't span more than one line

and add a testcase to catch this in the future.

While in there I also:
- removed extra periods from the few options that had them (new test)
- made the --filter option consistent across all command

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2015-03-03 09:04:06 -08:00
parent 8e107a9321
commit 5595da2bde
4 changed files with 42 additions and 30 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/docker/docker/pkg/homedir"
)
func TestHelpWidth(t *testing.T) {
func TestHelpTextVerify(t *testing.T) {
// Make sure main help text fits within 80 chars and that
// on non-windows system we use ~ when possible (to shorten things).
// Test for HOME set to its default value and set to "/" on linux
@ -58,6 +58,7 @@ func TestHelpWidth(t *testing.T) {
if len(line) > 80 {
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
}
if scanForHome && strings.Contains(line, `=`+home) {
t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
}
@ -108,6 +109,7 @@ func TestHelpWidth(t *testing.T) {
t.Fatalf("Help for %q is too long(%d chars):\n%s", cmd,
len(line), line)
}
if scanForHome && strings.Contains(line, `"`+home) {
t.Fatalf("Help for %q should use ~ instead of %q on:\n%s",
cmd, home, line)
@ -116,6 +118,18 @@ func TestHelpWidth(t *testing.T) {
if i >= 0 && i != len(line)-1 && line[i+1] != '/' {
t.Fatalf("Help for %q should not have used ~:\n%s", cmd, line)
}
// If a line starts with 4 spaces then assume someone
// added a multi-line description for an option and we need
// to flag it
if strings.HasPrefix(line, " ") {
t.Fatalf("Help for %q should not have a multi-line option: %s", cmd, line)
}
// Options should NOT end with a period
if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") {
t.Fatalf("Help for %q should not end with a period: %s", cmd, line)
}
}
}
@ -126,5 +140,5 @@ func TestHelpWidth(t *testing.T) {
}
}
logDone("help - widths")
logDone("help - verify text")
}