mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-17 19:27:00 +00:00
Improve test runner logging
- Strip ANSI escape codes from stdout/stderr to reduce log size (spinner animations were ~95% of inference log size) - Add [TIMEOUT] indicator when commands are killed due to timeout for clearer failure diagnosis 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,15 @@ import { TestCase, TestResult, StepResult } from './types.js'
|
|||||||
|
|
||||||
const execAsync = promisify(exec)
|
const execAsync = promisify(exec)
|
||||||
|
|
||||||
|
// Strip ANSI escape codes to reduce log size
|
||||||
|
function stripAnsi(str: string): string {
|
||||||
|
// Matches ANSI escape sequences including:
|
||||||
|
// - CSI sequences: ESC [ ... (letter) - includes ? for private modes like [?25h
|
||||||
|
// - OSC sequences: ESC ] ... (BEL or ESC \)
|
||||||
|
// - Simple escapes: ESC (letter)
|
||||||
|
return str.replace(/\x1b\[[0-9;?]*[a-zA-Z]|\x1b\][^\x07]*\x07|\x1b[()][AB012]|\x1b[a-zA-Z]/g, '')
|
||||||
|
}
|
||||||
|
|
||||||
export class TestExecutor {
|
export class TestExecutor {
|
||||||
private workingDir: string
|
private workingDir: string
|
||||||
private totalTests: number = 0
|
private totalTests: number = 0
|
||||||
@@ -23,6 +32,7 @@ export class TestExecutor {
|
|||||||
let stdout = ''
|
let stdout = ''
|
||||||
let stderr = ''
|
let stderr = ''
|
||||||
let exitCode = 0
|
let exitCode = 0
|
||||||
|
let timedOut = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await execAsync(command, {
|
const result = await execAsync(command, {
|
||||||
@@ -37,10 +47,20 @@ export class TestExecutor {
|
|||||||
stdout = error.stdout || ''
|
stdout = error.stdout || ''
|
||||||
stderr = error.stderr || error.message || 'Unknown error'
|
stderr = error.stderr || error.message || 'Unknown error'
|
||||||
exitCode = error.code || 1
|
exitCode = error.code || 1
|
||||||
|
timedOut = error.killed === true
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = Date.now() - startTime
|
const duration = Date.now() - startTime
|
||||||
|
|
||||||
|
// Strip ANSI escape codes to reduce log size
|
||||||
|
stdout = stripAnsi(stdout)
|
||||||
|
stderr = stripAnsi(stderr)
|
||||||
|
|
||||||
|
// Add timeout indicator if command was killed
|
||||||
|
if (timedOut) {
|
||||||
|
stderr = `[TIMEOUT] Command killed after ${timeout / 1000}s\n\n${stderr}`
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
command,
|
command,
|
||||||
|
|||||||
Reference in New Issue
Block a user