test: keep record internals in the record store's own tests

Merged
HA
1d ago
+503-442

Summary

  • Tests that look inside compile-check's records now live in the record store's own test files. Every other test observes the records only through the store's methods.
  • Test-only change; no production code changes.

User Impact

  • None. This prepares moving the record store into its own package, where tests outside it can no longer reach its internals.

Changes

  • Store tests (record_store_test.go, record_store_baseline_test.go, record_format_test.go):
    • the result manifest tests (reuse, rejection, writes, atomic rename, output hashing), now working from output names instead of compile units;
    • forgetting an assembly's records;
    • generator output hashing;
    • the baseline format checks and the golden record bytes.
  • Other tests, rewritten to use the store's methods:
    WasNow
    reading the baseline or manifest JSONbaseline(t): a usable baseline from the store. The store only returns one whose input key matches its manifest
    baseline file existshasBaselineOf: the store's reason does not start with no baseline:. A baseline that disagrees with its manifest is reported as baseline compile is no longer on disk, so a baseline written after a failed compile is still detected
    manifest file existshasRecordedCompile: the store's reason is not no baseline: no full compile of this assembly is on record. These assemblies are too small to get a baseline, so that reason only means no compile result is recorded
    hashes of four named filesoutputSnapshot: every file under the output directory that belongs to the assembly, except the changed-files check's own response file
    editing record JSON by handrecording a failed compile, or a tampered key, through the store
    generated file count from the recordcounting the files under the generator output directory
    blocking the manifest patha failed compile whose output directory is removed during the compile, so only the record write fails
    removing outputs, then checking each record fileremoveUnitOutputs, then the two outputs are gone and the store has no compile result, no baseline and no generator output

Verification

  • git grep -P over the test files outside the store's own test files, for record internals (struct names, constants, paths, internal functions, record file names): no matches.
  • Each rewritten check was confirmed with a mutation, restored afterwards; each mutation fails the listed tests:
    • forgetting skips the manifest: the two manifest-absence tests and the removeUnitOutputs test fail;
    • recording after a compile error, then returning the error: the three record-nothing tests fail;
    • recording when the compiler failed without a diagnostic: the matching test fails;
    • recording a successful compile with a missing output: the matching test fails;
    • recording a baseline after a failed compile: the matching test fails;
    • writing a baseline and then refusing the missing non-source key: the matching test fails;
    • ignoring a record write failure: the matching test fails;
    • rewriting the manifest during a changed-files check: the matching test fails.
  • The fallback order and record format tests still catch all eight mutations they were checked with when they were added.
  • No expected reason, byte or count changed.
  • cli/dispatcher: golangci-lint fmt --diff (empty), go vet ./..., golangci-lint run (0 issues), the complexity config (0 issues), go test ./..., and go test -race ./internal/compilecheck/... pass. Coverage with the CI exclusions: 94.30% (baseline 94.2).
  • cli/release-automation: go test ./... passes. The file-length check passes.