Fix CLI test runner preload and test-utils fallback for public mirror - #1203
Fix CLI test runner preload and test-utils fallback for public mirror#1203nordicnode wants to merge 1 commit into
Conversation
|
Good, focused fix. Both changes address concrete breakage caused by the mirror export process rather than opinion or style:
One nit: the outer try/catch already existed for a different purpose (env default setup failures) — nesting a second try/catch inside it works but slightly muddies what error is being caught where. A short comment distinguishing 'private module missing' from 'other load failures' would help future readers, since a genuine bug in Overall this is a real, narrow bug fix with verification steps included, and it's confined to |
Problem & Context
Running CLI tests via Bun on the public repository failed immediately with two blocking issues:
Missing Preload in
cli/bunfig.toml:cli/bunfig.tomldeclared../test/setup-scm-loader.tsunderpreload. The roottest/directory was unbundled from the public mirror in commit61bbbed7, causing any invocation ofbun testinclito crash at startup before running any test files:(Modern Bun loads
.scmtext queries natively without requiring an external loader plugin).Missing
packages/internalincli/src/__tests__/test-utils.ts: When test suites invokedensureCliTestEnv(),loadCliEnv()attempted to require../../../packages/internal/src/env. Becausepackages/internalis an unexported private module omitted from the public repository, this threw an unhandled error (Cannot find module '../../../packages/internal/src/env') instead of utilizing the defined test defaults (TEST_CLIENT_ENV_DEFAULTSandTEST_SERVER_ENV_DEFAULTS).Changes Made
cli/bunfig.toml: Removed the non-existent../test/setup-scm-loader.tsentry frompreload.cli/src/__tests__/test-utils.ts: Wrapped the dynamicrequire('../../../packages/internal/src/env')in a fallback block that initializescachedEnvwithTEST_CLIENT_ENV_DEFAULTSandTEST_SERVER_ENV_DEFAULTSwhen running on the public repository.Architecture & Conventions Conformance
common/src/types/contracts/, no module monkey patching)terminalCommandBroker(no directspawnor TUI-process bypass)getCliEnv()for CLI,getSdkEnv()for SDK, no forbiddengetProcessEnv()imports)IS_FREEBUFFpreserved, no paid features introduced)import typeused for types)Scope Verification
cli/web/,freebuff/web/,packages/internal/,packages/billing/,packages/bigquery/, orpackages/build-tools/Testing & Verification
bun run --cwd cli typecheckpassed with 0 errors.bun test src/__tests__/cli-args.test.tspassed 15/15 tests (was crashing on missing preload).bun test src/__tests__/launcher-disconnect.test.tspassed (was crashing on missingpackages/internal).bun test src/__tests__/launcher-avx2-fallback.test.tspassed 31/31 tests.bun test src/__tests__/unit/passed 85/85 tests.bun run build:sdkpassed cleanly.bun run build:freebuffpassed cleanly.bun cli/scripts/smoke-binary.ts cli/bin/freebuffpassed cleanly.