fix(installer): make the bats suite green on stock macOS (bash 3.2 + tmpdir symlink + host-CLI leak) - #443
Open
LukasWodka wants to merge 1 commit into
Open
fix(installer): make the bats suite green on stock macOS (bash 3.2 + tmpdir symlink + host-CLI leak)#443LukasWodka wants to merge 1 commit into
LukasWodka wants to merge 1 commit into
Conversation
…tmpdir symlink + host-CLI leak)
Three tests failed locally on macOS but passed in ubuntu CI — all
local-environment artifacts, no behavior change on Linux:
- _extract_yaml_value '' de-escape: bash 3.2 keeps the backslash when a
${var//pat/rep} replacement is an escaped quote, so 'a''b' unescaped to
a\'b. Build the pattern/replacement from a $sq variable instead; same
fix on the mirror-image password-escape site (' -> '').
- validate_config "valid config passes": macOS puts BATS_TEST_TMPDIR under
the /var -> /private/var symlink and validate_config resolves via cd -P,
so the unresolved $HOME spuriously failed the under-$HOME check.
Pre-resolve HOME exactly like the sibling tilde tests already do.
- un-stamped DEFAULT_REF fails closed: the only bootstrap test that sets
no REF/BRANCH, so the healthy-machine bail-out stays armed — and
run_boot's PATH=$BIN:$PATH let a dev box's real tracebloc CLI leak in:
the test ran the host's `tracebloc doctor` and exec'd the real CLI
(exit 0) before ever reaching the REF gate. New run_boot_hermetic
(PATH=$BIN + sandboxed HOME) keeps it hermetic.
Also silence bats BW01 on the deliberate 127 in the sudo() test with
`run -127` + bats_require_minimum_version 1.5.0 (CI's apt bats is 1.10).
scripts/manifest.sha256 regenerated — install-client-helm.sh is on the
R8 integrity surface.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4e4c3bf. Configure here.
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.
Summary
Three bats tests failed when the suite runs locally on macOS but passed in ubuntu CI (verified on a clean origin/develop checkout) — noise that masks real regressions for anyone running
bats scripts/tests/*.batsbefore pushing. All three are local-environment artifacts; this fixes each at its actual root cause and silences the one bats warning the suite emitted. Suite is now 468/468 green on stock macOS (bash 3.2, bats 1.13) with zero warnings, and unchanged on Linux.Root causes & fixes
1.
_extract_yaml_value: single-quoted with '' escape(install-client-helm.bats) — bash 3.2 bug in the lib code.In
${var//pat/rep}, macOS's bash 3.2 keeps the backslash when the replacement is an escaped quote: the''de-escape turned'a''b'intoa\'b(bash 4+/5 givesa'b). Fixed by building pattern/replacement from a$sqvariable — identical semantics on every bash. The mirror-image escape site (' -> ''forTB_CLIENT_PASSWORD_ESCAPED) had the same latent bug and gets the same two-line fix.scripts/manifest.sha256regenerated since this lib is on the R8 integrity surface (gen-manifest.sh --checkpasses).2.
validate_config: valid config passes(common.bats) — tmpdir symlink shape.macOS puts
BATS_TEST_TMPDIRunder the/var -> /private/varsymlink.validate_configresolves the data dir viacd -P(symlinks resolved) but compared it against the unresolved$HOME, spuriously failing the under-$HOMEcheck. Fixed the test by pre-resolvingHOMEwithcd -P— the exact pattern (and comment rationale) the sibling tilde tests in the same file already use; this first test simply predated them.3.
un-stamped DEFAULT_REF fails closed(install-bootstrap.bats) — host CLI leaking into the sandbox.This is the only bootstrap test that sets no
REF/BRANCH, so_tb_bail_okstays armed — andrun_boot'sPATH="$BIN:$PATH"let the dev box's real/usr/local/bin/traceblocsatisfycommand -v tracebloc. The test then ran the host's realtracebloc doctorand, the box being healthy, exec'd the real CLI, which exited 0 before the REF gate was ever reached (CI has no tracebloc binary, so it never saw this). Addedrun_boot_hermetic—PATH=$BINalone (setup already symlinks the needed coreutils for exactly this pattern) plus a sandboxedHOME, since the bootstrap re-prepends~/.local/binto PATH. Beyond determinism, this stops the suite from executing a real CLI binary on dev machines.4. bats
BW01warning onsudo modprobe overlay(common.bats).The
sudo(): non-root without sudo returns 127test deliberately expects 127, which bats flags as "command not found". Switched torun -127plus the documentedbats_require_minimum_version 1.5.0declaration (CI's apt bats is 1.10, fine with both).Related
Local dev-environment fix — no tracked issue.
Type of change
Test plan
bats scripts/tests/*.bats— 468/468 pass, zero warnings (was: 3 failures + BW01)scripts/gen-manifest.sh --check— manifest up to datebash -nover all scripts +shellcheck --severity=erroron the same file set as the Lint job — cleanbash scripts/check-style.sh— clean'a''b'unescapes toa'b;a'bescapes toa''bChecklist
bash scripts/check-style.shpassesFixes tracebloc/<repo>#N(N/A)🤖 Generated with Claude Code
Note
Low Risk
Changes are localized to bash 3.2–compatible string substitution and test harness determinism; credential escaping semantics are preserved and manifest integrity is updated accordingly.
Overview
Makes the installer bats suite reliable on stock macOS (bash 3.2) without changing Linux CI behavior.
Installer lib:
_extract_yaml_valueandclientPasswordYAML escaping no longer use backslash-quote replacements in${var//pat/rep}— bash 3.2 leaves stray backslashes, breaking''unescape and'→''escape. Both sites now use a$sqvariable for pattern/replacement.scripts/manifest.sha256is updated for the touched lib.Tests:
validate_config: valid config passesresolvesHOMEwithcd -Pso it matches macOS/var→/private/vartmpdir layout. Bootstrap un-stamped DEFAULT_REF runs via newrun_boot_hermetic(PATH=$BINonly + sandboxedHOME) so a hosttraceblocCLI cannot satisfy the early healthy bailout before the REF gate.run -127silences bats BW01 on the intentional sudo-127 test;bats_require_minimum_version 1.5.0added.Reviewed by Cursor Bugbot for commit 4e4c3bf. Bugbot is set up for automated code reviews on this repo. Configure here.