Files
everything-claude-code/tests/run-all.js
Affaan Mustafa ed7ec29ead fix: migrate hooks to stdin JSON input, fix duplicate main() calls, add threshold validation
- Migrate session-end.js and evaluate-session.js from CLAUDE_TRANSCRIPT_PATH
  env var to stdin JSON transcript_path (correct hook input mechanism)
- Remove duplicate main() calls that ran before stdin was read, causing
  session files to be created with empty data
- Add range validation (1-10000) on COMPACT_THRESHOLD in suggest-compact.js
  to prevent negative or absurdly large thresholds
- Add integration/hooks.test.js to tests/run-all.js so CI runs all 97 tests
- Update evaluate-session.sh to parse transcript_path from stdin JSON
- Update hooks.test.js to pass transcript_path via stdin instead of env var
- Sync .cursor/ copies
2026-02-12 15:33:55 -08:00

78 lines
3.1 KiB
JavaScript

#!/usr/bin/env node
/**
* Run all tests
*
* Usage: node tests/run-all.js
*/
const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');
const testsDir = __dirname;
const testFiles = [
'lib/utils.test.js',
'lib/package-manager.test.js',
'hooks/hooks.test.js',
'integration/hooks.test.js'
];
console.log('╔══════════════════════════════════════════════════════════╗');
console.log('║ Everything Claude Code - Test Suite ║');
console.log('╚══════════════════════════════════════════════════════════╝');
console.log();
let totalPassed = 0;
let totalFailed = 0;
let totalTests = 0;
for (const testFile of testFiles) {
const testPath = path.join(testsDir, testFile);
if (!fs.existsSync(testPath)) {
console.log(`⚠ Skipping ${testFile} (file not found)`);
continue;
}
console.log(`\n━━━ Running ${testFile} ━━━`);
try {
const output = execSync(`node "${testPath}"`, {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe']
});
console.log(output);
// Parse results from output
const passedMatch = output.match(/Passed:\s*(\d+)/);
const failedMatch = output.match(/Failed:\s*(\d+)/);
if (passedMatch) totalPassed += parseInt(passedMatch[1], 10);
if (failedMatch) totalFailed += parseInt(failedMatch[1], 10);
} catch (err) {
console.log(err.stdout || '');
console.log(err.stderr || '');
// Parse results even on failure
const output = (err.stdout || '') + (err.stderr || '');
const passedMatch = output.match(/Passed:\s*(\d+)/);
const failedMatch = output.match(/Failed:\s*(\d+)/);
if (passedMatch) totalPassed += parseInt(passedMatch[1], 10);
if (failedMatch) totalFailed += parseInt(failedMatch[1], 10);
}
}
totalTests = totalPassed + totalFailed;
console.log('\n╔══════════════════════════════════════════════════════════╗');
console.log('║ Final Results ║');
console.log('╠══════════════════════════════════════════════════════════╣');
console.log(`║ Total Tests: ${String(totalTests).padStart(4)}`);
console.log(`║ Passed: ${String(totalPassed).padStart(4)} ✓ ║`);
console.log(`║ Failed: ${String(totalFailed).padStart(4)} ${totalFailed > 0 ? '✗' : ' '}`);
console.log('╚══════════════════════════════════════════════════════════╝');
process.exit(totalFailed > 0 ? 1 : 0);