Skip to content

Commit

Permalink
tests: Include commands and directory in run output (#5254)
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis committed Jan 20, 2021
1 parent 74087e3 commit 189701d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions integration/skaffold/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (b *RunBuilder) runForked(t *testing.T, out io.Writer) {

cmd := b.cmd(ctx)
cmd.Stdout = out
logrus.Infoln(cmd.Args)
logrus.Infof("Running %s in %s", cmd.Args, cmd.Dir)

start := time.Now()
if err := cmd.Start(); err != nil {
Expand All @@ -214,7 +214,7 @@ func (b *RunBuilder) runForked(t *testing.T, out io.Writer) {

go func() {
cmd.Wait()
logrus.Infoln("Ran in", util.ShowHumanizeTime(time.Since(start)))
logrus.Infof("Ran %s in %v", cmd.Args, util.ShowHumanizeTime(time.Since(start)))
}()

t.Cleanup(func() {
Expand All @@ -234,13 +234,13 @@ func (b *RunBuilder) Run(t *testing.T) error {
t.Helper()

cmd := b.cmd(context.Background())
logrus.Infoln(cmd.Args)
logrus.Infof("Running %s in %s", cmd.Args, cmd.Dir)

start := time.Now()
if err := cmd.Run(); err != nil {
return fmt.Errorf("skaffold %q: %w", b.command, err)
}
logrus.Infoln("Ran in", util.ShowHumanizeTime(time.Since(start)))
logrus.Infof("Ran %s in %v", cmd.Args, util.ShowHumanizeTime(time.Since(start)))
return nil
}

Expand All @@ -250,14 +250,14 @@ func (b *RunBuilder) RunWithCombinedOutput(t *testing.T) ([]byte, error) {

cmd := b.cmd(context.Background())
cmd.Stdout, cmd.Stderr = nil, nil
logrus.Infoln(cmd.Args)
logrus.Infof("Running %s in %s", cmd.Args, cmd.Dir)

start := time.Now()
out, err := cmd.CombinedOutput()
if err != nil {
return out, fmt.Errorf("skaffold %q: %w", b.command, err)
}
logrus.Infoln("Ran in", util.ShowHumanizeTime(time.Since(start)))
logrus.Infof("Ran %s in %v", cmd.Args, util.ShowHumanizeTime(time.Since(start)))
return out, nil
}

Expand All @@ -269,7 +269,7 @@ func (b *RunBuilder) RunOrFailOutput(t *testing.T) []byte {

cmd := b.cmd(context.Background())
cmd.Stdout, cmd.Stderr = nil, nil
logrus.Infoln(cmd.Args)
logrus.Infof("Running %s in %s", cmd.Args, cmd.Dir)

start := time.Now()
out, err := cmd.Output()
Expand All @@ -279,7 +279,7 @@ func (b *RunBuilder) RunOrFailOutput(t *testing.T) []byte {
}
t.Fatalf("skaffold %s: %v, %s", b.command, err, out)
}
logrus.Infoln("Ran in", util.ShowHumanizeTime(time.Since(start)))
logrus.Infof("Ran %s in %v", cmd.Args, util.ShowHumanizeTime(time.Since(start)))
return out
}

Expand Down

0 comments on commit 189701d

Please sign in to comment.