diff --git a/components/engine/container.go b/components/engine/container.go index 9099d90f6f..39c19c53d4 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -107,7 +107,7 @@ type KeyValuePair struct { func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, *flag.FlagSet, error) { cmd := Subcmd("run", "[OPTIONS] IMAGE [COMMAND] [ARG...]", "Run a command in a new container") - if len(args) > 0 && args[0] != "--help" { + if os.Getenv("TEST") != "" { cmd.SetOutput(ioutil.Discard) cmd.Usage = nil } diff --git a/components/engine/runtime.go b/components/engine/runtime.go index 13cd6a8e81..002c0fe10a 100644 --- a/components/engine/runtime.go +++ b/components/engine/runtime.go @@ -208,7 +208,7 @@ func (runtime *Runtime) Destroy(container *Container) error { func (runtime *Runtime) restore() error { wheel := "-\\|/" - if os.Getenv("DEBUG") == "" { + if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" { fmt.Printf("Loading containers: ") } dir, err := ioutil.ReadDir(runtime.repository) @@ -218,7 +218,7 @@ func (runtime *Runtime) restore() error { for i, v := range dir { id := v.Name() container, err := runtime.Load(id) - if i%21 == 0 && os.Getenv("DEBUG") == "" { + if i%21 == 0 && os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" { fmt.Printf("\b%c", wheel[i%4]) } if err != nil { @@ -227,7 +227,7 @@ func (runtime *Runtime) restore() error { } utils.Debugf("Loaded container %v", container.ID) } - if os.Getenv("DEBUG") == "" { + if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" { fmt.Printf("\bdone.\n") } return nil diff --git a/components/engine/runtime_test.go b/components/engine/runtime_test.go index 83ada6dd21..a65d962fa6 100644 --- a/components/engine/runtime_test.go +++ b/components/engine/runtime_test.go @@ -72,6 +72,8 @@ func layerArchive(tarfile string) (io.Reader, error) { } func init() { + os.Setenv("TEST", "1") + // Hack to run sys init during unit testing if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" { SysInit()