Skip to content

fix(test-runner): skip git-ignored and unreadable directories in readAllFiles - #3356

Open
Battleplus wants to merge 2 commits into
makecindy:mainfrom
Battleplus:fix/3353-test-runner-gitignore
Open

fix(test-runner): skip git-ignored and unreadable directories in readAllFiles#3356
Battleplus wants to merge 2 commits into
makecindy:mainfrom
Battleplus:fix/3353-test-runner-gitignore

Conversation

@Battleplus

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

修复测试运行器 readAllFiles() 的两个问题:

  1. 未忽略 git-ignored 目录IGNORED_PARTS 缺少 "tmp",导致 readAllFiles 扫描被 .gitignore 忽略的 tmp/ 目录。Windows 上 tmp/ 可能包含其他进程创建的不可读子目录,导致 EPERM 错误使测试门禁失败。

  2. 不可读目录导致崩溃fs.readdirSync() 遇到不可读目录时直接抛错,整个测试运行器崩溃,无法执行任何测试。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

怎么验证的

  1. 运行 pnpm test:runner,确认不再因 tmp/ 目录 EPERM 失败
  2. 在 Windows 上创建 tmp/test/ 目录并设置权限限制,确认测试运行器不会崩溃
  3. 确认 readAllFiles 仍能正确发现所有非忽略的源码和测试文件

风险

  • 极低风险——仅修改测试运行器的文件发现逻辑,不影响生产代码
  • 跳过不可读目录可能导致某些测试文件未被发现,但这些文件本身也无法被测试(因为不可读)

…AllFiles

Two issues with readAllFiles():

1. It doesn't include "tmp" in IGNORED_PARTS, so it scans the git-ignored
   tmp/ directory. On Windows, tmp/ may contain unreadable subdirectories
   created by other processes, causing EPERM failures in the test gate.

2. fs.readdirSync() throws on unreadable directories (EPERM on Windows),
   crashing the entire test runner before any tests run.

Fix: add "tmp" to IGNORED_PARTS, and wrap readdirSync in try-catch to
gracefully skip unreadable directories.

Fixes makecindy#3353.

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus
Battleplus requested a review from a team as a code owner August 24, 2026 14:06
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 调整测试运行器的文件遍历逻辑,避免权限受限目录导致测试发现过程崩溃。

  • tmp 加入文件发现的忽略目录集合。
  • 仅对 EPERMEACCES 跳过目录,其余读取错误继续抛出。

Confidence Score: 5/5

此 PR 看起来可以安全合并。

未发现仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
scripts/test-workspaces.mjs 文件遍历现在忽略 tmp 目录,并将不可读目录的容错范围限制为权限错误;此前线程指出的错误被无条件吞掉问题已修复。

Reviews (2): Last reviewed commit: "fix(test-runner): restrict readAllFiles ..." | Re-trigger Greptile

Comment thread scripts/test-workspaces.mjs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46ad0c9e52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/test-workspaces.mjs Outdated
…S only

The unconditional catch in readAllFiles() swallowed all errors, including
real I/O errors like EIO and ENOTDIR. Restrict the catch to only
EPERM and EACCES (permission denied), and re-throw other errors so
real filesystem issues propagate correctly.

Addresses P1 and P2 review feedback on makecindy#3356.

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi added the status:ci-failed CI 失败(review-pr 自动维护,仅展示) label Aug 24, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

@MagicLizi MagicLizi added status:conflict 与目标分支有冲突(review-pr 自动维护,仅展示) status:ci-failed CI 失败(review-pr 自动维护,仅展示) and removed status:ci-failed CI 失败(review-pr 自动维护,仅展示) status:conflict 与目标分支有冲突(review-pr 自动维护,仅展示) labels Aug 25, 2026
@MagicLizi MagicLizi added status:ci-failed CI 失败(review-pr 自动维护,仅展示) status:conflict 与目标分支有冲突(review-pr 自动维护,仅展示) and removed status:conflict 与目标分支有冲突(review-pr 自动维护,仅展示) status:ci-failed CI 失败(review-pr 自动维护,仅展示) labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:ci-failed CI 失败(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants