Skip to content

test(scripts): cover repository-linter race guards - #827

Merged
tobyhede merged 3 commits into
remove-v2from
fix/pr-824-review-feedback
Jul 29, 2026
Merged

test(scripts): cover repository-linter race guards#827
tobyhede merged 3 commits into
remove-v2from
fix/pr-824-review-feedback

Conversation

@tobyhede

@tobyhede tobyhede commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cover the walk() ENOENT skip path and unexpected-error rethrow path
  • reproduce the nested directory-disappearance race deterministically
  • skip files that vanish after enumeration while rethrowing other read errors
  • guard the load-bearing fileParallelism: false scripts-test setting

Follow-up to #824, addressing its unresolved review feedback.

Validation

  • pnpm test:scripts — 137 tests passed
  • Biome check on changed files
  • CodeRabbit committed-change review — zero findings

No changeset: test-only repository tooling changes.

@tobyhede
tobyhede requested a review from a team as a code owner July 29, 2026 02:00
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9c7ff43

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: added tests guarding repository-linter race conditions in scripts.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/__tests__/lint-no-hardcoded-runners.test.mjs`:
- Around line 15-18: Update the runScript helper to use an API such as spawnSync
that captures both stdout and stderr on successful execution, then combine those
streams into output before returning it. Preserve the existing exitCode behavior
and ensure assertions can inspect zero-exit stderr output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e483b7d-75cf-429c-b53d-884a7bf605b3

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6395c and 78b9ab3.

📒 Files selected for processing (2)
  • scripts/__tests__/lint-no-hardcoded-runners.test.mjs
  • scripts/__tests__/vitest-config.test.mjs

Comment on lines +15 to +18
const output = execFileSync(process.execPath, [script, ...targets], {
encoding: 'utf8',
})
return { exitCode: 0, output }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching target:'
fd -a 'lint-no-hardcoded-runners.test.mjs' . || true

file="$(fd 'lint-no-hardcoded-runners.test.mjs' . | head -n1 || true)"
if [ -n "${file:-}" ]; then
  printf '\nFile: %s\n' "$file"
  wc -l "$file"
  printf '\nRelevant test file excerpts:\n'
  sed -n '1,120p' "$file" | cat -n
fi

printf '\nExecutable files under scripts that might be test targets:\n'
find scripts -maxden depth 3 -type f -executable 2>/dev/null | sed -n '1,120p' || true

printf '\nSearch for spawnSync/fetch/execFileSync in test file:\n'
rg -n "execFileSync|spawnSync|stderr|stdout|exitCode|diagnostic|error" "$file" 2>/dev/null || true

Repository: cipherstash/stack

Length of output: 6398


🌐 Web query:

Node.js child_process execFileSync return value stdout on success does not return stderr documentation

💡 Result:

The child_process.execFileSync method in Node.js returns only the stdout of the command as a string or Buffer upon success [1][2][3]. It does not return stderr, nor does it return an object containing both stdout and stderr [1][4]. By default, the stderr of the child process is piped to the parent process's stderr [1][5]. If you need to capture stderr, you must explicitly configure the stdio option to pipe it [1][6]. However, even when stdio is configured to 'pipe', the return value of execFileSync remains only the stdout [1][2]. To access stderr when using execFileSync, you must handle the error thrown if the process exits with a non-zero exit code [1][7]. When the process fails, the thrown Error object includes the stdout and stderr properties [1][4][7]. If the process succeeds, however, stderr is typically inherited by the parent process and is not available via the return value of the function [1][5]. To capture both streams successfully during normal execution, you may need to use different child process methods or manually manage the stdio streams [8].

Citations:


Capture stderr on successful runs too.

execFileSync() returns only stdout on success, so zero-exit stderr output is unavailable to the runScript() helper. Use an API that exposes both streams, such as spawnSync, and combine them before the assertions check output.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/__tests__/lint-no-hardcoded-runners.test.mjs` around lines 15 - 18,
Update the runScript helper to use an API such as spawnSync that captures both
stdout and stderr on successful execution, then combine those streams into
output before returning it. Preserve the existing exitCode behavior and ensure
assertions can inspect zero-exit stderr output.

@tobyhede

Copy link
Copy Markdown
Contributor Author

Inline Feedback Addressed

Verified and fixed the successful-stderr capture finding in scripts/__tests__/lint-no-hardcoded-runners.test.mjs.

runScript() now combines stdout and stderr for every exit status, with a regression test covering stderr from an exit-0 subprocess.

Commit: 9c7ff43b

Validation passed: 137 scripts tests, Biome, and a zero-finding CodeRabbit review.

@auxesis auxesis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tobyhede thanks, appreciate the follow up to #824. ❤️

@tobyhede
tobyhede merged commit 9efecb2 into remove-v2 Jul 29, 2026
7 checks passed
@tobyhede
tobyhede deleted the fix/pr-824-review-feedback branch July 29, 2026 02:55
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.

2 participants