Commit fffb3a5c authored by Yury Smolsky's avatar Yury Smolsky Committed by Marcel van Lohuizen

testing: make indentation consistent in sub-tests

Instead of mixed usage of spaces and tabs for indentation,
just use 4 spaces instead of one tab.

This test:

func TestX(t *testing.T) {
	t.Error("1\nnew line")
	t.Error("2")
	t.Error("3")
	t.Run("Y", func(t *testing.T) {
		t.Error("2")
		t.Error("2b\nnew line")
		t.Run("Z", func(t *testing.T) {
			t.Error("3\nnew line")
		})
	})
	t.Error("4")
}

produces following output:

--- FAIL: TestX (0.00s)
    indent_test.go:6: 1
	new line
    indent_test.go:7: 2
    indent_test.go:8: 3
    --- FAIL: TestX/Y (0.00s)
	indent_test.go:10: 2
	indent_test.go:11: 2b
	    new line
	--- FAIL: TestX/Y/Z (0.00s)
	    indent_test.go:13: 3
		new line
    indent_test.go:16: 4
FAIL

Fixes #25369

Change-Id: Ib3b5da45ab3ee670c6e8a23172e7cbefb94c5e60
Reviewed-on: https://go-review.googlesource.com/113177
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMarcel van Lohuizen <mpvl@golang.org>
parent 3c4d3bdd
...@@ -394,7 +394,7 @@ func (c *common) frameSkip(skip int) runtime.Frame { ...@@ -394,7 +394,7 @@ func (c *common) frameSkip(skip int) runtime.Frame {
} }
// decorate prefixes the string with the file and line of the call site // decorate prefixes the string with the file and line of the call site
// and inserts the final newline if needed and indentation tabs for formatting. // and inserts the final newline if needed and indentation spaces for formatting.
// This function must be called with c.mu held. // This function must be called with c.mu held.
func (c *common) decorate(s string) string { func (c *common) decorate(s string) string {
frame := c.frameSkip(3) // decorate + log + public function. frame := c.frameSkip(3) // decorate + log + public function.
...@@ -414,8 +414,8 @@ func (c *common) decorate(s string) string { ...@@ -414,8 +414,8 @@ func (c *common) decorate(s string) string {
line = 1 line = 1
} }
buf := new(strings.Builder) buf := new(strings.Builder)
// Every line is indented at least one tab. // Every line is indented at least 4 spaces.
buf.WriteByte('\t') buf.WriteString(" ")
fmt.Fprintf(buf, "%s:%d: ", file, line) fmt.Fprintf(buf, "%s:%d: ", file, line)
lines := strings.Split(s, "\n") lines := strings.Split(s, "\n")
if l := len(lines); l > 1 && lines[l-1] == "" { if l := len(lines); l > 1 && lines[l-1] == "" {
...@@ -423,8 +423,8 @@ func (c *common) decorate(s string) string { ...@@ -423,8 +423,8 @@ func (c *common) decorate(s string) string {
} }
for i, line := range lines { for i, line := range lines {
if i > 0 { if i > 0 {
// Second and subsequent lines are indented an extra tab. // Second and subsequent lines are indented an additional 4 spaces.
buf.WriteString("\n\t\t") buf.WriteString("\n ")
} }
buf.WriteString(line) buf.WriteString(line)
} }
......
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