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

Unified Diff: go/src/infra/tools/drover/util.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 2 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/src/infra/tools/drover/merge.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/drover/util.go
diff --git a/go/src/infra/tools/drover/util.go b/go/src/infra/tools/drover/util.go
new file mode 100644
index 0000000000000000000000000000000000000000..ca57b99ba96aa5d98bbb0deeb4ba102b6249ab9b
--- /dev/null
+++ b/go/src/infra/tools/drover/util.go
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "strings"
+)
+
+func failIf(err error) {
+ if err != nil {
+ fmt.Println("fatal:", err)
+ os.Exit(1)
+ }
+}
+
+func SplitLines(data string) []string {
+ return strings.Split(strings.TrimRight(data, "\n"), "\n")
+}
+
+func Shell(dir string) bool {
+ shell := os.Getenv("SHELL")
+ if shell == "" {
+ shell = DefaultShell
+ }
+ shell, err := exec.LookPath(shell)
+ failIf(err)
+ p, err := os.StartProcess(shell, []string{shell}, &os.ProcAttr{
+ Dir: dir,
+ Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
+ })
+ failIf(err)
+ s, err := p.Wait()
+ failIf(err)
+
+ return s.Success()
+}
« no previous file with comments | « go/src/infra/tools/drover/merge.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698