diff options
| author | David Chase <drchase@google.com> | 2023-05-10 19:29:18 -0400 |
|---|---|---|
| committer | David Chase <drchase@google.com> | 2023-05-16 19:46:14 +0000 |
| commit | b3d1cce3eb26a08420d803df872721bfd370e3ed (patch) | |
| tree | bb0ea2bfddfb0a2cf644bfe24cf8ce2dd61a222d /src/cmd/compile/internal/loopvar/loopvar_test.go | |
| parent | 4cf79e479bbf334f2a5d248852b83c169a11c727 (diff) | |
| download | go-b3d1cce3eb26a08420d803df872721bfd370e3ed.tar.xz | |
cmd/compile: add more information to the bisect-verbose report
running on cmd/compile/internal/testdata/inlines now shows:
```
--- change set #1 (enabling changes causes failure)
b/b.go:16:6: loop variable i now per-iteration (loop inlined into b/b.go:10)
b/b.go:16:6: loop variable i now per-iteration
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into a/a.go:18)
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into ./main.go:37)
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into ./main.go:38)
---
```
and
```
--- change set #2 (enabling changes causes failure)
./main.go:27:6: loop variable i now per-iteration
./main.go:27:6: loop variable i now per-iteration (loop inlined into ./main.go:35)
---
```
Still unsure about the utility of mentioning the inlined occurrence, but better
than mysteriously repeating the line over and over again.
Change-Id: I357f5d419ab4928fa316f4612eec3b75e7f8ac34
Reviewed-on: https://go-review.googlesource.com/c/go/+/494296
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/loopvar/loopvar_test.go')
| -rw-r--r-- | src/cmd/compile/internal/loopvar/loopvar_test.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/loopvar/loopvar_test.go b/src/cmd/compile/internal/loopvar/loopvar_test.go index d48b5ada7f..03e6eec437 100644 --- a/src/cmd/compile/internal/loopvar/loopvar_test.go +++ b/src/cmd/compile/internal/loopvar/loopvar_test.go @@ -8,6 +8,7 @@ import ( "internal/testenv" "os/exec" "path/filepath" + "regexp" "runtime" "strings" "testing" @@ -159,6 +160,11 @@ func TestLoopVarInlines(t *testing.T) { } } +func countMatches(s, re string) int { + slice := regexp.MustCompile(re).FindAllString(s, -1) + return len(slice) +} + func TestLoopVarHashes(t *testing.T) { switch runtime.GOOS { case "linux", "darwin": @@ -195,7 +201,7 @@ func TestLoopVarHashes(t *testing.T) { m := f(arg) t.Logf(m) - mCount := strings.Count(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 001100110110110010100100") + mCount := countMatches(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6: .* 001100110110110010100100") otherCount := strings.Count(m, "loopvarhash") if mCount < 1 { t.Errorf("%s: did not see triggered main.go:27:6", arg) @@ -203,8 +209,7 @@ func TestLoopVarHashes(t *testing.T) { if mCount != otherCount { t.Errorf("%s: too many matches", arg) } - - mCount = strings.Count(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 [bisect-match 0x7802e115b9336ca4]") + mCount = countMatches(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6: .* \\[bisect-match 0x7802e115b9336ca4\\]") otherCount = strings.Count(m, "[bisect-match ") if mCount < 1 { t.Errorf("%s: did not see bisect-match for main.go:27:6", arg) |
