Reviewers: golang-dev_googlegroups.com,
Message:
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),
I'd like you to review this change to
https://code.google.com/p/go/
Description:
testing: fix extra tabs when t.Log("string")
t.Log("line 1\nline 2\nline 3")
Old output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:25: line 1
line 2
line 3
PASS
New output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:24: line 1
line 2
line 3
PASS
Please review this at http://codereview.appspot.com/6613069/
Affected files:
M src/pkg/testing/testing.go
Index: src/pkg/testing/testing.go
===================================================================
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -160,6 +160,9 @@
fmt.Fprintf(buf, "%s:%d: ", file, line)
lines := strings.Split(s, "\n")
+ if l := len(lines); l > 1 && lines[l-1] == "" {
+ lines = lines[:l-1]
+ }
for i, line := range lines {
if i > 0 {
buf.WriteByte('\n')
@@ -172,10 +175,7 @@
}
buf.WriteString(line)
}
- if l := len(s); l > 0 && s[len(s)-1] != '\n' {
- // Add final new line if needed.
- buf.WriteByte('\n')
- }
+ buf.WriteByte('\n')
return buf.String()
}