mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
testing: fix output formatting
Revision 5e7fd762f356 has changed the output formatting in a way that is no longer in line with the format described by the revision ff0ade0b937b which has introduced this functionality. When decorating the first line, instead of indenting the whole line, the current implementation adds indentation right after the "decorate" part and before the "log" message. The fix addresses this issue. R=golang-dev, iant, minux.ma, r, rsc, remyoudompheng CC=golang-dev https://golang.org/cl/7304094
This commit is contained in:
parent
1903ad7189
commit
782cbb4f90
1 changed files with 3 additions and 7 deletions
|
|
@ -166,21 +166,17 @@ func decorate(s string) string {
|
|||
line = 1
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
// Every line is indented at least one tab.
|
||||
buf.WriteByte('\t')
|
||||
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')
|
||||
}
|
||||
// Every line is indented at least one tab.
|
||||
buf.WriteByte('\t')
|
||||
if i > 0 {
|
||||
// Second and subsequent lines are indented an extra tab.
|
||||
buf.WriteByte('\t')
|
||||
buf.WriteString("\n\t\t")
|
||||
}
|
||||
buf.WriteString(line)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue