v.io/x/devtools/jiri-test: continue to move to runutil.Sequence.

MultiPart: 2/2
Change-Id: I86128fe78efdb2ee1aaef99f0c859c3bf67b6868
diff --git a/runutil/.api b/runutil/.api
index d636801..9969ef5 100644
--- a/runutil/.api
+++ b/runutil/.api
@@ -3,6 +3,7 @@
 pkg runutil, func IsFNLHost() bool
 pkg runutil, func IsNotExist(error) bool
 pkg runutil, func IsPermission(error) bool
+pkg runutil, func IsTimeout(error) bool
 pkg runutil, func LookPath(string, map[string]string) (string, error)
 pkg runutil, func NewRun(map[string]string, io.Reader, io.Writer, io.Writer, bool, bool, bool) *Run
 pkg runutil, func NewSequence(map[string]string, io.Reader, io.Writer, io.Writer, bool, bool, bool) *Sequence
@@ -88,4 +89,3 @@
 pkg runutil, type Run struct
 pkg runutil, type Sequence struct
 pkg runutil, type Start struct
-pkg runutil, var CommandTimedOutErr error
diff --git a/runutil/executor.go b/runutil/executor.go
index 31f2fff..79ed5ad 100644
--- a/runutil/executor.go
+++ b/runutil/executor.go
@@ -178,7 +178,7 @@
 		if opts.Verbose {
 			e.printf(e.opts.Stdout, "TIMED OUT")
 		}
-		return CommandTimedOutErr
+		return commandTimedOutErr
 	case err := <-done:
 		if err != nil {
 			if opts.Verbose {
diff --git a/runutil/run.go b/runutil/run.go
index 60d876c..6b276e6 100644
--- a/runutil/run.go
+++ b/runutil/run.go
@@ -14,7 +14,7 @@
 )
 
 var (
-	CommandTimedOutErr = fmt.Errorf("command timed out")
+	commandTimedOutErr = fmt.Errorf("command timed out")
 )
 
 type Run struct {
diff --git a/runutil/run_test.go b/runutil/run_test.go
index a408e59..f253505 100644
--- a/runutil/run_test.go
+++ b/runutil/run_test.go
@@ -113,7 +113,7 @@
 	}
 	if err := run.TimedCommand(timedCommandTimeout, bin); err == nil {
 		t.Fatalf(`TimedCommand("go run ./testdata/slow_hello.go") did not fail when it should`)
-	} else if got, want := err, CommandTimedOutErr; got != want {
+	} else if got, want := IsTimeout(err), true; got != want {
 		t.Fatalf("unexpected error: got %v, want %v", got, want)
 	}
 	if got, want := removeTimestamps(t, &out), fmt.Sprintf(">> %s\nhello\n>> TIMED OUT\n", bin); got != want {
@@ -151,7 +151,7 @@
 	opts.Stdout = &cmdOut
 	if err := run.TimedCommandWithOpts(timedCommandTimeout, opts, bin); err == nil {
 		t.Fatalf(`TimedCommandWithOpts("go run ./testdata/slow_hello.go") did not fail when it should`)
-	} else if got, want := err, CommandTimedOutErr; got != want {
+	} else if got, want := IsTimeout(err), true; got != want {
 		t.Fatalf("unexpected error: got %v, want %v", got, want)
 	}
 	if got, want := removeTimestamps(t, &runOut), fmt.Sprintf(">> %s\n>> TIMED OUT\n", bin); got != want {
diff --git a/runutil/sequence.go b/runutil/sequence.go
index a41413d..01f6941 100644
--- a/runutil/sequence.go
+++ b/runutil/sequence.go
@@ -211,6 +211,15 @@
 	return os.IsPermission(err)
 }
 
+// IsTimeout returns a boolean indicating whether the error is a result of
+// a timeout.
+func IsTimeout(err error) bool {
+	if we, ok := err.(*wrappedError); ok {
+		return we.oe == commandTimedOutErr
+	}
+	return err == commandTimedOutErr
+}
+
 func fmtError(depth int, err error, detail string) string {
 	_, file, line, _ := runtime.Caller(depth + 1)
 	return fmt.Sprintf("%s:%d: %s", filepath.Base(file), line, detail)