go test caching does not track .ll fixtures loaded through go-llvm
go test decides whether a cached PASS is still valid from a log of files the test
binary read. That log only records files opened through Go's os package.
llvm.NewMemoryBufferFromFile opens the file in C, so the .ll fixture never
becomes a cache input: you can edit or corrupt a fixture and go test will keep
reporting ok (cached) forever.
The discarded os.Stat(path) next to each fixture load exists solely to register
the path with that log.
transform/optimizer_internal_test.go has no such call. Its fixture is not tracked
today.
Possible solutions
Give the pattern a name. A helper,
ensureCacheFreshness(t *testing.T, path string), that stats the path and fails the test if it is missing. The call site then states its purpose instead of reading as dead code, and the explanation lives in one comment rather than being reconstructed by whoever next meets it. Four call sites across three packages —transform_test,transform(the internaloptimizer_internal_test.go) andinterp— so it has to be reachable from all three.Fix go-llvm. Add a
NewMemoryBufferFromMemoryRangeCopybinding, then switch the tests toos.ReadFileplus parse-from-bytes and drop the helper entirely. The read goes throughos, so caching works with no special pleading, and the discardedos.Staterror becomes a real one on the read. Removes the idiom rather than documenting it, and fixes the class of bug rather than its instances. Requires a go-llvm release and a go.mod bump; v0.0.0-20260721072906 exposes onlyNewMemoryBufferFromFileandNewMemoryBufferFromStdin.
Source: tinygo-org/tinygo