Skip to content

Commit 84335b4

Browse files
Formatting
1 parent 791d838 commit 84335b4

File tree

6 files changed

+152
-150
lines changed

6 files changed

+152
-150
lines changed

_fixtures/deferloop.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package main
22

33
var intc, intd int
4+
45
func A(n int) {
56
for i := 0; i < n; i++ {
67
defer func() {
7-
intc+=10
8-
intd-=20
8+
intc += 10
9+
intd -= 20
910
}()
1011
}
1112
temp := intc
@@ -14,7 +15,7 @@ func A(n int) {
1415
}
1516

1617
func main() {
17-
intc=0
18-
intd=0
18+
intc = 0
19+
intd = 0
1920
A(2)
2021
}

_fixtures/namedeferloop.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package main
22

33
var intc, intd int
4+
45
func B() {
5-
intc+=10
6-
intd-=20
6+
intc += 10
7+
intd -= 20
78
}
89
func A(n int) {
910
for i := 0; i < n; i++ {
@@ -15,7 +16,7 @@ func A(n int) {
1516
}
1617

1718
func main() {
18-
intc=0
19-
intd=0
19+
intc = 0
20+
intd = 0
2021
A(2)
2122
}

_fixtures/nestdefer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package main
22

3+
var varc int
34

4-
var varc int
5-
func C() {
5+
func C() {
66
defer D()
7-
varc += 10*10
7+
varc += 10 * 10
88
}
99
func A() {
1010
defer C()
1111
varc = 40
1212
}
1313

1414
func D() {
15-
B()
15+
B()
1616
}
1717

1818
func B() {

_fixtures/testtracefns.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,40 +86,40 @@ func unnamedDefer() {
8686
swap()
8787
fmt.Println(intc, intd)
8888
}
89-
func formula(op string) func (int, int) int {
90-
var calc func(int, int) int
91-
if op == "add" {
92-
calc = func(m int, n int) int {
93-
res := m+n
94-
return res
95-
}
96-
} else if op == "mul" {
97-
calc = func(m int, n int) int {
98-
res := m*n
99-
return res
100-
}
101-
}
102-
return calc
89+
func formula(op string) func(int, int) int {
90+
var calc func(int, int) int
91+
if op == "add" {
92+
calc = func(m int, n int) int {
93+
res := m + n
94+
return res
95+
}
96+
} else if op == "mul" {
97+
calc = func(m int, n int) int {
98+
res := m * n
99+
return res
100+
}
101+
}
102+
return calc
103103
}
104104

105105
func op() int {
106-
calc := formula("add")
107-
res := calc(10,20)
108-
return res
106+
calc := formula("add")
107+
res := calc(10, 20)
108+
return res
109109
}
110110

111111
func assign(bar func()) {
112-
bar()
112+
bar()
113113
}
114114
func testfunc() {
115-
intc=10
116-
intd=20
115+
intc = 10
116+
intd = 20
117117
}
118118

119119
func dyn() {
120-
intc=0
121-
intd=0
122-
assign(testfunc)
120+
intc = 0
121+
intd = 0
122+
assign(testfunc)
123123
}
124124

125125
func main() {

cmd/dlv/dlv_test.go

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -991,76 +991,76 @@ func TestTraceDirRecursion(t *testing.T) {
991991
}
992992

993993
func TestTraceNestDefer(t *testing.T) {
994-
dlvbin := protest.GetDlvBinary(t)
994+
dlvbin := protest.GetDlvBinary(t)
995995

996-
expected := []byte("> goroutine(1):frame(1) main.A()\n>> goroutine(1):frame(1) main.A => ()\n > goroutine(1):frame(2) runtime.deferreturn()\n > goroutine(1):frame(3) main.C()\n >> goroutine(1):frame(3) main.C => ()\n > goroutine(1):frame(4) runtime.deferreturn()\n > goroutine(1):frame(5) main.D()\n > goroutine(1):frame(6) main.B()\n >> goroutine(1):frame(6) main.B => ()\n >> goroutine(1):frame(5) main.D => ()\n >> goroutine(1):frame(4) runtime.deferreturn => ()\n >> goroutine(1):frame(3) main.C => ()\n >> goroutine(1):frame(2) runtime.deferreturn => ()\n>> goroutine(1):frame(1) main.A => ()\n")
996+
expected := []byte("> goroutine(1):frame(1) main.A()\n>> goroutine(1):frame(1) main.A => ()\n > goroutine(1):frame(2) runtime.deferreturn()\n > goroutine(1):frame(3) main.C()\n >> goroutine(1):frame(3) main.C => ()\n > goroutine(1):frame(4) runtime.deferreturn()\n > goroutine(1):frame(5) main.D()\n > goroutine(1):frame(6) main.B()\n >> goroutine(1):frame(6) main.B => ()\n >> goroutine(1):frame(5) main.D => ()\n >> goroutine(1):frame(4) runtime.deferreturn => ()\n >> goroutine(1):frame(3) main.C => ()\n >> goroutine(1):frame(2) runtime.deferreturn => ()\n>> goroutine(1):frame(1) main.A => ()\n")
997997

998-
fixtures := protest.FindFixturesDir()
999-
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "nestdefer.go"), "main.A", "--follow-calls", "6")
1000-
rdr, err := cmd.StderrPipe()
1001-
assertNoError(err, t, "stderr pipe")
1002-
defer rdr.Close()
998+
fixtures := protest.FindFixturesDir()
999+
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "nestdefer.go"), "main.A", "--follow-calls", "6")
1000+
rdr, err := cmd.StderrPipe()
1001+
assertNoError(err, t, "stderr pipe")
1002+
defer rdr.Close()
10031003

1004-
cmd.Dir = filepath.Join(fixtures, "buildtest")
1004+
cmd.Dir = filepath.Join(fixtures, "buildtest")
10051005

1006-
assertNoError(cmd.Start(), t, "running trace")
1006+
assertNoError(cmd.Start(), t, "running trace")
10071007

1008-
output, err := io.ReadAll(rdr)
1009-
assertNoError(err, t, "ReadAll")
1008+
output, err := io.ReadAll(rdr)
1009+
assertNoError(err, t, "ReadAll")
10101010

1011-
if !bytes.Contains(output, expected) {
1012-
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1013-
}
1014-
cmd.Wait()
1011+
if !bytes.Contains(output, expected) {
1012+
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1013+
}
1014+
cmd.Wait()
10151015
}
10161016

10171017
func TestTraceUnnamedDeferLoop(t *testing.T) {
1018-
dlvbin := protest.GetDlvBinary(t)
1018+
dlvbin := protest.GetDlvBinary(t)
10191019

1020-
expected := []byte(
1021-
"> goroutine(1):frame(1) main.main()\n > goroutine(1):frame(2) main.A(2)\n >> goroutine(1):frame(2) main.A => ()\n > goroutine(1):frame(3) runtime.deferreturn()\n > goroutine(1):frame(4) main.A.func1()\n >> goroutine(1):frame(4) main.A.func1 => ()\n > goroutine(1):frame(4) main.A.func1()\n >> goroutine(1):frame(4) main.A.func1 => ()\n >> goroutine(1):frame(3) runtime.deferreturn => ()\n >> goroutine(1):frame(2) main.A => ()\n>> goroutine(1):frame(1) main.main => ()")
1020+
expected := []byte(
1021+
"> goroutine(1):frame(1) main.main()\n > goroutine(1):frame(2) main.A(2)\n >> goroutine(1):frame(2) main.A => ()\n > goroutine(1):frame(3) runtime.deferreturn()\n > goroutine(1):frame(4) main.A.func1()\n >> goroutine(1):frame(4) main.A.func1 => ()\n > goroutine(1):frame(4) main.A.func1()\n >> goroutine(1):frame(4) main.A.func1 => ()\n >> goroutine(1):frame(3) runtime.deferreturn => ()\n >> goroutine(1):frame(2) main.A => ()\n>> goroutine(1):frame(1) main.main => ()")
10221022

1023-
fixtures := protest.FindFixturesDir()
1024-
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "deferloop.go"), "main.main", "--follow-calls", "5")
1025-
rdr, err := cmd.StderrPipe()
1026-
assertNoError(err, t, "stderr pipe")
1027-
defer rdr.Close()
1023+
fixtures := protest.FindFixturesDir()
1024+
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "deferloop.go"), "main.main", "--follow-calls", "5")
1025+
rdr, err := cmd.StderrPipe()
1026+
assertNoError(err, t, "stderr pipe")
1027+
defer rdr.Close()
10281028

1029-
cmd.Dir = filepath.Join(fixtures, "buildtest")
1029+
cmd.Dir = filepath.Join(fixtures, "buildtest")
10301030

1031-
assertNoError(cmd.Start(), t, "running trace")
1031+
assertNoError(cmd.Start(), t, "running trace")
10321032

1033-
output, err := io.ReadAll(rdr)
1034-
assertNoError(err, t, "ReadAll")
1033+
output, err := io.ReadAll(rdr)
1034+
assertNoError(err, t, "ReadAll")
10351035

1036-
if !bytes.Contains(output, expected) {
1037-
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1038-
}
1039-
cmd.Wait()
1036+
if !bytes.Contains(output, expected) {
1037+
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1038+
}
1039+
cmd.Wait()
10401040
}
1041-
func TestTraceNamedDeferLoop(t *testing.T) {
1042-
dlvbin := protest.GetDlvBinary(t)
1041+
func TestTraceNamedDeferLoop(t *testing.T) {
1042+
dlvbin := protest.GetDlvBinary(t)
10431043

1044-
expected := []byte(
1045-
"> goroutine(1):frame(1) main.main()\n > goroutine(1):frame(2) main.A(2)\n >> goroutine(1):frame(2) main.A => ()\n > goroutine(1):frame(3) runtime.deferreturn()\n > goroutine(1):frame(4) main.B()\n >> goroutine(1):frame(4) main.B => ()\n > goroutine(1):frame(4) main.B()\n >> goroutine(1):frame(4) main.B => ()\n >> goroutine(1):frame(3) runtime.deferreturn => ()\n >> goroutine(1):frame(2) main.A => ()\n>> goroutine(1):frame(1) main.main => ()")
1044+
expected := []byte(
1045+
"> goroutine(1):frame(1) main.main()\n > goroutine(1):frame(2) main.A(2)\n >> goroutine(1):frame(2) main.A => ()\n > goroutine(1):frame(3) runtime.deferreturn()\n > goroutine(1):frame(4) main.B()\n >> goroutine(1):frame(4) main.B => ()\n > goroutine(1):frame(4) main.B()\n >> goroutine(1):frame(4) main.B => ()\n >> goroutine(1):frame(3) runtime.deferreturn => ()\n >> goroutine(1):frame(2) main.A => ()\n>> goroutine(1):frame(1) main.main => ()")
10461046

1047-
fixtures := protest.FindFixturesDir()
1048-
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "namedeferloop.go"), "main.main", "--follow-calls", "5")
1049-
rdr, err := cmd.StderrPipe()
1050-
assertNoError(err, t, "stderr pipe")
1051-
defer rdr.Close()
1047+
fixtures := protest.FindFixturesDir()
1048+
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "namedeferloop.go"), "main.main", "--follow-calls", "5")
1049+
rdr, err := cmd.StderrPipe()
1050+
assertNoError(err, t, "stderr pipe")
1051+
defer rdr.Close()
10521052

1053-
cmd.Dir = filepath.Join(fixtures, "buildtest")
1053+
cmd.Dir = filepath.Join(fixtures, "buildtest")
10541054

1055-
assertNoError(cmd.Start(), t, "running trace")
1055+
assertNoError(cmd.Start(), t, "running trace")
10561056

1057-
output, err := io.ReadAll(rdr)
1058-
assertNoError(err, t, "ReadAll")
1057+
output, err := io.ReadAll(rdr)
1058+
assertNoError(err, t, "ReadAll")
10591059

1060-
if !bytes.Contains(output, expected) {
1061-
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1062-
}
1063-
cmd.Wait()
1060+
if !bytes.Contains(output, expected) {
1061+
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
1062+
}
1063+
cmd.Wait()
10641064
}
10651065
func TestTraceMultipleGoroutines(t *testing.T) {
10661066
dlvbin := protest.GetDlvBinary(t)

0 commit comments

Comments
 (0)