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) {
// runWithStdout is like run, but returns the text of standard output with the last newline dropped.
func runWithStdout(argv ...string) string {
s := doRun(argv, true)
if len(s) == 0 {
Fatalf("no output from command %s", strings.Join(argv, " "))
}
if s[len(s)-1] == '\n' {
if strings.HasSuffix(s, "\r\n") {
s = s[:len(s)-2]
} else if strings.HasSuffix(s, "\n") {
s = s[:len(s)-1]
}
if len(s) > 0 && s[len(s)-1] == '\r' { // it is \r\n on Windows.
s = s[:len(s)-1]
if len(s) == 0 {
Fatalf("no output from command %s", strings.Join(argv, " "))
}
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