mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-08 07:37:48 +02:00
test(hooks): report unavailable Windows runtimes
This commit is contained in:
@@ -60,6 +60,7 @@ function runTests() {
|
|||||||
|
|
||||||
let passed = 0;
|
let passed = 0;
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
|
let skipped = 0;
|
||||||
|
|
||||||
if (test('emits empty stdout and stderr warning when required bootstrap inputs are missing', () => {
|
if (test('emits empty stdout and stderr warning when required bootstrap inputs are missing', () => {
|
||||||
const result = run([], { input: '{"ok":true}' });
|
const result = run([], { input: '{"ok":true}' });
|
||||||
@@ -315,13 +316,17 @@ process.exit(7);
|
|||||||
|
|
||||||
// Windows-only: PowerShell preference and .sh fallback behaviour.
|
// Windows-only: PowerShell preference and .sh fallback behaviour.
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
if (test('shell mode selects PowerShell when BASH is unset on Windows', () => {
|
const psProbe = spawnSync('pwsh.exe', ['-NoProfile', '-NonInteractive', '-Command', 'exit 0'], { stdio: 'ignore', timeout: 5000 });
|
||||||
const psProbe = spawnSync('pwsh.exe', ['-NoProfile', '-NonInteractive', '-Command', 'exit 0'], { stdio: 'ignore', timeout: 5000 });
|
const ps = psProbe.error
|
||||||
const ps = psProbe.error
|
? spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', 'exit 0'], { stdio: 'ignore', timeout: 5000 }).error
|
||||||
? spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', 'exit 0'], { stdio: 'ignore', timeout: 5000 }).error
|
? null : 'powershell.exe'
|
||||||
? null : 'powershell.exe'
|
: 'pwsh.exe';
|
||||||
: 'pwsh.exe';
|
|
||||||
assert.ok(ps, 'Windows shell-path coverage requires PowerShell');
|
if (!ps) {
|
||||||
|
skipped += 5;
|
||||||
|
console.log(' SKIP 5 Windows shell-branch tests: PowerShell is unavailable');
|
||||||
|
} else {
|
||||||
|
if (test('shell mode selects PowerShell when BASH is unset on Windows', () => {
|
||||||
|
|
||||||
const root = createTempDir();
|
const root = createTempDir();
|
||||||
try {
|
try {
|
||||||
@@ -344,9 +349,9 @@ process.exit(7);
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup(root);
|
cleanup(root);
|
||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (test('PowerShell branch suppresses raw stdin echoed by the child', () => {
|
if (test('PowerShell branch suppresses raw stdin echoed by the child', () => {
|
||||||
const root = createTempDir();
|
const root = createTempDir();
|
||||||
try {
|
try {
|
||||||
writeFile(root, path.join('scripts', 'passthrough.ps1'), [
|
writeFile(root, path.join('scripts', 'passthrough.ps1'), [
|
||||||
@@ -368,11 +373,13 @@ process.exit(7);
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup(root);
|
cleanup(root);
|
||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (test('shell mode falls back to bash for .sh scripts when PowerShell is the resolved shell', () => {
|
|
||||||
const bashProbe = spawnSync('bash.exe', ['-c', ':'], { stdio: 'ignore', timeout: 5000 });
|
const bashProbe = spawnSync('bash.exe', ['-c', ':'], { stdio: 'ignore', timeout: 5000 });
|
||||||
assert.ok(!bashProbe.error && bashProbe.status === 0, 'Windows .sh fallback coverage requires bash.exe');
|
const bashAvailable = !bashProbe.error && bashProbe.status === 0;
|
||||||
|
|
||||||
|
if (bashAvailable) {
|
||||||
|
if (test('shell mode falls back to bash for .sh scripts when PowerShell is the resolved shell', () => {
|
||||||
|
|
||||||
const root = createTempDir();
|
const root = createTempDir();
|
||||||
try {
|
try {
|
||||||
@@ -394,9 +401,9 @@ process.exit(7);
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup(root);
|
cleanup(root);
|
||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (test('PowerShell .sh fallback branch suppresses raw stdin echoed by bash', () => {
|
if (test('PowerShell .sh fallback branch suppresses raw stdin echoed by bash', () => {
|
||||||
const root = createTempDir();
|
const root = createTempDir();
|
||||||
try {
|
try {
|
||||||
writeFile(root, path.join('scripts', 'passthrough.sh'), 'cat\n');
|
writeFile(root, path.join('scripts', 'passthrough.sh'), 'cat\n');
|
||||||
@@ -413,9 +420,13 @@ process.exit(7);
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup(root);
|
cleanup(root);
|
||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
} else {
|
||||||
|
skipped += 2;
|
||||||
|
console.log(' SKIP 2 Windows .sh fallback tests: bash.exe is unavailable');
|
||||||
|
}
|
||||||
|
|
||||||
if (test('shell mode emits skip warning for .sh script when no bash found on Windows', () => {
|
if (test('shell mode emits skip warning for .sh script when no bash found on Windows', () => {
|
||||||
const root = createTempDir();
|
const root = createTempDir();
|
||||||
try {
|
try {
|
||||||
writeFile(root, path.join('scripts', 'hook.sh'), 'printf unreachable\n');
|
writeFile(root, path.join('scripts', 'hook.sh'), 'printf unreachable\n');
|
||||||
@@ -440,10 +451,14 @@ process.exit(7);
|
|||||||
} finally {
|
} finally {
|
||||||
cleanup(root);
|
cleanup(root);
|
||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
||||||
|
if (skipped > 0) {
|
||||||
|
console.log(`Skipped: ${skipped}`);
|
||||||
|
}
|
||||||
process.exit(failed > 0 ? 1 : 0);
|
process.exit(failed > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user