Skip to content

transform, interp: name the test fixture cache workaround - #5781

Merged
deadprogram merged 1 commit into
tinygo-org:devfrom
davecheney:testcache-helper
Sep 29, 2026
Merged

deadprogram merged 1 commit into
tinygo-org:devfrom
davecheney:testcache-helper

Conversation

@davecheney

Copy link
Copy Markdown
Contributor

go test only treats a file as a cache input if the test opened it through the os package. LLVM fixtures are read by
llvm.NewMemoryBufferFromFile, which opens the file in C, so a fixture is never hashed and editing one leaves a stale cached pass.

A stopgap for #5780. I'm working on the go-llvm change next.

`go test` only treats a file as a cache input if the test opened it
through the os package. LLVM fixtures are read by
llvm.NewMemoryBufferFromFile, which opens the file in C, so a fixture is
never hashed and editing one leaves a stale cached pass.

optimizer_internal_test.go had no os.Stat workaround, so
TestBlockGlobalAllocPromotionUses did not run against its fixture:
appending unparseable IR to testdata/optimizer-alloc-uses.ll did not
fail it.

Replace the bare os.Stat calls with ensureTestCacheFreshness, which also
fails the test when the fixture is missing, and add the missing call.
transform_test, transform and interp each keep a copy.

A stopgap for tinygo-org#5780.

@jakebailey jakebailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes

@davecheney

Copy link
Copy Markdown
Contributor Author

This probably isn’t as planet breaking as it sounds. In CI I doubt the caching works as well as it does locally so CI will likely catch any issues, but it does introduce WTFs for local development.

@jakebailey

Copy link
Copy Markdown
Member

No, sorry, Yikes was "this must have been a pain to diagnose".

@davecheney

Copy link
Copy Markdown
Contributor Author

No, sorry, Yikes was "this must have been a pain to diagnose".

It's all good, tinygo-org/go-llvm#80

davecheney added a commit to davecheney/go-llvm that referenced this pull request Sep 28, 2026
Fixes tinygo-org/tinygo#5781

Stat the file before passing the path to libllvm. This gives us a
cleaner Go error message if the file is missing, and also announces to
go test that the file is in scope for caching.
@deadprogram

Copy link
Copy Markdown
Member

Thank you for the improvement @davecheney and to @jakebailey for review. Now merging.

@deadprogram
deadprogram merged commit 266fbd4 into tinygo-org:dev Sep 29, 2026
33 checks passed
@davecheney
davecheney deleted the testcache-helper branch September 29, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants