🎨 format code

This commit is contained in:
Tw93
2025-08-14 11:20:15 +08:00
parent 7adeb91ae9
commit 256cdc77ee
12 changed files with 745 additions and 639 deletions

View File

@@ -7,71 +7,72 @@
* Usage: node tests/index.js [--unit] [--integration] [--manual]
*/
import cliTestRunner from './cli.test.js';
import integrationTestRunner from './integration.test.js';
import builderTestRunner from './builder.test.js';
import { execSync } from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';
import ora from 'ora';
import cliTestRunner from "./cli.test.js";
import integrationTestRunner from "./integration.test.js";
import builderTestRunner from "./builder.test.js";
import { execSync } from "child_process";
import path from "path";
import { fileURLToPath } from "url";
import ora from "ora";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.dirname(__dirname);
const cliPath = path.join(projectRoot, 'dist/cli.js');
const cliPath = path.join(projectRoot, "dist/cli.js");
const args = process.argv.slice(2);
const runUnit = args.length === 0 || args.includes('--unit');
const runIntegration = args.length === 0 || args.includes('--integration');
const runBuilder = args.length === 0 || args.includes('--builder');
const runUnit = args.length === 0 || args.includes("--unit");
const runIntegration = args.length === 0 || args.includes("--integration");
const runBuilder = args.length === 0 || args.includes("--builder");
async function runAllTests() {
console.log('🚀 Pake CLI Test Suite');
console.log('=======================\n');
console.log("🚀 Pake CLI Test Suite");
console.log("=======================\n");
let totalPassed = 0;
let totalTests = 0;
if (runUnit) {
console.log('📋 Running Unit Tests...\n');
console.log("📋 Running Unit Tests...\n");
await cliTestRunner.runAll();
totalPassed += cliTestRunner.results.filter(r => r.passed).length;
totalPassed += cliTestRunner.results.filter((r) => r.passed).length;
totalTests += cliTestRunner.results.length;
console.log('');
console.log("");
}
if (runIntegration) {
console.log('🔧 Running Integration Tests...\n');
console.log("🔧 Running Integration Tests...\n");
await integrationTestRunner.runAll();
totalPassed += integrationTestRunner.results.filter(r => r.passed).length;
totalPassed += integrationTestRunner.results.filter((r) => r.passed).length;
totalTests += integrationTestRunner.results.length;
console.log('');
console.log("");
}
if (runBuilder) {
console.log('🏗️ Running Builder Tests...\n');
console.log("🏗️ Running Builder Tests...\n");
await builderTestRunner.runAll();
totalPassed += builderTestRunner.results.filter(r => r.passed).length;
totalPassed += builderTestRunner.results.filter((r) => r.passed).length;
totalTests += builderTestRunner.results.length;
console.log('');
console.log("");
}
// Final summary
console.log('🎯 Overall Test Summary');
console.log('=======================');
console.log("🎯 Overall Test Summary");
console.log("=======================");
console.log(`Total: ${totalPassed}/${totalTests} tests passed`);
if (totalPassed === totalTests) {
console.log('🎉 All tests passed! CLI is ready for use.\n');
console.log("🎉 All tests passed! CLI is ready for use.\n");
} else {
console.log(`${totalTests - totalPassed} test(s) failed. Please check the issues above.\n`);
console.log(
`${totalTests - totalPassed} test(s) failed. Please check the issues above.\n`,
);
}
// Exit with appropriate code
process.exit(totalPassed === totalTests ? 0 : 1);
}
runAllTests().catch(error => {
console.error('❌ Test runner failed:', error);
runAllTests().catch((error) => {
console.error("❌ Test runner failed:", error);
process.exit(1);
});