Skip to content

Skip generation when zero calls were captured; document sbt 2's cached test task - #136

Merged
luksow merged 1 commit into
mainfrom
empty-generation-guard
Aug 19, 2026
Merged

luksow merged 1 commit into
mainfrom
empty-generation-guard

Conversation

@luksow

@luksow luksow commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes #135.

Problem

Baklava generation runs as a post-test side effect (Tests.Cleanup). It formatted whatever serialized calls were in target/baklava/calls/ — even zero — and overwrote the previous output. Under sbt 2, bare test is an incremental task cached in a global store (~/.cache/sbt/v2) that survives clean; on a warm cache it runs 0 tests (exit 0) while the cleanup hook still fires, so a complete openapi.yml got replaced by an empty stub. Reported downstream in madrileno-dev/madrileno#113 / fixed on their side in madrileno-dev/madrileno#114 by switching to testFull, with the structural fix explicitly left to Baklava.

Changes

  • Empty-capture guard (BaklavaGenerate): when zero calls were captured, skip the formatters entirely — existing output stays intact — and print a warning explaining the likely cause and pointing sbt 2 users at testFull. Serialized-call cleanup is also skipped in that case (there is nothing to clean). Covered by a new BaklavaGenerateSpec (guard skips formatters + warns; non-empty path still runs formatters).
  • Docs: prominent sbt 2 warning everywhere sbt test is prescribed for generation (README, intro, installation, output-formats): use sbt testFull for complete documentation, because incremental test may run a subset or nothing and the output only covers tests that actually ran.

A partial incremental run (subset of the suite) still produces a partial spec — that can't be detected mechanically (partial output via testOnly is a feature), so it's covered by the documentation warning only.

Verification

  • TDD: watched the guard test fail against the extracted always-run behavior, then implemented the guard.
  • sbt +core/test green on Scala 2.13.18 (53 tests) and 3.3.7 (60 tests); core/scalafmtCheckAll clean.

🤖 Generated with Claude Code

…put (#135)

With zero captured calls BaklavaGenerate used to hand the formatters an
empty list, overwriting a previously generated spec with an empty stub.
Under sbt 2 this happens on every warm-cache 'sbt test' run, since the
incremental test task restores a cached result without running tests
while the Tests.Cleanup generation hook still fires.

Generation now skips the formatters when no calls were captured, leaving
existing output intact and printing a warning that points sbt 2 users at
testFull. Docs gain a prominent sbt 2 warning everywhere 'sbt test' is
prescribed for generation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luksow
luksow merged commit dd41049 into main Aug 19, 2026
13 checks passed
@luksow
luksow deleted the empty-generation-guard branch August 19, 2026 13: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.

Generation from zero captured calls silently clobbers existing output (sbt 2 cached test)

1 participant