Repository navigation
Conversation
flight-deck-update-check.sh was the only shipped hook without a test suite, and the only one tools/doctor.sh structurally cannot exercise: its hook-execution check strips curl from PATH on purpose, so the hook exits on its fail-open guard before the version comparison, the cache logic, or the JSON emission ever run. The suite is hermetic. HOME points at a per-case fixture under $TMPDIR and a stub curl sits ahead of the real one on PATH, so no case reads the real config directory, writes the real daily cache, touches the network, or spends GitHub rate limit. A dedicated case asserts the real cache is unchanged. Covers notification logic (including 1.9.0 vs 1.14.0, which a lexical sort would invert), the fail-open contract on eight failure modes, missing dependencies, the cache write, and malformed stdin. Every case asserts exit 0 and empty stderr, not just the expected verdict. The fresh-cache case is a documented XFAIL for #2: it pins today's behaviour and reports XPASS with a follow-up instruction once the fix lands, so the assertion flips deliberately rather than silently. Verified by mutation: eight seeded regressions in the hook (lexical sort, dropped ahead-of-release guard, dropped v-prefix strip, dropped curl guard, dropped empty-VERSION guard, exit 1 on missing jq, wrong hookEventName, cache never written) are each caught by the intended case. The suite exercises 9 of the hook's 9 executable exit points. Refs #3 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The GitHub contents API does not carry file modes, so the previous commit landed it 100644 while the three existing suites are 100755. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3. Adds
tools/test-update-check.sh, a 320-line suite forhooks/flight-deck-update-check.sh— the only shipped hook without one, and the only onetools/doctor.shstructurally cannot exercise.Why it belongs here rather than in doctor
doctor's hook-execution check strips curl from PATH on purpose, so this hook exits on its documented fail-open guard before the version comparison, the cache logic, or the JSON emission ever run. That keeps doctor read-only and is the right call; it just leaves this hook's actual decision logic uncovered. Section 3c already names that boundary. This suite fills it from the outside instead of loosening doctor.
Hermetic by construction
Two substitutions make the hook fully testable with no side effects:
HOMEon a per-case fixture under$TMPDIRsuppliesskills/mission-control/VERSIONand receives the cache write, so any installed version can be simulated and nothing lands outside the fixture.curlahead of the real one on PATH returns a cannedreleases/latestbody, so cases are deterministic, offline, and cost no GitHub rate limit.A dedicated case compares the real
~/.claude/.flight-deck-update-checkbefore and after the run, so a fixture that silently stops taking effect is caught rather than quietly corrupting the developer's own install.Coverage
19 cases across notification logic, the fail-open contract, missing dependencies, the cache write, and malformed stdin. Every case asserts exit 0 and empty stderr, not merely the expected verdict: a hook that prints shell noise at session start is a defect even when it exits 0. Notifying cases also assert the payload is valid JSON with
hookSpecificOutput.hookEventName == "SessionStart".Two cases are worth calling out because nothing currently in the repo would notice them fail:
1.9.0vs1.14.0— a lexical sort inverts this; onlysort -Vgets it right.The fresh-cache case is a documented XFAIL for #2: it pins today's behaviour and switches to
XPASSwith a follow-up instruction once the fix lands, so the assertion flips deliberately rather than silently.Verification
Running the suite is not evidence on its own — an empty suite passes too. Eight regressions were seeded into copies of the hook, and each was caught by the case meant to catch it:
sort -V→sortlatest=${latest#v}droppedexit 0→exit 1on missing jqhookEventNameIndependent metric: instrumenting the hook's exit points shows the suite exercises 9 of its 9 executable ones (the tenth
exit 0is inside a comment).Two harness bugs surfaced during that check and are fixed here — worth noting since both would have produced a green suite that proved nothing:
make_reduced_pathsymlinked Cygwin/MSYS binaries, which then could not find their DLLs. The nominal path never exercised it (the hook bails before reachingtr), so only mutation revealed it. Now wrapper scriptsexec-ing absolute paths.#!/usr/bin/env bashshebang, andenvcannot findbashin a reduced PATH that omits it.$BASH_BINis now resolved once, absolutely.Notes
bash tools/test-update-check.sh, matching the existing suites. Nothing runs it automatically —release-check.ymlonly runscheck-release.sh, andRELEASING.mdnames notest-*.sh. Wiring this (and the three existing suites) into CI or the release checklist is a separate call I have not made here.