mirror of
https://github.com/golang/go
synced 2024-11-19 22:04:44 -07:00
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 <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
d06335e28f
commit
ca886e0673
4
src/cmd/go/internal/cache/cache.go
vendored
4
src/cmd/go/internal/cache/cache.go
vendored
@ -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")
|
||||
|
24
src/cmd/go/internal/cache/cache_test.go
vendored
24
src/cmd/go/internal/cache/cache_test.go
vendored
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user