fix(tests): resolve Windows CI test failures (#701)

* fix(tests): skip bash tests on Windows and fix USERPROFILE in resolve-ecc-root

- hooks.test.js: add SKIP_BASH guard for 8 bash-dependent tests
  (detect-project.sh, observe.sh) while keeping 207 Node.js tests running
- resolve-ecc-root.test.js: add USERPROFILE to env overrides in 2
  INLINE_RESOLVE tests so os.homedir() resolves correctly on Windows

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* fix(tests): handle BOM in shebang stripping and skip worktree tests on Windows

- validators.test.js: replace regex stripShebang with character-code
  approach that handles UTF-8 BOM before shebang line
- detect-project-worktree.test.js: skip entire file on Windows since
  tests invoke bash scripts directly

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Happy <yesreply@happy.engineering>
This commit is contained in:
Chris Yau
2026-03-20 18:37:21 +08:00
committed by GitHub
parent 162236f463
commit b61f549444
4 changed files with 158 additions and 121 deletions

View File

@@ -50,15 +50,6 @@ function setupPluginCache(homeDir, orgName, version) {
return cacheDir;
}
function withHomeEnv(homeDir, extraEnv = {}) {
return {
PATH: process.env.PATH,
HOME: homeDir,
USERPROFILE: homeDir,
...extraEnv,
};
}
function runTests() {
console.log('\n=== Testing resolve-ecc-root.js ===\n');
@@ -224,7 +215,7 @@ function runTests() {
const result = execFileSync('node', [
'-e', `console.log(${INLINE_RESOLVE})`,
], {
env: withHomeEnv(homeDir),
env: { PATH: process.env.PATH, HOME: homeDir, USERPROFILE: homeDir },
encoding: 'utf8',
}).trim();
assert.strictEqual(result, expected);
@@ -240,7 +231,7 @@ function runTests() {
const result = execFileSync('node', [
'-e', `console.log(${INLINE_RESOLVE})`,
], {
env: withHomeEnv(homeDir),
env: { PATH: process.env.PATH, HOME: homeDir, USERPROFILE: homeDir },
encoding: 'utf8',
}).trim();
assert.strictEqual(result, path.join(homeDir, '.claude'));