Skip to content

Validate cached snapshot tests against expected metadata#2679

Merged
plajjan merged 1 commit into
mainfrom
snapshot-cache-expected-metadata
Mar 7, 2026
Merged

Validate cached snapshot tests against expected metadata#2679
plajjan merged 1 commit into
mainfrom
snapshot-cache-expected-metadata

Conversation

@plajjan

@plajjan plajjan commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

A cached snapshot test result could be reused after the expected snapshot changed on disk, as long as the test code content hash still matched. This showed up when switching git branches: snapshots/output still reflected the old run, snapshots/expected could have been updated, and acton test would trust the cached pass.

This change makes cached snapshot reuse check the on-disk snapshot artifacts before accepting the cached result. We only reuse the cache when snapshots/output// exists, the expected snapshot exists, the file sizes match, and the expected snapshot mtime is older than the output snapshot mtime. Any uncertainty falls back to rerunning the test, which keeps cache hits cheap while conservatively avoiding stale snapshot passes.

A regression test was added for acton test to cover the branch-switch style scenario where the expected snapshot changes without any source change, and the testing docs were updated to describe the extra snapshot validation.

A cached snapshot test result could be reused after the expected
snapshot changed on disk, as long as the test code content hash still
matched. This showed up when switching git branches: snapshots/output
still reflected the old run, snapshots/expected could have been updated,
and acton test would trust the cached pass.

This change makes cached snapshot reuse check the on-disk snapshot
artifacts before accepting the cached result. We only reuse the cache
when snapshots/output/<module>/<test> exists, the expected snapshot
exists, the file sizes match, and the expected snapshot mtime is older
than the output snapshot mtime. Any uncertainty falls back to rerunning
the test, which keeps cache hits cheap while conservatively avoiding
stale snapshot passes.

A regression test was added for acton test to cover the branch-switch
style scenario where the expected snapshot changes without any source
change, and the testing docs were updated to describe the extra
snapshot validation.
@plajjan plajjan enabled auto-merge March 7, 2026 15:10
@plajjan plajjan merged commit 0ea3487 into main Mar 7, 2026
39 of 42 checks passed
@plajjan plajjan deleted the snapshot-cache-expected-metadata branch March 7, 2026 15:23
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.

1 participant