Repository navigation
test(cli): unit tests get a fake home directory and NO_COLOR - #271
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR
The node:os mock cannot reach node_modules (conf, env-paths, Pulumi automation) or direct process.env.HOME readers. Forked workers get HOME, USERPROFILE, XDG_* and PULUMI_HOME pointing into one temp dir per run, created by a globalSetup. client.test.ts pins its conf dir to a temp dir. Docs now say NO_COLOR covers colour only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR
teardown() removes only the dir setup() created, and only when it sits directly under os.tmpdir(). The config assigns WRAPS_CLI_TEST_HOME with = (the proof test checks the dir exists and HOME matches). client.test.ts uses mkdtempSync. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This branch was previously deployed
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.
What
CLI unit tests can no longer read or write the developer's real home directory, and they run with
NO_COLOR=1.On 2026-11-12, a test rewrote a real
~/.wraps/pulumi/Pulumi.yaml. SettingHOMEinside a test did nothing, and code insidenode_modules(conf/env-pathsfor telemetry, Pulumi automation) still resolved the real home even whennode:oswas mocked.How
packages/cli/vitest.config.ts:pool: "forks";test.envat one temp home per run, coveringHOME,USERPROFILE, theXDG_*dirs andPULUMI_HOME;os.homedir()followsHOME, so this covers source code,node_modulesand child processes.src/__tests__/setup/fake-home-global.tscreates the temp home and removes it. It deletes only the dir it created, and only when that dir is awraps-cli-home-*dir directly underos.tmpdir().src/__tests__/setup/fake-home.test.tsproves the setup works. It checks:os.homedir()through named, default and bareosimports;getWrapsDir();conf;client.test.tspins its telemetry config dir to amkdtempdir.NO_COLOR=1: picocolors (and clack) let it win overCI/FORCE_COLOR, so a plain run matches CI's colour handling.CIstill changesisInteractive()and telemetry, andCLAUDE.mdsays so.packages/cli/CLAUDE.mdgets a new "Tests" section.Checks
CI=true: 3711/3711.~/.wraps/pulumi/Pulumi.yaml,~/.config/wraps-nodejs/telemetry.json,~/.wrapsand~/.pulumi: mtimes unchanged across runs. No temp dirs left behind.turbo typecheck --filter=@wraps.dev/cliand biome: pass.Tests and docs only. No release needed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GxJAQQr6pNB7qCy8dj9CYR