fix(tests): iteration 3
This commit is contained in:
+103
-87
@@ -36,102 +36,35 @@ for (let i = 0; i < args.length; i++) {
|
|||||||
|
|
||||||
$.verbose = false
|
$.verbose = false
|
||||||
|
|
||||||
console.log('🧪 Paseo CLI E2E Test Runner\n')
|
type Failure = { test: string; error: string }
|
||||||
console.log('='.repeat(50))
|
|
||||||
|
|
||||||
// Discover all test files
|
|
||||||
const files = await readdir(__dirname)
|
|
||||||
const testFiles = files
|
|
||||||
.filter(f => f.match(/^\d{2}-.*\.test\.ts$/))
|
|
||||||
.sort()
|
|
||||||
|
|
||||||
if (testFiles.length === 0) {
|
|
||||||
console.log('❌ No test files found')
|
|
||||||
if (jsonOutputPath) {
|
|
||||||
await writeFile(
|
|
||||||
jsonOutputPath,
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
suite: 'cli-local',
|
|
||||||
command: 'npm run test:local --workspace=@getpaseo/cli',
|
|
||||||
counts: {
|
|
||||||
passed: 0,
|
|
||||||
failed: 0,
|
|
||||||
skipped: 0,
|
|
||||||
},
|
|
||||||
skippedTests: [],
|
|
||||||
failures: [],
|
|
||||||
error: 'No test files found',
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
) + '\n'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Found ${testFiles.length} test file(s):\n`)
|
|
||||||
for (const file of testFiles) {
|
|
||||||
console.log(` - ${file}`)
|
|
||||||
}
|
|
||||||
console.log()
|
|
||||||
|
|
||||||
let passed = 0
|
|
||||||
let failed = 0
|
|
||||||
const failures: { test: string; error: string }[] = []
|
|
||||||
|
|
||||||
for (const testFile of testFiles) {
|
|
||||||
const testPath = join(__dirname, testFile)
|
|
||||||
const testName = testFile.replace(/\.test\.ts$/, '')
|
|
||||||
|
|
||||||
|
async function runCommand(label: string, command: string): Promise<void> {
|
||||||
console.log(`\n${'─'.repeat(50)}`)
|
console.log(`\n${'─'.repeat(50)}`)
|
||||||
console.log(`📋 Running ${testName}...`)
|
console.log(`🔧 ${label}...`)
|
||||||
console.log('─'.repeat(50))
|
console.log('─'.repeat(50))
|
||||||
|
|
||||||
try {
|
const result = await $`bash -lc ${command}`.nothrow()
|
||||||
const result = await $`PASEO_LOCAL_SPEECH_AUTO_DOWNLOAD=${testEnvDefaults.PASEO_LOCAL_SPEECH_AUTO_DOWNLOAD} PASEO_DICTATION_ENABLED=${testEnvDefaults.PASEO_DICTATION_ENABLED} PASEO_VOICE_MODE_ENABLED=${testEnvDefaults.PASEO_VOICE_MODE_ENABLED} npx tsx ${testPath}`.nothrow()
|
if (result.exitCode !== 0) {
|
||||||
if (result.exitCode === 0) {
|
const error = result.stderr || result.stdout || `Exit code: ${result.exitCode}`
|
||||||
console.log(`\n✅ ${testName} PASSED`)
|
console.error(`\n❌ ${label} failed`)
|
||||||
passed++
|
console.error(error)
|
||||||
} else {
|
throw new Error(error)
|
||||||
console.log(`\n❌ ${testName} FAILED (exit code: ${result.exitCode})`)
|
|
||||||
if (result.stderr) {
|
|
||||||
console.log('stderr:', result.stderr)
|
|
||||||
}
|
|
||||||
failed++
|
|
||||||
failures.push({ test: testName, error: result.stderr || `Exit code: ${result.exitCode}` })
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
const error = e instanceof Error ? e.message : String(e)
|
|
||||||
console.log(`\n❌ ${testName} FAILED`)
|
|
||||||
console.log('Error:', error)
|
|
||||||
failed++
|
|
||||||
failures.push({ test: testName, error })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Summary
|
async function writeJsonSummary({
|
||||||
console.log('\n' + '='.repeat(50))
|
passed,
|
||||||
console.log('📊 Test Results')
|
failed,
|
||||||
console.log('='.repeat(50))
|
failures,
|
||||||
console.log(` ✅ Passed: ${passed}`)
|
}: {
|
||||||
console.log(` ❌ Failed: ${failed}`)
|
passed: number
|
||||||
console.log(` 📝 Total: ${passed + failed}`)
|
failed: number
|
||||||
|
failures: Failure[]
|
||||||
if (failures.length > 0) {
|
}) {
|
||||||
console.log('\n❌ Failed tests:')
|
if (!jsonOutputPath) {
|
||||||
for (const { test, error } of failures) {
|
return
|
||||||
console.log(` - ${test}`)
|
|
||||||
if (error) {
|
|
||||||
console.log(` ${error.split('\n')[0]}`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log()
|
|
||||||
|
|
||||||
if (jsonOutputPath) {
|
|
||||||
await writeFile(
|
await writeFile(
|
||||||
jsonOutputPath,
|
jsonOutputPath,
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
@@ -155,4 +88,87 @@ if (jsonOutputPath) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('🧪 Paseo CLI E2E Test Runner\n')
|
||||||
|
console.log('='.repeat(50))
|
||||||
|
|
||||||
|
// Discover all test files
|
||||||
|
const files = await readdir(__dirname)
|
||||||
|
const testFiles = files
|
||||||
|
.filter(f => f.match(/^\d{2}-.*\.test\.ts$/))
|
||||||
|
.sort()
|
||||||
|
|
||||||
|
if (testFiles.length === 0) {
|
||||||
|
console.log('❌ No test files found')
|
||||||
|
await writeJsonSummary({ passed: 0, failed: 0, failures: [] })
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Found ${testFiles.length} test file(s):\n`)
|
||||||
|
for (const file of testFiles) {
|
||||||
|
console.log(` - ${file}`)
|
||||||
|
}
|
||||||
|
console.log()
|
||||||
|
|
||||||
|
let passed = 0
|
||||||
|
let failed = 0
|
||||||
|
const failures: Failure[] = []
|
||||||
|
|
||||||
|
await runCommand('Building relay', 'npm run build --workspace=@getpaseo/relay')
|
||||||
|
await runCommand('Building server', 'npm run build --workspace=@getpaseo/server')
|
||||||
|
await runCommand('Building CLI', 'npm run build --workspace=@getpaseo/cli')
|
||||||
|
|
||||||
|
for (const testFile of testFiles) {
|
||||||
|
const testPath = join(__dirname, testFile)
|
||||||
|
const testName = testFile.replace(/\.test\.ts$/, '')
|
||||||
|
|
||||||
|
console.log(`\n${'─'.repeat(50)}`)
|
||||||
|
console.log(`📋 Running ${testName}...`)
|
||||||
|
console.log('─'.repeat(50))
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await $`PASEO_LOCAL_SPEECH_AUTO_DOWNLOAD=${testEnvDefaults.PASEO_LOCAL_SPEECH_AUTO_DOWNLOAD} PASEO_DICTATION_ENABLED=${testEnvDefaults.PASEO_DICTATION_ENABLED} PASEO_VOICE_MODE_ENABLED=${testEnvDefaults.PASEO_VOICE_MODE_ENABLED} npx tsx ${testPath}`.nothrow()
|
||||||
|
if (result.exitCode === 0) {
|
||||||
|
console.log(`\n✅ ${testName} PASSED`)
|
||||||
|
passed++
|
||||||
|
} else {
|
||||||
|
console.log(`\n❌ ${testName} FAILED (exit code: ${result.exitCode})`)
|
||||||
|
if (result.stderr) {
|
||||||
|
console.log('stderr:', result.stderr)
|
||||||
|
}
|
||||||
|
failed++
|
||||||
|
failures.push({ test: testName, error: result.stderr || `Exit code: ${result.exitCode}` })
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
const error = e instanceof Error ? e.message : String(e)
|
||||||
|
console.log(`\n❌ ${testName} FAILED`)
|
||||||
|
console.log('Error:', error)
|
||||||
|
failed++
|
||||||
|
failures.push({ test: testName, error })
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Summary
|
||||||
|
console.log('\n' + '='.repeat(50))
|
||||||
|
console.log('📊 Test Results')
|
||||||
|
console.log('='.repeat(50))
|
||||||
|
console.log(` ✅ Passed: ${passed}`)
|
||||||
|
console.log(` ❌ Failed: ${failed}`)
|
||||||
|
console.log(` 📝 Total: ${passed + failed}`)
|
||||||
|
|
||||||
|
if (failures.length > 0) {
|
||||||
|
console.log('\n❌ Failed tests:')
|
||||||
|
for (const { test, error } of failures) {
|
||||||
|
console.log(` - ${test}`)
|
||||||
|
if (error) {
|
||||||
|
console.log(` ${error.split('\n')[0]}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log()
|
||||||
|
|
||||||
|
await writeJsonSummary({ passed, failed, failures })
|
||||||
|
|
||||||
process.exit(failed > 0 ? 1 : 0)
|
process.exit(failed > 0 ? 1 : 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user