Commit ddd0fa17 authored by Rob Pike's avatar Rob Pike

gotest: Fix fix for \r\n on windows.

R=rsc, brainman, rh, r2
CC=golang-dev
https://golang.org/cl/4366045
parent db5c5d6f
...@@ -234,14 +234,13 @@ func run(args ...string) { ...@@ -234,14 +234,13 @@ func run(args ...string) {
// runWithStdout is like run, but returns the text of standard output with the last newline dropped. // runWithStdout is like run, but returns the text of standard output with the last newline dropped.
func runWithStdout(argv ...string) string { func runWithStdout(argv ...string) string {
s := doRun(argv, true) s := doRun(argv, true)
if len(s) == 0 { if strings.HasSuffix(s, "\r\n") {
Fatalf("no output from command %s", strings.Join(argv, " ")) s = s[:len(s)-2]
} } else if strings.HasSuffix(s, "\n") {
if s[len(s)-1] == '\n' {
s = s[:len(s)-1] s = s[:len(s)-1]
} }
if len(s) > 0 && s[len(s)-1] == '\r' { // it is \r\n on Windows. if len(s) == 0 {
s = s[:len(s)-1] Fatalf("no output from command %s", strings.Join(argv, " "))
} }
return s return s
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment