Skip to content

fix: resolve tmpdir symlink in describeInstallLocation fixture (macOS flake) - #2086

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
yukhymenko-yurii:2026-10-03_fix-installdir-macos-flake
Oct 4, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
yukhymenko-yurii:2026-10-03_fix-installdir-macos-flake

Conversation

@yukhymenko-yurii

Copy link
Copy Markdown
Contributor

Fixes #2068

What

tests/update-install-dir.test.ts:131 (describeInstallLocation: names target, symlink real, and running module) failed deterministically on macOS.

Root cause

The fixture is created under mkdtempSync(path.join(tmpdir(), ...)). On macOS tmpdir() is /var/folders/..., which is itself a system symlink to /private/var/folders/.... The implementation (src/update.ts describeInstallLocation) legitimately runs realpathSync(installDir) and reports the difference as real=... — so the test's plain case ("no symlink hop") actually contained a symlink hop (the OS one), and assert.doesNotMatch(plain, /real=/) failed. Verified pre-existing on clean master (3a7308a) in a separate worktree without this change: 7 tests, 6 pass, 1 fail.

Fix (test-only, 1 line + comment)

Resolve the fixture dir with realpathSync before use, so the plain case stays plain on every platform. The link case below already compared via realpathSync(link), so it is unaffected. Implementation unchanged — reporting real= for a genuine symlink hop is the intended behavior of that log line.

Pre-flight (on this branch, macOS host)

  • npm run typecheck — clean
  • npm test — 4056 tests, 4034 pass, 0 fail, 22 skipped (the previously failing test now passes; full suite green)
  • npm run build — success

Config surface: none (test-only change).

… flake)

On macOS tmpdir() is /var/folders/..., a system symlink to
/private/var/folders/..., so the fixture dir the test passes as
installDir is itself a symlink hop. describeInstallLocation's
realpath then legitimately reports it (real=...), and the plain
case's doesNotMatch(/real=/) assertion fails deterministically.
Realpath the fixture dir so the plain case stays plain on every
platform; the link case below already compared via realpathSync.

Fixes ranxianglei#2068
@yukhymenko-yurii
yukhymenko-yurii force-pushed the 2026-10-03_fix-installdir-macos-flake branch from 755d745 to a54536e Compare October 4, 2026 12:41
@ranxianglei

Copy link
Copy Markdown
Owner

ework review

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR review — #2086 (test-only macOS flake fix for #2068)

① 是什么问题:tests/update-install-dir.test.ts 的 describeInstallLocation 用例在 macOS 上稳定失败——fixture 建在 mkdtempSync(tmpdir()) 下,而 macOS 的 tmpdir()(/var/folders/...)本身是指向 /private/var/folders/... 的系统符号链接;"plain directory" 断言 doesNotMatch(/real=/) 因此被实现方正确地报出的这一跳 symlink 打破。

② 什么原因导致:测试环境依赖了「tmpdir 路径已完全解析」这个在 Linux CI 上成立、macOS 上不成立的隐含假设(§7.2 环境运气类,同 #360)。生产代码行为没有错——describeInstallLocation(src/update.ts:345)对真实存在的 realpath 差异报 real= 是设计语义。作者根因分析准确,且已在干净 master(3a7308a)worktree 上验证非回归。

③ 怎么修复:一行测试改动——const base = realpathSync(mkdtempSync(...)),把 fixture 基目录在任何平台上都归一到完全解析形态,使 given==resolved、plain 断言恢复成立。这正是 issue 建议的第一方案。link 用例原本就与 realpathSync(link) 比对,unresolved 用例不依赖 base,均不受影响。无生产代码改动。

④ 是否有回归问题:无。纯 test-only diff(+5/-1,单文件)。已清点同文件其余 6 个用例:全部用字面路径做相等/包含断言(findPackageRoot 内部从不 realpath),不受 fixture 路径形态影响。本地定向验证矩阵(symlink TMPDIR ≈ macOS 条件):

条件 结果
master(修复前)+ symlinked TMPDIR 6/7,失败 1 = 本用例(not ok 6 - describeInstallLocation: names target, symlink real, and running module),精确复现 #2068
PR head + symlinked TMPDIR 7/7 ✅
PR head + plain TMPDIR 7/7 ✅
master + plain TMPDIR(Linux 基线) 7/7 ✅

CI(head a54536e):14 项 check run 全绿(test ubuntu 22/24、windows 22/24、hermetic registry e2e、build-artifact、version-guard 等)。注意 CI 无 macOS runner——此 flake 只在本地 macOS 显现,但修复方向正确,不影响 Linux/Windows 行为。

⑤ 是否破坏缓存:不涉及(无缓存/重试/游标/去重键相关)。

⑥ 是否改了设计方向:不涉及。

⑦ 是否引入新配置:不涉及。

⚠️ 重复 PR 提示(需 owner 拍板)

本 PR 与 #2069(ework-daemon 同日早些时候针对同一 issue #2068 开出)是功能完全相同的修复——同样一行 realpathSync(mkdtempSync(...)),仅注释措辞不同。两个 PR 目前都 open:

结论

可合(选其一)。修复打到了机制本身(fixture 未归一化),不是掩盖症状;断言语义原样保留;回归面为零。等 owner 决定合并 #2086 还是 #2069。

@ranxianglei
ranxianglei merged commit ef59298 into ranxianglei:master Oct 4, 2026
14 checks passed
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.20-master.ef59298 (rolling master tag).

npm install -g billion-context@0.0.20-master.ef59298  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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.

tests: update-install-dir describeInstallLocation case is flaky on macOS (tmpdir symlink)

2 participants