From ca886e0673ab1e199b722d4828b35f6a9c995cbf Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 16 Nov 2017 11:49:33 -0500 Subject: [PATCH] cmd/go/internal/cache: fix build failure introduced in CL 78176 Maybe a bad git merge - not sure. In any event, I do miss the trybots. Noticed while fixing: change print-to-stderr+panic to pure panic, just so that the test (which catches the panic) does not print any errors before passing. Change-Id: If25153ea64e81066455401110ae7a79c36f2f712 Reviewed-on: https://go-review.googlesource.com/78316 Run-TryBot: Russ Cox Reviewed-by: Russ Cox --- src/cmd/go/internal/cache/cache.go | 4 ++-- src/cmd/go/internal/cache/cache_test.go | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cmd/go/internal/cache/cache.go b/src/cmd/go/internal/cache/cache.go index 1fc9ff9b6b..311cd89f33 100644 --- a/src/cmd/go/internal/cache/cache.go +++ b/src/cmd/go/internal/cache/cache.go @@ -229,9 +229,9 @@ func (c *Cache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify if verify && allowVerify { old, err := c.get(id) if err == nil && (old.OutputID != out || old.Size != size) { - fmt.Fprintf(os.Stderr, "go: internal cache error: id=%x changed:<<<\n%s\n>>>\nold: %x %d\nnew: %x %d\n", id, reverseHash(id), out, size, old.OutputID, old.Size) // panic to show stack trace, so we can see what code is generating this cache entry. - panic("cache verify failed") + msg := fmt.Sprintf("go: internal cache error: cache verify failed: id=%x changed:<<<\n%s\n>>>\nold: %x %d\nnew: %x %d", id, reverseHash(id), out, size, old.OutputID, old.Size) + panic(msg) } } file := c.fileName(id, "a") diff --git a/src/cmd/go/internal/cache/cache_test.go b/src/cmd/go/internal/cache/cache_test.go index 7c8383ad27..84749a6965 100644 --- a/src/cmd/go/internal/cache/cache_test.go +++ b/src/cmd/go/internal/cache/cache_test.go @@ -43,22 +43,22 @@ func TestBasic(t *testing.T) { if err := c1.putIndexEntry(dummyID(1), dummyID(2), 3, true); err != nil { // overwrite entry t.Fatalf("addIndexEntry: %v", err) } - if out, size, err := c1.Get(dummyID(1)); err != nil || out != dummyID(2) || size != 3 { - t.Fatalf("c1.Get(1) = %x, %v, %v, want %x, %v, nil", out[:], size, err, dummyID(2), 3) + if entry, err := c1.Get(dummyID(1)); err != nil || entry.OutputID != dummyID(2) || entry.Size != 3 { + t.Fatalf("c1.Get(1) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(2), 3) } c2, err := Open(cdir) if err != nil { t.Fatalf("Open(c2) (reuse): %v", err) } - if out, size, err := c2.Get(dummyID(1)); err != nil || out != dummyID(2) || size != 3 { - t.Fatalf("c2.Get(1) = %x, %v, %v, want %x, %v, nil", out[:], size, err, dummyID(2), 3) + if entry, err := c2.Get(dummyID(1)); err != nil || entry.OutputID != dummyID(2) || entry.Size != 3 { + t.Fatalf("c2.Get(1) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(2), 3) } if err := c2.putIndexEntry(dummyID(2), dummyID(3), 4, true); err != nil { t.Fatalf("addIndexEntry: %v", err) } - if out, size, err := c1.Get(dummyID(2)); err != nil || out != dummyID(3) || size != 4 { - t.Fatalf("c1.Get(2) = %x, %v, %v, want %x, %v, nil", out[:], size, err, dummyID(3), 4) + if entry, err := c1.Get(dummyID(2)); err != nil || entry.OutputID != dummyID(3) || entry.Size != 4 { + t.Fatalf("c1.Get(2) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(3), 4) } } @@ -84,22 +84,22 @@ func TestGrowth(t *testing.T) { t.Fatalf("addIndexEntry: %v", err) } id := ActionID(dummyID(i)) - out, size, err := c.Get(id) + entry, err := c.Get(id) if err != nil { t.Fatalf("Get(%x): %v", id, err) } - if out != dummyID(i*99) || size != int64(i)*101 { - t.Errorf("Get(%x) = %x, %d, want %x, %d", id, out, size, dummyID(i*99), int64(i)*101) + if entry.OutputID != dummyID(i*99) || entry.Size != int64(i)*101 { + t.Errorf("Get(%x) = %x, %d, want %x, %d", id, entry.OutputID, entry.Size, dummyID(i*99), int64(i)*101) } } for i := 0; i < n; i++ { id := ActionID(dummyID(i)) - out, size, err := c.Get(id) + entry, err := c.Get(id) if err != nil { t.Fatalf("Get2(%x): %v", id, err) } - if out != dummyID(i*99) || size != int64(i)*101 { - t.Errorf("Get2(%x) = %x, %d, want %x, %d", id, out, size, dummyID(i*99), int64(i)*101) + if entry.OutputID != dummyID(i*99) || entry.Size != int64(i)*101 { + t.Errorf("Get2(%x) = %x, %d, want %x, %d", id, entry.OutputID, entry.Size, dummyID(i*99), int64(i)*101) } } }