Repository navigation
Tests: run ShellCheck over every shell script the tests write - #86
Merged
Merged
Conversation
Fakes of sudo, pmset, launchctl and the other tools decide what a test
sees. A broken one makes a test pass or fail for the wrong reason (a
fake gh that used $10, which bash reads as ${1}0, faked 16 failures on
#51), and nothing linted them.
TestScripts.write now writes every script a test authors. When
INSOMNIA_TEST_SCRIPT_DUMP names a folder, it also copies each one there,
once per distinct text (UUIDs zeroed first), with index.tsv naming the
source line that wrote it. CI sets the variable and, at the end of the
Swift job, runs ShellCheck 0.11.0 (pinned and checked against its
digest) over the folder. An empty folder fails the step.
ShellCheck found four deliberate constructs: glob patterns in two mv
fakes, an A && B || C in the sudo fake, and capture.sh's unused output.
Each gets a disable line with the reason.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…lcheck-test-fakes # Conflicts: # .github/workflows/ci.yml
Codex's review of a88d05c and Greptile (comment 4243820315) found scripts the ShellCheck step never saw. - The fake swiftc wrote the icon generator from a heredoc inside its own text, so ShellCheck read the generator as a string. The generator is now its own file, written through TestScripts.write, and the fake copies it to swiftc's -o path. - Four RecoveryScriptTests scripts have no #! line because the test runs them with /bin/bash: the installed-backstop stand-in (two writers, one text), the sleep sentinel and the umask wrapper. They now go through TestScripts.write with executable: false. A dump copy of a script with no #! line starts with `# shellcheck shell=bash`, so ShellCheck lints it as bash instead of stopping at SC2148. - TestScripts wrote the copy before its index line. A failure between the two left a copy the index never named, and a later write of the same text found the copy and skipped it, so it was never linted. The index line now goes first, and a missing copy fails ShellCheck. The dump of the seven script-writing classes went from 69 to 73 distinct scripts, and ShellCheck 0.11.0 passes on all of them. A `$10` planted in the umask wrapper's copy fails with SC1037; the same copy without the directive fails with SC2148. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Brings in #89's fake sudo change, so CI lints the fake's new text, and #85's merge. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
krishhgg
added a commit
to 0xRafie/Insomnia
that referenced
this pull request
Oct 12, 2026
Brings in krishhgg#86, which runs ShellCheck over the scripts the tests write. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
krishhgg
added a commit
to D4TBot/Insomnia
that referenced
this pull request
Oct 12, 2026
Brings in krishhgg#86, which runs ShellCheck over the scripts the tests write. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
krishhgg
added a commit
to nsd97/Insomnia
that referenced
this pull request
Oct 12, 2026
Brings in krishhgg#86's TestScripts.write, which the next commit uses for this PR's test scripts, and the other merges since bb5cf2b. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
krishhgg
added a commit
to nsd97/Insomnia
that referenced
this pull request
Oct 12, 2026
This branch started before krishhgg#86, so the new test wrote both scripts directly and CI's ShellCheck step never saw them. They now go through TestScripts.write like the sibling hand-down test's wrapper. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Phase 1 of the testing plan, item 3: lint the shell scripts the tests write. It was stacked on #85. #85 and #89 have merged, the base is now main, and 74a580d merges main in.
Why
Fakes of
sudo,pmset,launchctland the other tools decide what a test sees. A broken fake makes a test pass or fail for the wrong reason. A fakeghthat used$10, which bash reads as${1}0, faked 16 failures on #51. The ShellCheck job lintsscripts/*.shonly. The fakes are strings inside Swift tests, and nothing linted them.What changes
TestScripts.write(_:to:executable:)(Tests/InsomniaTests/TestScripts.swift) writes a script and makes it executable, unless the test runs it through/bin/bash. The 30 call sites that write fakes, stand-in backstops, wrapper scripts and the fakeswiftc's icon generator now go through it. Two kinds of script don't, because the ShellCheck job lints the originals: patched copies of the real scripts inscripts/, and test harnesses built from functions cut out of them.INSOMNIA_TEST_SCRIPT_DUMPnames a folder, each script is also copied there, once per distinct text. UUIDs (the per-test temp folders) are zeroed first. That way the RecoveryScriptTests fixture's fakes, written for each of its 231 tests, land once.index.tsvnames the test source line that first wrote each copy.#!line is one a test runs with/bin/bash. Its copy (never the real file) starts with# shellcheck shell=bash, so ShellCheck lints it as bash instead of stopping at SC2148.# shellcheck disable=line with the reason:mvfake: itsmv.failpatterns are globs.mvfake: itsmv-failspatterns are globs.sudofake'svisudobranch:A && B || rejectmeans "reject unless both pass".capture.sh: the test checks that the command substitution sees end of file, not what it captured.Checks
testTheSupervisorOutlivesItsRunAndGroupSignalsAndHoldsTheLockUntilItReapsTheCommand, the fake sudo race on main that Tests: let the fake sudo wait on SECONDS so one signal is logged once #89 fixes. This PR doesn't change that fake's text. The Mac did not sleep during the run.$10fake added to the folder, it failed with SC1037 ("Braces are required for positionals over 9").$10planted in the umask wrapper's copy, one of the scripts without#!, it also failed with SC1037. The same copy without theshell=bashline fails with SC2148.swiftc's icon generator sat in a heredoc that ShellCheck read as text. Four scripts without#!skipped the helper; Greptile's comment flags the same thing. A copy could exist without its index line. 2ca0534 fixes all three. Codex found nothing at 2ca0534, or in the merge at 74a580d, which adds exactly Tests: let the fake sudo wait on SECONDS so one signal is logged once #89's change.Tests and CI only: no Mac report needed.
🤖 Generated with Claude Code

Confidence Score: 5/5
The PR appears safe to merge; no actionable new issues remain.Summary
The PR sends test-written shell scripts through
TestScripts.writeand adds a CI step to lint their copies.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Tests[Test script writers] --> Writer[TestScripts.write] Writer --> Original[Script used by the test] Writer --> Dump[Normalized lint copy and index.tsv] Dump --> Lint[CI ShellCheck step]Reviews (3) · Last reviewed commit: "Merge main into ci/shellcheck-test-fakes" · Reviewed by Greptile