* Main test runner
()
| 593 | * Main test runner |
| 594 | */ |
| 595 | async function runTests() { |
| 596 | log('=================================', 'info'); |
| 597 | log('Documentation Snippet Validation', 'info'); |
| 598 | log('=================================\n', 'info'); |
| 599 | |
| 600 | // Load cache |
| 601 | fileCache = loadCache(); |
| 602 | |
| 603 | if (specificFile) { |
| 604 | log(`Testing specific file: ${specificFile}\n`, 'info'); |
| 605 | } else if (clearCache) { |
| 606 | log('Cache cleared - testing all files\n', 'info'); |
| 607 | } else if (testAll) { |
| 608 | log('Testing all files (cache ignored)\n', 'info'); |
| 609 | } else { |
| 610 | const cachedCount = Object.keys(fileCache).length; |
| 611 | if (cachedCount > 0) { |
| 612 | log(`Found cache with ${cachedCount} previously tested files\n`, 'info'); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | log(`Searching for documentation files in: ${DOCS_BASE_DIR}`, 'info'); |
| 617 | |
| 618 | let docFiles = findDocFiles(); |
| 619 | |
| 620 | // Filter to specific file if requested |
| 621 | if (specificFile) { |
| 622 | const absolutePath = path.isAbsolute(specificFile) |
| 623 | ? specificFile |
| 624 | : path.join(process.cwd(), specificFile); |
| 625 | docFiles = docFiles.filter(f => f === absolutePath); |
| 626 | if (docFiles.length === 0) { |
| 627 | log(`Error: File not found: ${specificFile}`, 'error'); |
| 628 | process.exit(1); |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | log(`Found ${docFiles.length} documentation files\n`, 'info'); |
| 633 | |
| 634 | // Group files by cached status |
| 635 | const filesToTest = []; |
| 636 | const cachedPassedFiles = []; |
| 637 | |
| 638 | for (const file of docFiles) { |
| 639 | if (isFileCached(file, fileCache)) { |
| 640 | cachedPassedFiles.push(file); |
| 641 | cachedFiles++; |
| 642 | } else { |
| 643 | filesToTest.push(file); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | if (cachedPassedFiles.length > 0) { |
| 648 | log(`Skipping ${cachedPassedFiles.length} files (already passed, unchanged)`, 'dim'); |
| 649 | } |
| 650 | |
| 651 | if (filesToTest.length === 0) { |
| 652 | log('\n✅ All files already tested and passing!', 'success'); |
no test coverage detected