]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: print lines missing is_stmt if testing.Verbose()
authorDavid Chase <drchase@google.com>
Mon, 29 Jul 2019 20:26:40 +0000 (16:26 -0400)
committerDavid Chase <drchase@google.com>
Fri, 30 Aug 2019 20:11:59 +0000 (20:11 +0000)
helpful for debugging failures to figure out which lines
disappeared to cause the failure.

Change-Id: Id42b64a65f76eed47e01003f05346bc09cec27e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/188019
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/compile/internal/ssa/stmtlines_test.go

index b8a9388b6143f67a85a615b8ff94d40bb414f173..f5ff3a59272dbff75ee2d34b3683c5ca1290cad7 100644 (file)
@@ -12,6 +12,7 @@ import (
        "io"
        "os"
        "runtime"
+       "sort"
        "testing"
 )
 
@@ -109,11 +110,23 @@ func TestStmtLines(t *testing.T) {
                }
        }
 
-       if runtime.GOARCH == "amd64" && len(nonStmtLines)*100 > len(lines) { // > 99% obtained on amd64, no backsliding
-               t.Errorf("Saw too many (amd64, > 1%%) lines without statement marks, total=%d, nostmt=%d\n", len(lines), len(nonStmtLines))
+       if runtime.GOARCH == "amd64" {
+               if len(nonStmtLines)*100 > len(lines) { // > 99% obtained on amd64, no backsliding
+                       t.Errorf("Saw too many (amd64, > 1%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", len(lines), len(nonStmtLines))
+               }
+       } else if len(nonStmtLines)*100 > 2*len(lines) { // expect 98% elsewhere.
+               t.Errorf("Saw too many (not amd64, > 2%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", len(lines), len(nonStmtLines))
        }
-       if len(nonStmtLines)*100 > 2*len(lines) { // expect 98% elsewhere.
-               t.Errorf("Saw too many (not amd64, > 2%%) lines without statement marks, total=%d, nostmt=%d\n", len(lines), len(nonStmtLines))
+       if testing.Verbose() {
+               sort.Slice(nonStmtLines, func(i, j int) bool {
+                       if nonStmtLines[i].File != nonStmtLines[j].File {
+                               return nonStmtLines[i].File < nonStmtLines[j].File
+                       }
+                       return nonStmtLines[i].Line < nonStmtLines[j].Line
+               })
+               for _, l := range nonStmtLines {
+                       t.Logf("%s:%d has no DWARF is_stmt mark\n", l.File, l.Line)
+               }
        }
        t.Logf("total=%d, nostmt=%d\n", len(lines), len(nonStmtLines))
 }