Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: go/util/command.go

Issue 1290913004: Add a library for running external commands, providing timeouts and test injection. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Fix bug with nil io.Writer. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/exec/exec_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/util/command.go
diff --git a/go/util/command.go b/go/util/command.go
index f1494ad1d891b28b85d970851c1599102f553426..48db07892cc9688d8860fd01ff5df53467ff42f0 100644
--- a/go/util/command.go
+++ b/go/util/command.go
@@ -1,31 +1,12 @@
package util
import (
- "os/exec"
- "strings"
-
- "github.com/skia-dev/glog"
+ "go.skia.org/infra/go/exec"
)
// DoCmd executes the given command line string; the command being
// run is expected to not care what its current working directory is.
-// Returns the stdout and stderr. If there is an error, the
-// returned error will be of type ExitError, which the caller
-// can use to find out more about what happened.
+// Returns the stdout and stderr.
func DoCmd(commandLine string) (string, error) {
- glog.Infof("Command: %q\n", commandLine)
- programAndArgs := strings.SplitN(commandLine, " ", 2)
- program := programAndArgs[0]
- args := []string{}
- if len(programAndArgs) > 1 {
- args = strings.Split(programAndArgs[1], " ")
- }
- cmd := exec.Command(program, args...)
- message, err := cmd.CombinedOutput()
- glog.Infof("StdOut + StdErr: %s\n", string(message))
- if err != nil {
- glog.Errorf("Exit status: %s\n", err)
- return string(message), err
- }
- return string(message), nil
+ return exec.RunSimple(commandLine)
}
« no previous file with comments | « go/exec/exec_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698