# Test that go vet's caching of vet tool actions replays
# the recorded stderr output even after a cache hit.

[short] skip 'uses a fresh build cache'

# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache

# First time is a cache miss.
! go vet example.com/a
stderr 'fmt.Sprint call has possible Printf formatting directive'

# Second time is assumed to be a cache hit for the stdout JSON,
# but we don't bother to assert it. Same diagnostics again.
! go vet example.com/a
stderr 'fmt.Sprint call has possible Printf formatting directive'

# Vetting example.com/a only as a dependency of example.com/b
# records facts but reports no diagnostics. A later
# 'go vet example.com/a' must not reuse that result.
env GOCACHE=$WORK/gocache2
go vet example.com/b
! go vet example.com/a
stderr 'fmt.Sprint call has possible Printf formatting directive'

-- go.mod --
module example.com

-- a/a.go --
package a

import "fmt"

var _ = fmt.Sprint("%s") // oops!

-- b/b.go --
package b

import _ "example.com/a"
