mirror of
https://github.com/golang/go
synced 2024-11-21 22:04:39 -07:00
gotest: Fix fix for \r\n on windows.
R=rsc, brainman, rh, r2 CC=golang-dev https://golang.org/cl/4366045
This commit is contained in:
parent
db5c5d6fa6
commit
ddd0fa1744
@ -234,15 +234,14 @@ 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 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 {
|
if len(s) == 0 {
|
||||||
Fatalf("no output from command %s", strings.Join(argv, " "))
|
Fatalf("no output from command %s", strings.Join(argv, " "))
|
||||||
}
|
}
|
||||||
if s[len(s)-1] == '\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]
|
|
||||||
}
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user