#!/usr/bin/env node /** * Run all tests * * Usage: node tests/run-all.js */ const { spawnSync } = require('child_process'); const path = require('path'); const fs = require('fs'); const testsDir = __dirname; const repoRoot = path.resolve(testsDir, '..'); const TEST_GLOB = 'tests/**/*.test.js'; function matchesTestGlob(relativePath) { const normalized = relativePath.split(path.sep).join('/'); if (typeof path.matchesGlob === 'function') { return path.matchesGlob(normalized, TEST_GLOB); } return /^tests\/(?:.+\/)?[^/]+\.test\.js$/.test(normalized); } function walkFiles(dir, acc = []) { const entries = fs.readdirSync(dir, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(dir, entry.name); if (entry.isDirectory()) { walkFiles(fullPath, acc); } else if (entry.isFile()) { acc.push(fullPath); } } return acc; } function discoverTestFiles() { return walkFiles(testsDir) .map(fullPath => path.relative(repoRoot, fullPath)) .filter(matchesTestGlob) .map(repoRelativePath => path.relative(testsDir, path.join(repoRoot, repoRelativePath))) .sort(); } const testFiles = discoverTestFiles(); const BOX_W = 58; // inner width between ║ delimiters const boxLine = s => `║${s.padEnd(BOX_W)}║`; console.log('╔' + '═'.repeat(BOX_W) + '╗'); console.log(boxLine(' Everything Claude Code - Test Suite')); console.log('╚' + '═'.repeat(BOX_W) + '╝'); console.log(); if (testFiles.length === 0) { console.log(`✗ No test files matched ${TEST_GLOB}`); process.exit(1); } let totalPassed = 0; let totalFailed = 0; let totalTests = 0; for (const testFile of testFiles) { const testPath = path.join(testsDir, testFile); const displayPath = testFile.split(path.sep).join('/'); if (!fs.existsSync(testPath)) { console.log(`WARNING Skipping ${displayPath} (file not found)`); continue; } console.log(`\n━━━ Running ${displayPath} ━━━`); // Run each test hermetically: strip inherited git env vars. When the suite // runs inside a git hook (e.g. pre-push), git sets GIT_DIR/GIT_WORK_TREE, // which would hijack `git -C