Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test(windows): pin native Bash and normalize executable paths

haelyraa194883e0d5e
diff --git a/tests/hooks/ecc-statusline-late.test.js b/tests/hooks/ecc-statusline-late.test.js
index e84ab5d6a..253e7e3fa 100644
--- a/tests/hooks/ecc-statusline-late.test.js
+++ b/tests/hooks/ecc-statusline-late.test.js
@@ -6,9 +6,13 @@ const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const test = require('node:test');
+const { resolveWindowsBashCandidates } = require('../../scripts/lib/windows-bash');
const { buildUsageLines } = require('../../scripts/hooks/ecc-statusline');
const { buildUsageLine } = require('../../scripts/lib/statusline-render');
-const shellQuote = value => "'" + value.replace(/'/g, "'\\''") + "'";
+const shellQuote = value => {
+ const portable = process.platform === 'win32' ? value.split('\\').join('/') : value;
+ return "'" + portable.replace(/'/g, "'\\''") + "'";
+};
const repoRoot = path.resolve(__dirname, '../..');
// eslint-disable-next-line no-control-regex -- Statusline ANSI output is the fixture boundary.
const stripAnsi = value => value.replace(/\x1b\[[0-9;]*m/g, '');
@@ -32,7 +36,9 @@ function registeredDisplay(t, payload, options = {}, bridge) {
const env = { ...process.env, HOME: home, USERPROFILE: home, CLAUDE_CONFIG_DIR: configDir, TMPDIR: temporaryDir, TEMP: temporaryDir, TMP: temporaryDir,
ECC_STATUSLINE_USAGE: '1', ECC_STATUSLINE_COMPACT: '0', ECC_BAR_GLYPHS: 'ascii', ...options };
if (env.ECC_STATUSLINE_USAGE === undefined) delete env.ECC_STATUSLINE_USAGE;
- const result = spawnSync(process.platform === 'win32' ? 'bash' : '/bin/sh', ['-c', settings.statusLine.command], {
+ const shell = process.platform === 'win32' ? resolveWindowsBashCandidates(['bash.exe', 'bash'], { env })[0] : '/bin/sh';
+ assert.ok(shell, 'A native Git Bash executable is required for the Windows registration check');
+ const result = spawnSync(shell, ['-c', settings.statusLine.command], {
input: JSON.stringify(payload), encoding: 'utf8', env, timeout: 5000, cwd: home,
});
assert.equal(result.status, 0, result.stderr);
diff --git a/tests/lib/command-plugin-root.test.js b/tests/lib/command-plugin-root.test.js
index 93f7390ce..0e7295dbf 100644
--- a/tests/lib/command-plugin-root.test.js
+++ b/tests/lib/command-plugin-root.test.js
@@ -5,6 +5,7 @@ const path = require('path');
const os = require('os');
const assert = require('assert');
const { spawnSync } = require('child_process');
+const { resolveWindowsBashCandidates } = require('../../scripts/lib/windows-bash');
const { INLINE_RESOLVE } = require('../../scripts/lib/resolve-ecc-root');
// Sentinel ECC skill that resolveEccRoot() requires alongside the script tree
@@ -115,7 +116,10 @@ for (const name of ['auto-update', 'instinct-status', 'skill-health', 'skill-hos
const selected = { ...process.env, HOME: temp, USERPROFILE: temp, CLAUDE_CONFIG_DIR: root };
delete selected.CLAUDE_PLUGIN_ROOT;
for (const env of [selected, { ...selected, CLAUDE_PLUGIN_ROOT: root }]) {
- const result = spawnSync('bash', ['-s'],
+ const [bash] = resolveWindowsBashCandidates(['bash.exe', 'bash'], { env });
+ const shell = process.platform === 'win32' ? bash : 'bash';
+ assert.ok(shell, 'A native Git Bash executable is required');
+ const result = spawnSync(shell, ['-s'],
{ input: assignment + '\nprintf "%s" "$ECC_ROOT"\n', env, cwd: temp, encoding: 'utf8' });
assert.strictEqual(result.status, 0, result.stderr);
assert.strictEqual(result.stderr, '');