Skip to content

fix(tests): resolve macOS ARM64 mock.module failure in import test#355

Merged
rhuanbarreto merged 1 commit into
mainfrom
fix/macos-import-test-mock
May 25, 2026
Merged

fix(tests): resolve macOS ARM64 mock.module failure in import test#355
rhuanbarreto merged 1 commit into
mainfrom
fix/macos-import-test-mock

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Replace require() + spread pattern inside mock.module() factory with explicit inline implementations of resolveSource and detectTarget
  • The previous require() of the same module being mocked is unreliable on macOS ARM64 (Bun mock.module interop issue — returns circular/empty object instead of real exports)
  • Compact test constants and registration tests to stay within the 500-line max-lines lint rule

Context

The import action handler > --yes imports a single ADR with its rules file test failed only on darwin-arm64 in run #26420753557. Linux and Windows passed fine because the require() interop worked there.

Test plan

  • All 20 import tests pass locally
  • bun run validate passes (lint, typecheck, format, test, ADR check, knip, build)
  • CI passes on darwin-arm64 (the failing platform)

The `--yes imports a single ADR with its rules file` test failed
only on macOS ARM64 (darwin-arm64) because `require()` of the same
module inside a `mock.module()` factory is unreliable — it can
return a circular/empty object instead of the real module exports,
causing `resolveSource` and `detectTarget` to not be properly
re-exported via the spread pattern.

Fix: replace `require()` + spread with explicit inline
implementations of `resolveSource` and `detectTarget` in the mock
factory. These use the same logic as the real functions but avoid
the problematic self-require. The `shallowClone` mock remains
unchanged.

Also compact test constants and registration tests to stay within
the 500-line max-lines lint rule.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9655eaa
Status: ✅  Deploy successful!
Preview URL: https://30ef6f4b.archgate-cli.pages.dev
Branch Preview URL: https://fix-macos-import-test-mock.archgate-cli.pages.dev

View logs

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.2% (6536 / 7246)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 2069 / 2348
src/engine/ 93.1% 1207 / 1297
src/formats/ 100.0% 141 / 141
src/helpers/ 90.1% 3119 / 3460

@rhuanbarreto rhuanbarreto merged commit 727c64d into main May 25, 2026
11 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/macos-import-test-mock branch May 25, 2026 22:40
@archgatebot archgatebot Bot mentioned this pull request May 25, 2026
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