Repository navigation
test: every assertion can fail, the forecast test runs on the real platform, and two Windows arm64 tests stop flaking - #90
Merged
Conversation
…atform, and two Windows arm64 tests stop flaking - 58 bare `! cmd` lines across 16 suites end in `|| false`. bash exempts a negated command from errexit, so each one passed whatever it checked unless it was its test's last line. All still pass. A portability test now refuses a bare negation in any suite. - statusline-forecast pinned PLATFORM=linux, so on macOS get_file_age ran GNU `stat -c`, read the mod file's age as unknown, and "the mod's forecast wins" failed on every Mac without GNU stat first on PATH. It uses detect_test_platform, as helpers.bash asks; a test may pin the platform only with `# pinned: <why>` on the line, which a portability test checks. - "a store slow on every get" timed two 9 s fnox gets against 19 s; on Windows arm64 process start-up ate the last second. 25 s still proves the third get is never made (it would take 27 s). - "saved verbatim" failed once on Windows arm64 with no output to read: it now asserts the run's status first, so a flake prints its cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-line negations, and scans the helpers
`! cmd || true` fails nothing either, so a negation must end in || false,
|| { or || { ...; false; }; one after && or ; outside a condition counts
too, and tests/helpers.bash is scanned with the suites. Controls: each of
`! true || true`, `x=1 && ! true` and `true; ! false` added to a suite is
caught.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and readonly pins Controls: `local PLATFORM=linux`, `export PLATFORM="macos"` and `declare -g PLATFORM=windows`, each added to a suite, are caught. Co-Authored-By: Claude Opus 5.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.
Problem
Three kinds of test that couldn't be trusted:
! grep -q x filein the middle of a bats test never fails it. bash exempts a negated command fromset -e, which is bats-core's own gotcha and #462, and ShellCheck's SC2314. Only a negation on a test's last line was ever checked.statusline-forecast.batssetPLATFORM=linux, so on macOSget_file_ageran GNUstat -c, read the mod file's age as unknown, and "the mod's forecast wins over the average" failed on every Mac without GNUstatfirst on PATH. It looked time-dependent; it was platform-dependent.full-search.bats.--status(run 44397150789).Change
|| false. Lines already written! cmd || { …; false; }were left alone. All tests still pass, so none of them was hiding a bug.detect_test_platform, ashelpers.bashasks every statusline test to.PLATFORM=unless the line carries# pinned: <why>. The two deliberate pins, the Keychain branch andbar.shunder bash 3.2, now say why.Tests
Each control shows that its fix catches what it says:
! trueadded to a suite@test bare { ! true; true; }against{ ! true || false; true; }okagainstnot ok: the old form passes whatever it checksPLATFORM=linuxrestored in the forecast test on macOSjust lintandjust format-checkare clean.🤖 Generated with Claude Code