Skip to content

test(cli): make homeDir-dependent tests hermetic - #5993

Open
kanadgupta wants to merge 4 commits into
developfrom
kanad-claude-2026-07-29/mock-runtime-fixes
Open

test(cli): make homeDir-dependent tests hermetic#5993
kanadgupta wants to merge 4 commits into
developfrom
kanad-claude-2026-07-29/mock-runtime-fixes

Conversation

@kanadgupta

@kanadgupta kanadgupta commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Tests that combined mockRuntimeInfo's fixed default homeDir (/tmp/supabase-cli-test-home) with a real FileSystem layer silently picked up stale files left by older test runs or manual CLI invocations — e.g. a leftover ~/.supabase/profile containing supabase-staging broke two legacy-cli-config unit tests on a developer machine.

  • mockRuntimeInfo / mockTelemetryRuntime now default to a per-process unique path that is never created on disk, so the stale-state class of failure can't recur.
  • Tests that build the real legacyCliConfigLayer / legacyCredentialsLayer against a real filesystem (the six *.layers.unit.test.ts layer-exposure tests, the four experimental-gate tests, and legacy-cli-config.layer.unit.test.ts) now pin homeDir to a per-test temp dir and isolate ambient env via a new legacyIsolatedHomeLayer helper, which also replaces the hand-rolled TelemetryRuntime blocks with mockTelemetryRuntime.
  • The hermeticity rule is documented in the testing policy in apps/cli/AGENTS.md.

Verified by recreating a poisoned /tmp/supabase-cli-test-home (stale profile + access token) and running the full core suite against it.

🤖 Generated with Claude Code

kanadgupta and others added 2 commits July 29, 2026 15:05
Extract the repeated mockRuntimeInfo({ homeDir }) + processEnvLayer()
pair into legacyIsolatedHomeLayer, replace the four experimental-gate
tests' hand-rolled TelemetryRuntime blocks with mockTelemetryRuntime,
and document the hermeticity rule in the testing policy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kanadgupta
kanadgupta marked this pull request as ready for review July 29, 2026 22:55
@kanadgupta
kanadgupta requested a review from a team as a code owner July 29, 2026 22:55
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@9df3716f50fc99f54d794e956aeacbd7c7136308

Preview package for commit 9df3716.

kanadgupta and others added 2 commits July 29, 2026 16:28
The parity harness only stripped Go's "Keyring is not supported on WSL"
line, but on runners with no D-Bus secrets daemon keyring ops fail with
"The name org.freedesktop.secrets was not provided by any .service
files" inside store.go's "failed to delete credentials: %w" wrapper.
This broke the `projects delete --yes` parity e2e on every PR (the TS
port intentionally skips Go's no-op credential cleanup). Strip that
wording as the same class of keyring-backend availability noise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kanadgupta

Copy link
Copy Markdown
Contributor Author

Test failures are due to an unrelated issue, fix for that is in #5997

7ttp pushed a commit to 7ttp/cli that referenced this pull request Jul 30, 2026
supabase#5997)

The `projects delete --yes` parity e2e is failing on every develop-based
PR (e.g. supabase#5993 and unrelated branches). Go's best-effort keyring cleanup
in `projects delete` (`delete.go:46`) prints its failure to stderr, and
the parity normalizer only strips one of Go's two keyring-failure
wordings: `Keyring is not supported on WSL` (emitted when the D-Bus
client fails with `exec.ErrNotFound`). When the CI runner has a
reachable D-Bus session bus but no secrets daemon, go-keyring instead
fails with `The name org.freedesktop.secrets was not provided by any
.service files`, wrapped as `failed to delete credentials: …` — which
survives normalization and breaks the byte-for-byte stderr comparison.
The TS port intentionally skips this no-op cleanup and relies on the
harness treating Go's keyring-backend availability noise as environment
detail.

The failure appeared without any repo change (same test passed and
failed on the same rootfs image hours apart on 2026-07-29), pointing at
runner-environment drift in D-Bus availability. This extends the
existing normalization rule to strip the second wording, with a unit
test covering both.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant