tester

package module
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 18 Imported by: 0

README ΒΆ

Tester - Advanced Terminal Application Testing Framework

Go Reference Go Report Card GitHub release Go Version PRs Welcome

A powerful Go framework for testing terminal applications (TUI) in real-time, with crash detection, performance monitoring, and visual verification.

Features

πŸ” Comprehensive Testing
  • Virtual Terminal Emulation - Run real terminal apps in PTY
  • Keyboard Simulation - Send any key combination
  • Screen Capture - ASCII screenshots of terminal state
  • Layout Verification - Check positioning, centering, borders
πŸ›‘οΈ Reliability Testing
  • Crash Detection - Detect segfaults, panics, OOM kills
  • Advanced Hang Detection - Multi-layer hang prevention system
  • Memory Leak Detection - Monitor memory usage patterns
  • Performance Monitoring - Track CPU, memory, response times
🚨 Hang Prevention System (NEW!)
  • Watchdog Protection - Prevents tester from hanging when apps hang
  • Operation Timeouts - Configurable timeouts for all operations
  • Emergency Stop - Force termination of problematic applications
  • Graceful Recovery - Automatic cleanup and restart capabilities
🎨 Visual Testing
  • Color/ANSI Verification - Validate color output
  • Responsive Testing - Test different terminal sizes
  • Theme Testing - Verify theme changes
  • Unicode Support - Test international characters
πŸ“Š Reporting
  • Detailed Reports - Markdown reports with metrics
  • ASCII Screenshots - Visual proof of UI states
  • Performance Metrics - Response times, resource usage
  • Test Logs - Complete execution traces

Installation

go get github.com/akaoio/tester

Quick Start

package main

import (
    "log"
    "time"
    "github.com/akaoio/tester"
)

func main() {
    // Create virtual terminal with built-in hang protection
    term := tester.NewTerminal(80, 24)
    defer term.Close()
    
    // Configure timeouts (optional - has sensible defaults)
    term.SetTimeouts(30*time.Second, 5*time.Second) // global, operation
    
    // Start your app (protected against hanging)
    err := term.Start("./myapp")
    if err != nil {
        log.Fatal(err)
    }
    
    // All operations are now hang-protected
    term.Wait(500 * time.Millisecond)
    term.SendKeys("hello world")     // βœ… Won't hang
    term.SendKeys("<Enter>")         // βœ… Won't hang  
    term.SendKeys("<Ctrl+C>")        // βœ… Won't hang
    
    // Screenshot with protection
    screenshot := term.Screenshot()
    fmt.Println(screenshot)
    
    // Verify content
    if term.Contains("expected text") {
        fmt.Println("Test passed!")
    }
    
    // Check health + hang status
    health := term.Health()
    if health.Crashed {
        log.Fatalf("App crashed: %s", health.CrashReason)
    }
    
    if term.IsHanging() {
        log.Println("App is hanging - watchdog will handle it")
    }
}

Advanced Usage

Stress Testing
// Test crash scenarios
tester := tester.NewStressTester("./myapp")

// Try various crash scenarios
tester.TestCrash(tester.RapidInput)
tester.TestCrash(tester.InvalidEscape)
tester.TestCrash(tester.BufferOverflow)
tester.TestCrash(tester.RapidResize)

// Check for memory leaks
leaks := tester.DetectMemoryLeaks()
if len(leaks) > 0 {
    log.Printf("Memory leak detected: %+v", leaks)
}

// Monitor performance
metrics := tester.GetPerformanceMetrics()
fmt.Printf("Avg Response Time: %v\n", metrics.AvgResponseTime)
fmt.Printf("Peak Memory: %d MB\n", metrics.PeakMemory/1024/1024)
Visual Testing
// Test different screen sizes
sizes := []tester.Size{
    {30, 10},  // Watch
    {50, 20},  // Mobile
    {80, 24},  // Standard
    {120, 40}, // Desktop
}

for _, size := range sizes {
    term := tester.NewTerminal(size.Width, size.Height)
    term.Start("./myapp")
    
    // Verify layout adapts
    if !term.VerifyLayout(tester.Centered) {
        log.Printf("Layout broken at %dx%d", size.Width, size.Height)
    }
    
    term.Close()
}
Color Verification
term := tester.NewTerminal(80, 24)
term.Start("./myapp")

// Get color report
colors := term.GetColorReport()

if !colors.HasColors {
    log.Fatal("No colors detected")
}

if colors.Has256Colors {
    fmt.Println("256 color support verified")
}

fmt.Printf("ANSI sequences used: %d\n", colors.TotalSequences)
Test Suite Builder
suite := tester.NewSuite("MyApp Tests")

// Add test cases
suite.AddTest(tester.TestCase{
    Name: "Startup Test",
    Steps: []tester.Step{
        {Action: "wait", Duration: 500*time.Millisecond},
        {Action: "screenshot"},
    },
    Assertions: []tester.Assertion{
        {Type: "contains", Expected: "Welcome"},
        {Type: "no_crash"},
    },
})

suite.AddTest(tester.TestCase{
    Name: "Keyboard Navigation",
    Steps: []tester.Step{
        {Action: "keys", Input: "<Tab>"},
        {Action: "keys", Input: "<Enter>"},
        {Action: "screenshot"},
    },
    Assertions: []tester.Assertion{
        {Type: "contains", Expected: "Selected"},
    },
})

// Run all tests
report := suite.Run("./myapp")
report.SaveMarkdown("test_report.md")
report.SaveJSON("test_report.json")
Hang Prevention & Recovery
// Configure aggressive hang protection for problematic apps
term := tester.NewTerminal(80, 24)
defer term.Close()

// Set strict timeouts
term.SetTimeouts(10*time.Second, 2*time.Second) // global, operation

// Configure watchdog behavior
term.ConfigureWatchdog(tester.WatchdogConfig{
    MaxResponse:      1 * time.Second,   // Max response time
    CheckInterval:    200 * time.Millisecond, // Check frequency  
    ForceKillTimeout: 1 * time.Second,   // Time before force kill
})

// Start potentially problematic app
err := term.Start("./problematic-app")
if err != nil {
    log.Fatal(err)
}

// All operations are protected - won't hang the tester
err = term.SendKeys("some input that might cause hang")
if err != nil {
    log.Printf("Operation failed safely: %v", err)
}

// Check if hang was detected
if term.IsHanging() {
    log.Println("App is hanging, but tester continues")
    
    // Get watchdog statistics  
    stats := term.GetWatchdogStats()
    log.Printf("Watchdog interventions: %d timeouts, %d force kills", 
        stats.TimeoutCount, stats.ForceKillCount)
}

// Emergency stop if needed
if term.IsHanging() {
    term.ForceStop("Manual intervention")
}

// Use timeout wrapper for custom operations
err = term.WithTimeout("custom_operation", 3*time.Second, func() error {
    // Your custom operation that might hang
    return doSomethingRisky()
})

Testing Hanging Applications

The tester framework now includes robust protection against hanging applications:

Problem Solved
  • Before: Testing hanging apps would freeze the entire test suite
  • After: Watchdog system detects and terminates hanging apps automatically
  • Result: Test suites never hang, always complete with results
Example: Testing Dex Project
// Test the hanging dex project safely
func TestDexWithHangProtection(t *testing.T) {
    term := tester.NewTerminal(120, 40)
    defer term.Close()
    
    // Configure for known problematic app
    term.SetTimeouts(10*time.Second, 3*time.Second)
    
    // Start dex (known to hang)
    err := term.Start("./dex")
    if err != nil {
        t.Fatalf("Failed to start: %v", err)
    }
    
    // These operations won't hang the test
    term.SendKeys("test input")
    screenshot := term.Screenshot()
    
    // Test completes even if dex hangs
    stats := term.GetWatchdogStats()
    t.Logf("Watchdog protected against %d hangs", stats.HangCount)
}

Real-World Example - Testing a TUI App

func TestTUIApp(t *testing.T) {
    term := tester.NewTerminal(80, 24)
    defer term.Close()
    
    // Start app
    err := term.Start("./tui-app")
    require.NoError(t, err)
    
    // Test menu navigation
    term.SendKeys("<Down>")
    term.SendKeys("<Down>")
    term.SendKeys("<Enter>")
    
    // Verify we're in settings
    assert.True(t, term.Contains("Settings"))
    
    // Test form input
    term.SendKeys("John Doe")
    term.SendKeys("<Tab>")
    term.SendKeys("[email protected]")
    term.SendKeys("<Enter>")
    
    // Verify form submission
    assert.True(t, term.Contains("Saved successfully"))
    
    // Check no crashes
    health := term.Health()
    assert.False(t, health.Crashed)
    assert.False(t, health.IsHanging)
}

API Reference

Terminal
type Terminal struct {
    // Core methods
    Start(cmd string, args ...string) error
    Close() error
    Wait(duration time.Duration)
    
    // Input methods
    SendKeys(keys string) error
    SendRaw(bytes []byte) error
    
    // Screen methods
    Screenshot() string
    GetScreen() string
    Contains(text string) bool
    
    // Verification
    VerifyLayout(layout LayoutType) bool
    VerifyColors() ColorReport
    
    // Health monitoring
    Health() HealthReport
    IsRunning() bool
    
    // NEW: Hang prevention and control
    SetTimeouts(global, operation time.Duration)
    ConfigureWatchdog(config WatchdogConfig)
    GetWatchdogStats() WatchdogStats
    IsHanging() bool
    ForceStop(reason string)
    WithTimeout(operation string, timeout time.Duration, fn func() error) error
}
Key Notation
<Enter>     - Enter key
<Tab>       - Tab key
<Esc>       - Escape
<Space>     - Space bar
<Backspace> - Backspace

<Ctrl+A>    - Control combinations
<Alt+X>     - Alt combinations
<Shift+Tab> - Shift combinations

<Up>        - Arrow keys
<Down>
<Left>
<Right>

<F1>-<F12>  - Function keys
<PgUp>      - Page up
<PgDown>    - Page down
<Home>      - Home
<End>       - End

Testing Patterns

1. Smoke Test
term.Start(app)
term.Wait(1*time.Second)
assert.False(t, term.Health().Crashed)
2. Navigation Test
term.SendKeys("<Tab><Tab><Enter>")
assert.True(t, term.Contains("Expected Screen"))
3. Data Entry Test
term.SendKeys("[email protected]")
term.SendKeys("<Tab>")
term.SendKeys("password123")
term.SendKeys("<Enter>")
4. Responsive Test
for width := 20; width <= 200; width += 20 {
    term.Resize(width, 24)
    assert.True(t, term.VerifyLayout(tester.Responsive))
}
5. Hang Prevention Test
// Test apps that might hang
term.SetTimeouts(5*time.Second, 2*time.Second)
term.Start(problematicApp)

// Won't hang the test
err := term.SendKeys("input")
if err != nil {
    t.Logf("Operation failed safely: %v", err)
}

assert.False(t, term.IsHanging())
6. Emergency Recovery Test
term.Start(hangingApp)
time.Sleep(1*time.Second)

if term.IsHanging() {
    term.ForceStop("Test cleanup")
    time.Sleep(500*time.Millisecond)
    assert.False(t, term.IsRunning())
}

CI/CD Integration

GitHub Actions
name: TUI Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    
    - uses: actions/setup-go@v4
      with:
        go-version: '1.21'
    
    - name: Install dependencies
      run: go mod download
    
    - name: Run TUI tests
      run: go test -v ./...
    
    - name: Upload screenshots
      if: failure()
      uses: actions/upload-artifact@v3
      with:
        name: screenshots
        path: test_reports/

Troubleshooting

"PTY not available"
  • Run in a real terminal or use script command
  • In Docker, use -t flag: docker run -t
"Colors not detected"
  • Ensure TERM environment variable is set
  • Try TERM=xterm-256color
"Hanging tests"
  • Increase timeouts for slow systems
  • Check if app requires specific environment

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

License

MIT License - see LICENSE file for details.

Credits

Created by AKAO.IO for testing terminal applications with confidence.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	SizeWatch   = Size{25, 10}  // Smartwatch
	SizeMobile  = Size{50, 20}  // Mobile phone
	SizeTablet  = Size{80, 30}  // Tablet
	SizeDesktop = Size{120, 40} // Desktop
	SizeWide    = Size{200, 50} // Wide desktop
)

Common terminal sizes for testing

View Source
var KeyMap = map[string]string{

	"<Ctrl+A>": "\x01",
	"<Ctrl+B>": "\x02",
	"<Ctrl+C>": "\x03",
	"<Ctrl+D>": "\x04",
	"<Ctrl+E>": "\x05",
	"<Ctrl+F>": "\x06",
	"<Ctrl+G>": "\x07",
	"<Ctrl+H>": "\x08",
	"<Ctrl+I>": "\x09",
	"<Ctrl+J>": "\x0A",
	"<Ctrl+K>": "\x0B",
	"<Ctrl+L>": "\x0C",
	"<Ctrl+M>": "\x0D",
	"<Ctrl+N>": "\x0E",
	"<Ctrl+O>": "\x0F",
	"<Ctrl+P>": "\x10",
	"<Ctrl+Q>": "\x11",
	"<Ctrl+R>": "\x12",
	"<Ctrl+S>": "\x13",
	"<Ctrl+T>": "\x14",
	"<Ctrl+U>": "\x15",
	"<Ctrl+V>": "\x16",
	"<Ctrl+W>": "\x17",
	"<Ctrl+X>": "\x18",
	"<Ctrl+Y>": "\x19",
	"<Ctrl+Z>": "\x1A",

	"<Enter>":     "\r",
	"<Return>":    "\r",
	"<Tab>":       "\t",
	"<Backspace>": "\x7F",
	"<Delete>":    "\x1B[3~",
	"<Esc>":       "\x1B",
	"<Escape>":    "\x1B",
	"<Space>":     " ",

	"<Up>":    "\x1B[A",
	"<Down>":  "\x1B[B",
	"<Right>": "\x1B[C",
	"<Left>":  "\x1B[D",

	"<Home>":     "\x1B[H",
	"<End>":      "\x1B[F",
	"<PgUp>":     "\x1B[5~",
	"<PgDown>":   "\x1B[6~",
	"<PageUp>":   "\x1B[5~",
	"<PageDown>": "\x1B[6~",

	"<F1>":  "\x1BOP",
	"<F2>":  "\x1BOQ",
	"<F3>":  "\x1BOR",
	"<F4>":  "\x1BOS",
	"<F5>":  "\x1B[15~",
	"<F6>":  "\x1B[17~",
	"<F7>":  "\x1B[18~",
	"<F8>":  "\x1B[19~",
	"<F9>":  "\x1B[20~",
	"<F10>": "\x1B[21~",
	"<F11>": "\x1B[23~",
	"<F12>": "\x1B[24~",

	"<Alt+A>":     "\x1Ba",
	"<Alt+B>":     "\x1Bb",
	"<Alt+C>":     "\x1Bc",
	"<Alt+D>":     "\x1Bd",
	"<Alt+E>":     "\x1Be",
	"<Alt+F>":     "\x1Bf",
	"<Alt+Enter>": "\x1B\r",
	"<Alt+Tab>":   "\x1B\t",

	"<Shift+Tab>":   "\x1B[Z",
	"<Shift+Up>":    "\x1B[1;2A",
	"<Shift+Down>":  "\x1B[1;2B",
	"<Shift+Right>": "\x1B[1;2C",
	"<Shift+Left>":  "\x1B[1;2D",
}

KeyMap defines special key mappings

Functions ΒΆ

func ParseKeys ΒΆ

func ParseKeys(keys string) string

ParseKeys converts key notation to actual bytes

func StripANSI ΒΆ

func StripANSI(text string) string

StripANSI removes ANSI escape sequences from text

func TestEveryAssertionType ΒΆ added in v1.1.0

func TestEveryAssertionType(t *testing.T)

TestEveryAssertionType - Test tα»«ng loαΊ‘i assertion mα»™t cΓ‘ch chi tiαΊΏt

Types ΒΆ

type ANSIBuilder ΒΆ

type ANSIBuilder struct {
	// contains filtered or unexported fields
}

ANSIBuilder helps build ANSI sequences for testing

func NewANSIBuilder ΒΆ

func NewANSIBuilder() *ANSIBuilder

NewANSIBuilder creates a new ANSI builder

func (*ANSIBuilder) BgColor ΒΆ

func (a *ANSIBuilder) BgColor(color string) *ANSIBuilder

BgColor adds background color

func (*ANSIBuilder) Bold ΒΆ

func (a *ANSIBuilder) Bold() *ANSIBuilder

Bold adds bold style

func (*ANSIBuilder) Color ΒΆ

func (a *ANSIBuilder) Color(color string) *ANSIBuilder

Color adds foreground color

func (*ANSIBuilder) Reset ΒΆ

func (a *ANSIBuilder) Reset() *ANSIBuilder

Reset adds reset sequence

func (*ANSIBuilder) String ΒΆ

func (a *ANSIBuilder) String() string

String returns the built string

func (*ANSIBuilder) Text ΒΆ

func (a *ANSIBuilder) Text(text string) *ANSIBuilder

Text adds text

type ANSISequence ΒΆ

type ANSISequence struct {
	Type     string // color, cursor, clear, etc.
	Code     string
	Params   string
	Position int
}

ANSISequence represents an ANSI escape sequence

type ActiveFailure ΒΆ added in v1.1.0

type ActiveFailure struct{}

type AdvancedAssertionEngine ΒΆ added in v1.1.0

type AdvancedAssertionEngine struct {
	// contains filtered or unexported fields
}

AdvancedAssertionEngine provides comprehensive assertion capabilities for complex applications

func NewAdvancedAssertionEngine ΒΆ added in v1.1.0

func NewAdvancedAssertionEngine() *AdvancedAssertionEngine

NewAdvancedAssertionEngine creates an enhanced assertion engine

type AllocatedResources ΒΆ added in v1.1.0

type AllocatedResources struct{}

type Allocation ΒΆ added in v1.1.0

type Allocation struct {
	Timestamp time.Time
	Size      uint64
	Location  string
	Type      string
	Released  bool
}

Allocation represents a memory allocation

type AllocationPattern ΒΆ added in v1.1.0

type AllocationPattern struct {
	Pattern     string
	Frequency   int
	AvgSize     uint64
	Problematic bool
}

AllocationPattern represents allocation patterns

type AllocationTracker ΒΆ added in v1.1.0

type AllocationTracker struct {
	// contains filtered or unexported fields
}

AllocationTracker tracks memory allocation patterns

type Anomaly ΒΆ added in v1.1.0

type Anomaly struct {
	Type        string
	Severity    string
	Description string
	Timestamp   time.Time
	Context     map[string]interface{}
}

Anomaly represents detected unusual behavior

type ApplicationState ΒΆ added in v1.1.0

type ApplicationState struct {
	ProcessTree     ProcessInfo
	MemoryLayout    MemoryInfo
	FileDescriptors []FDInfo
	Configuration   map[string]interface{}
	InternalState   map[string]interface{}
}

ApplicationState represents deep application state for validation

type Assertion ΒΆ

type Assertion struct {
	Type     AssertionType
	Expected string
	Message  string
}

Assertion represents a test assertion

type AssertionFunc ΒΆ added in v1.1.0

type AssertionFunc func(actual, expected interface{}, context *TestContext) error

AssertionFunc represents a custom assertion function

type AssertionTestCases ΒΆ added in v1.1.0

type AssertionTestCases struct {
	// contains filtered or unexported fields
}

AssertionTestCases - Tập hợp test cases chi tiết cho từng assertion

func NewAssertionTestCases ΒΆ added in v1.1.0

func NewAssertionTestCases() *AssertionTestCases

type AssertionType ΒΆ

type AssertionType string

AssertionType represents types of assertions

const (
	AssertContains    AssertionType = "contains"
	AssertNotContains AssertionType = "not_contains"
	AssertNoCrash     AssertionType = "no_crash"
	AssertNoHang      AssertionType = "no_hang"
	AssertLayout      AssertionType = "layout"
	AssertColor       AssertionType = "color"
	AssertResponse    AssertionType = "response"
)

type BackoffStrategy ΒΆ added in v1.1.0

type BackoffStrategy int

type ColorInfo ΒΆ

type ColorInfo struct {
	Text       string
	Foreground string
	Background string
	Style      string
}

ColorInfo contains color information for text

func ExtractColors ΒΆ

func ExtractColors(text string) []ColorInfo

ExtractColors extracts visible colors from ANSI text

type ColorReport ΒΆ

type ColorReport struct {
	HasColors      bool
	Has256Colors   bool
	HasTrueColor   bool
	HasStyles      bool
	TotalSequences int
	ColorMap       map[string]int
	SequenceTypes  map[string]int
}

ColorReport contains color usage information

type ColorTracker ΒΆ

type ColorTracker struct {
	// contains filtered or unexported fields
}

ColorTracker tracks ANSI color usage

func NewColorTracker ΒΆ

func NewColorTracker() *ColorTracker

NewColorTracker creates a new color tracker

func (*ColorTracker) GetReport ΒΆ

func (c *ColorTracker) GetReport() ColorReport

GetReport returns color usage report

func (*ColorTracker) Process ΒΆ

func (c *ColorTracker) Process(data []byte)

Process processes data and extracts ANSI sequences

type ComprehensiveTestReport ΒΆ added in v1.1.0

type ComprehensiveTestReport struct {
	Summary         *ExecutionSummary
	Suites          map[string]*SuiteReport
	Performance     *PerformanceReport
	Coverage        *CoverageReport
	Failures        *FailureReport
	Recommendations []Recommendation
}

type ConfigChange ΒΆ added in v1.1.0

type ConfigChange struct {
	Timestamp time.Time
	FilePath  string
	Key       string
	OldValue  interface{}
	NewValue  interface{}
	Source    string
}

ConfigChange represents a configuration change

type ConfigSnapshot ΒΆ added in v1.1.0

type ConfigSnapshot struct {
	Timestamp time.Time
	FilePath  string
	Content   map[string]interface{}
	Checksum  string
}

ConfigSnapshot represents configuration state at a point in time

type ConfigTracker ΒΆ added in v1.1.0

type ConfigTracker struct {
	// contains filtered or unexported fields
}

ConfigTracker monitors configuration changes

func NewConfigTracker ΒΆ added in v1.1.0

func NewConfigTracker() *ConfigTracker

func (*ConfigTracker) Start ΒΆ added in v1.1.0

func (ct *ConfigTracker) Start() error

func (*ConfigTracker) Stop ΒΆ added in v1.1.0

func (ct *ConfigTracker) Stop() error

type ConfigValidationRule ΒΆ added in v1.1.0

type ConfigValidationRule struct {
	Key           string
	Required      bool
	Type          string
	AllowedValues []interface{}
	Validator     func(interface{}) error
}

ConfigValidationRule defines configuration validation

type CoverageReport ΒΆ added in v1.1.0

type CoverageReport struct{}

type CrashScenario ΒΆ

type CrashScenario string

CrashScenario represents a crash test scenario

const (
	// CrashRapidInput sends rapid keyboard input
	CrashRapidInput CrashScenario = "rapid_input"
	// CrashInvalidEscape sends malformed ANSI sequences
	CrashInvalidEscape CrashScenario = "invalid_escape"
	// CrashBufferOverflow attempts buffer overflow
	CrashBufferOverflow CrashScenario = "buffer_overflow"
	// CrashRapidResize rapidly resizes terminal
	CrashRapidResize CrashScenario = "rapid_resize"
	// CrashNullBytes sends null bytes
	CrashNullBytes CrashScenario = "null_bytes"
	// CrashUnicodeStress sends complex unicode
	CrashUnicodeStress CrashScenario = "unicode_stress"
	// CrashMemoryExhaust attempts to exhaust memory
	CrashMemoryExhaust CrashScenario = "memory_exhaust"
)

type CrashType ΒΆ

type CrashType int

CrashType represents types of crashes

const (
	CrashNone CrashType = iota
	CrashSegfault
	CrashOOM
	CrashAbort
	CrashTimeout
	CrashUnknown
)

func GetCrashType ΒΆ

func GetCrashType(exitCode int) CrashType

GetCrashType determines crash type from exit code

func (CrashType) String ΒΆ

func (c CrashType) String() string

String returns crash type as string

type CriticalFailure ΒΆ added in v1.1.0

type CriticalFailure struct{}

type DataProvider ΒΆ added in v1.1.0

type DataProvider struct{}

type DebugCollector ΒΆ added in v1.1.0

type DebugCollector struct{}

type DependencyEdge ΒΆ added in v1.1.0

type DependencyEdge struct {
	From      string
	To        string
	Type      DependencyType
	Required  bool
	Condition func() bool
}

DependencyEdge represents a dependency relationship

type DependencyGraph ΒΆ added in v1.1.0

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph manages test suite dependencies

func NewDependencyGraph ΒΆ added in v1.1.0

func NewDependencyGraph() *DependencyGraph

Constructor stubs

func (*DependencyGraph) AddNode ΒΆ added in v1.1.0

func (dg *DependencyGraph) AddNode(suite TestSuite) error

Method stubs for dependency graph

func (*DependencyGraph) Resolve ΒΆ added in v1.1.0

func (dg *DependencyGraph) Resolve() error

type DependencyNode ΒΆ added in v1.1.0

type DependencyNode struct {
	ID       string
	Suite    *TestSuite
	Status   NodeStatus
	Priority int
}

DependencyNode represents a test suite in the dependency graph

type DependencyType ΒΆ added in v1.1.0

type DependencyType int

type EnhancedTestCase ΒΆ added in v1.1.0

type EnhancedTestCase struct {
	// Basic info
	TestCase

	// Advanced features
	Prerequisites []Prerequisite
	SetupFunc     func(*EnhancedTestContext) error
	ExecuteFunc   func(*EnhancedTestContext) error
	ValidateFunc  func(*EnhancedTestContext) error
	CleanupFunc   func(*EnhancedTestContext) error

	// Test data and parameterization
	TestData      []TestDataSet
	DataProviders []DataProvider

	// Expectations
	ExpectedResults   []ExpectedResult
	PerformanceLimits PerformanceLimits

	// Error handling
	ExpectedErrors []ExpectedError
	RecoverySteps  []RecoveryStep

	// Integration points
	StateChecks      []StateCheck
	SideEffectChecks []SideEffectCheck
}

EnhancedTestCase extends basic test case with advanced features

type EnhancedTestContext ΒΆ added in v1.1.0

type EnhancedTestContext struct {
	// Basic context
	TestContext

	// Enhanced features
	StateInspector  *StateInspector
	DataProviders   map[string]DataProvider
	SharedResources *SharedResourcePool
	TestData        map[string]interface{}

	// Execution state
	ExecutionPhase ExecutionPhase
	RetryAttempt   int
	LastError      error

	// Monitoring and debugging
	PerformanceCollector *PerformanceCollector
	DebugCollector       *DebugCollector
	TraceCollector       *TraceCollector
}

EnhancedTestContext provides rich context for test execution

type EscalationRule ΒΆ added in v1.1.0

type EscalationRule struct{}

type EscapeKey ΒΆ

type EscapeKey string

EscapeKey represents a keyboard key that can be sent

const (
	// Control keys
	CtrlA EscapeKey = "\x01"
	CtrlB EscapeKey = "\x02"
	CtrlC EscapeKey = "\x03"
	CtrlD EscapeKey = "\x04"
	CtrlE EscapeKey = "\x05"
	CtrlF EscapeKey = "\x06"
	CtrlG EscapeKey = "\x07"
	CtrlH EscapeKey = "\x08"
	CtrlI EscapeKey = "\x09"
	CtrlJ EscapeKey = "\x0A"
	CtrlK EscapeKey = "\x0B"
	CtrlL EscapeKey = "\x0C"
	CtrlM EscapeKey = "\x0D"
	CtrlN EscapeKey = "\x0E"
	CtrlO EscapeKey = "\x0F"
	CtrlP EscapeKey = "\x10"
	CtrlQ EscapeKey = "\x11"
	CtrlR EscapeKey = "\x12"
	CtrlS EscapeKey = "\x13"
	CtrlT EscapeKey = "\x14"
	CtrlU EscapeKey = "\x15"
	CtrlV EscapeKey = "\x16"
	CtrlW EscapeKey = "\x17"
	CtrlX EscapeKey = "\x18"
	CtrlY EscapeKey = "\x19"
	CtrlZ EscapeKey = "\x1A"

	// Special keys
	Enter     EscapeKey = "\r"
	Tab       EscapeKey = "\t"
	Backspace EscapeKey = "\x7F"
	Delete    EscapeKey = "\x1B[3~"
	Escape    EscapeKey = "\x1B"
	Space     EscapeKey = " "

	// Arrow keys
	ArrowUp    EscapeKey = "\x1B[A"
	ArrowDown  EscapeKey = "\x1B[B"
	ArrowRight EscapeKey = "\x1B[C"
	ArrowLeft  EscapeKey = "\x1B[D"

	// Navigation
	Home     EscapeKey = "\x1B[H"
	End      EscapeKey = "\x1B[F"
	PageUp   EscapeKey = "\x1B[5~"
	PageDown EscapeKey = "\x1B[6~"
)

func (EscapeKey) String ΒΆ

func (k EscapeKey) String() string

String returns the escape sequence as string

type ExecutionCoordinator ΒΆ added in v1.1.0

type ExecutionCoordinator struct{}

type ExecutionJob ΒΆ added in v1.1.0

type ExecutionJob struct{}

type ExecutionPhase ΒΆ added in v1.1.0

type ExecutionPhase struct {
	ID             string
	Name           string
	Description    string
	TestSuites     []string
	ParallelGroups []ParallelGroup
	Dependencies   []string
	EstimatedTime  time.Duration
	CriticalPath   bool
}

ExecutionPhase represents a phase of test execution

type ExecutionPlan ΒΆ added in v1.1.0

type ExecutionPlan struct {
	Phases          []ExecutionPhase
	TotalEstimation time.Duration
	ResourcePlan    *ResourceAllocationPlan
	RiskAssessment  *RiskAssessment
}

ExecutionPlan defines the order and method of test execution

type ExecutionResult ΒΆ added in v1.1.0

type ExecutionResult struct{}

type ExecutionResults ΒΆ added in v1.1.0

type ExecutionResults struct {
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration
	Phases    map[string]*PhaseResults
}

Result types

type ExecutionSummary ΒΆ added in v1.1.0

type ExecutionSummary struct{}

type ExpectedError ΒΆ added in v1.1.0

type ExpectedError struct{}

type ExpectedResult ΒΆ added in v1.1.0

type ExpectedResult struct{}

type FDInfo ΒΆ added in v1.1.0

type FDInfo struct {
	FD   int
	Type string
	Path string
}

FDInfo contains file descriptor information

type FailureEvent ΒΆ added in v1.1.0

type FailureEvent struct{}

type FailureHandler ΒΆ added in v1.1.0

type FailureHandler struct {
	// contains filtered or unexported fields
}

FailureHandler manages test failure scenarios

func NewFailureHandler ΒΆ added in v1.1.0

func NewFailureHandler() *FailureHandler

type FailureInfo ΒΆ added in v1.1.0

type FailureInfo struct{}

type FailureReport ΒΆ added in v1.1.0

type FailureReport struct{}

type FailureType ΒΆ added in v1.1.0

type FailureType int

type FileOperation ΒΆ added in v1.1.0

type FileOperation struct {
	Timestamp time.Time
	Operation string // "open", "close", "read", "write", "delete"
	Path      string
	Size      int64
	Success   bool
	Error     string
}

FileOperation represents a file system operation

type FileSystemLimits ΒΆ added in v1.1.0

type FileSystemLimits struct {
	MaxOpenFiles   int
	MaxFileSize    int64
	MaxTotalWrites int64
	MaxTotalReads  int64
}

FileSystemLimits defines file system usage limits

type FileSystemWatcher ΒΆ added in v1.1.0

type FileSystemWatcher struct {
	// contains filtered or unexported fields
}

FileSystemWatcher monitors file system operations

func NewFileSystemWatcher ΒΆ added in v1.1.0

func NewFileSystemWatcher() *FileSystemWatcher

func (*FileSystemWatcher) Start ΒΆ added in v1.1.0

func (fsw *FileSystemWatcher) Start() error

func (*FileSystemWatcher) Stop ΒΆ added in v1.1.0

func (fsw *FileSystemWatcher) Stop() error

type Frame ΒΆ

type Frame struct {
	Timestamp time.Time
	Content   string
	ASCII     string
	Width     int
	Height    int
	CursorX   int
	CursorY   int
}

Frame represents a single frame of terminal output

type GlobalTestState ΒΆ added in v1.1.0

type GlobalTestState struct {
	TotalTests     int
	CompletedTests int
	PassedTests    int
	FailedTests    int
	SkippedTests   int

	StartTime        time.Time
	EstimatedEndTime time.Time

	SharedResources map[string]interface{}
	GlobalVariables map[string]interface{}

	CriticalFailures []CriticalFailure
}

GlobalTestState represents the overall test execution state

type HealthReport ΒΆ

type HealthReport struct {
	Uptime          time.Duration
	Crashed         bool
	CrashReason     string
	ExitCode        int
	IsHanging       bool
	HangDuration    time.Duration
	LastActivity    time.Time
	AvgResponseTime time.Duration
}

HealthReport contains health status

type HealthTracker ΒΆ

type HealthTracker struct {
	// contains filtered or unexported fields
}

HealthTracker monitors application health

func NewHealthTracker ΒΆ

func NewHealthTracker() *HealthTracker

NewHealthTracker creates a new health tracker

func (*HealthTracker) CheckHang ΒΆ

func (h *HealthTracker) CheckHang() bool

CheckHang checks if application is hanging

func (*HealthTracker) GetReport ΒΆ

func (h *HealthTracker) GetReport() HealthReport

GetReport returns health report

func (*HealthTracker) RecordCrash ΒΆ

func (h *HealthTracker) RecordCrash(reason string, code int)

RecordCrash records a crash

func (*HealthTracker) RecordResponseTime ΒΆ

func (h *HealthTracker) RecordResponseTime(duration time.Duration)

RecordResponseTime records command response time

func (*HealthTracker) UpdateActivity ΒΆ

func (h *HealthTracker) UpdateActivity()

UpdateActivity updates last activity time

type IsolationLevel ΒΆ added in v1.1.0

type IsolationLevel int

Type definitions for completeness

type LayoutType ΒΆ

type LayoutType int

LayoutType represents types of layout verification

const (
	// Centered checks if content is centered
	Centered LayoutType = iota
	// HasBorder checks for border characters
	HasBorder
	// Responsive checks if layout adapts to size
	Responsive
	// HorizontalSplit checks for horizontal split
	HorizontalSplit
	// VerticalSplit checks for vertical split
	VerticalSplit
)

type LeakDetector ΒΆ added in v1.1.0

type LeakDetector struct {
	// contains filtered or unexported fields
}

LeakDetector identifies memory leaks

type LeakThresholds ΒΆ added in v1.1.0

type LeakThresholds struct {
	MaxGrowthRate        float64 // MB per second
	MaxGrowthDuration    time.Duration
	MinLeakSize          uint64 // bytes
	ConsecutiveIncreases int
}

LeakThresholds defines leak detection thresholds

type MemoryAnalyzer ΒΆ added in v1.1.0

type MemoryAnalyzer struct {
	// contains filtered or unexported fields
}

MemoryAnalyzer provides deep memory analysis

func NewMemoryAnalyzer ΒΆ added in v1.1.0

func NewMemoryAnalyzer() *MemoryAnalyzer

func (*MemoryAnalyzer) DetectedLeaks ΒΆ added in v1.1.0

func (ma *MemoryAnalyzer) DetectedLeaks() int

func (*MemoryAnalyzer) GetLatestSnapshot ΒΆ added in v1.1.0

func (ma *MemoryAnalyzer) GetLatestSnapshot() MemorySnapshot

func (*MemoryAnalyzer) LeakBytes ΒΆ added in v1.1.0

func (ma *MemoryAnalyzer) LeakBytes() uint64

func (*MemoryAnalyzer) Start ΒΆ added in v1.1.0

func (ma *MemoryAnalyzer) Start() error

func (*MemoryAnalyzer) Stop ΒΆ added in v1.1.0

func (ma *MemoryAnalyzer) Stop() error

type MemoryInfo ΒΆ added in v1.1.0

type MemoryInfo struct {
	HeapSize      uint64
	StackSize     uint64
	Allocations   uint64
	Deallocations uint64
	LeakCount     int
	LeakBytes     uint64
}

MemoryInfo contains memory layout information

type MemoryLeak ΒΆ

type MemoryLeak struct {
	Type        string
	GrowthRate  float64
	StartMemory uint64
	EndMemory   uint64
}

MemoryLeak represents a potential memory leak

type MemorySnapshot ΒΆ added in v1.1.0

type MemorySnapshot struct {
	Timestamp     time.Time
	HeapSize      uint64
	HeapUsed      uint64
	StackSize     uint64
	Allocations   uint64
	Deallocations uint64
	GCCycles      uint64
	LiveObjects   map[string]int
}

MemorySnapshot captures memory state at a point in time

type Metrics ΒΆ

type Metrics struct {
	PID        int
	Running    bool
	AvgMemory  uint64
	PeakMemory uint64
	AvgCPU     float64
}

Metrics contains process metrics

type Monitor ΒΆ

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor tracks process metrics

func NewMonitor ΒΆ

func NewMonitor() *Monitor

NewMonitor creates a new process monitor

func (*Monitor) CheckMemoryLeak ΒΆ

func (m *Monitor) CheckMemoryLeak() []MemoryLeak

CheckMemoryLeak checks for potential memory leaks

func (*Monitor) GetMetrics ΒΆ

func (m *Monitor) GetMetrics() Metrics

GetMetrics returns current metrics

func (*Monitor) Start ΒΆ

func (m *Monitor) Start(pid int)

Start begins monitoring a process

func (*Monitor) Stop ΒΆ

func (m *Monitor) Stop()

Stop stops monitoring

type NetworkConnection ΒΆ added in v1.1.0

type NetworkConnection struct {
	LocalAddr  string
	RemoteAddr string
	State      string
	Protocol   string
	BytesSent  uint64
	BytesRecv  uint64
}

NetworkConnection represents a network connection

type NetworkLimits ΒΆ added in v1.1.0

type NetworkLimits struct {
	MaxConnections   int
	MaxBytesPerSec   uint64
	MaxTotalTraffic  uint64
	AllowedProtocols []string
}

NetworkLimits defines network usage limits

type NetworkMonitor ΒΆ added in v1.1.0

type NetworkMonitor struct {
	// contains filtered or unexported fields
}

NetworkMonitor tracks network operations

func NewNetworkMonitor ΒΆ added in v1.1.0

func NewNetworkMonitor() *NetworkMonitor

func (*NetworkMonitor) Start ΒΆ added in v1.1.0

func (nm *NetworkMonitor) Start() error

func (*NetworkMonitor) Stop ΒΆ added in v1.1.0

func (nm *NetworkMonitor) Stop() error

type NetworkTraffic ΒΆ added in v1.1.0

type NetworkTraffic struct {
	Timestamp   time.Time
	BytesSent   uint64
	BytesRecv   uint64
	Connections int
}

NetworkTraffic represents network traffic metrics

type NodeStatus ΒΆ added in v1.1.0

type NodeStatus int

type ParallelExecutor ΒΆ added in v1.1.0

type ParallelExecutor struct {
	// contains filtered or unexported fields
}

ParallelExecutor manages parallel test execution

func NewParallelExecutor ΒΆ added in v1.1.0

func NewParallelExecutor() *ParallelExecutor

type ParallelGroup ΒΆ added in v1.1.0

type ParallelGroup struct {
	ID              string
	TestSuites      []string
	MaxConcurrency  int
	SharedResources []string
}

ParallelGroup defines tests that can run in parallel

type PerformanceCollector ΒΆ added in v1.1.0

type PerformanceCollector struct{}

type PerformanceLimits ΒΆ added in v1.1.0

type PerformanceLimits struct{}

type PerformanceMetrics ΒΆ

type PerformanceMetrics struct {
	AvgResponseTime time.Duration
	MaxResponseTime time.Duration
	MinResponseTime time.Duration
	AvgCPU          float64
	MaxCPU          float64
	AvgMemory       uint64
	MaxMemory       uint64
	ThroughputOps   int
}

PerformanceMetrics contains performance measurements

type PerformanceReport ΒΆ added in v1.1.0

type PerformanceReport struct{}

type PhaseResults ΒΆ added in v1.1.0

type PhaseResults struct {
	PhaseID   string
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration
	Suites    map[string]*SuiteResults
}

type Prerequisite ΒΆ added in v1.1.0

type Prerequisite struct{}

type ProcessInfo ΒΆ added in v1.1.0

type ProcessInfo struct {
	PID         int
	Children    []ProcessInfo
	MemoryUsage uint64
	CPUUsage    float64
	OpenFiles   int
	ThreadCount int
	Status      string
}

ProcessInfo contains process tree information

type ProcessMetric ΒΆ added in v1.1.0

type ProcessMetric struct {
	Timestamp   time.Time
	PID         int
	CPU         float64
	Memory      uint64
	FileHandles int
	Threads     int
	Status      string
}

ProcessMetric represents a point-in-time process metric

type ProcessMonitor ΒΆ added in v1.1.0

type ProcessMonitor struct {
	// contains filtered or unexported fields
}

ProcessMonitor tracks process tree and resource usage

func NewProcessMonitor ΒΆ added in v1.1.0

func NewProcessMonitor(pid int) *ProcessMonitor

Implementation stubs for component constructors

func (*ProcessMonitor) GetLatestMetrics ΒΆ added in v1.1.0

func (pm *ProcessMonitor) GetLatestMetrics() ProcessMetric

func (*ProcessMonitor) Start ΒΆ added in v1.1.0

func (pm *ProcessMonitor) Start() error

Method stubs for component operations

func (*ProcessMonitor) Stop ΒΆ added in v1.1.0

func (pm *ProcessMonitor) Stop() error

type ProgressTracker ΒΆ added in v1.1.0

type ProgressTracker struct{}

func NewProgressTracker ΒΆ added in v1.1.0

func NewProgressTracker() *ProgressTracker

func (*ProgressTracker) UpdatePhaseProgress ΒΆ added in v1.1.0

func (pt *ProgressTracker) UpdatePhaseProgress(phaseID string, percent int)

Method stubs for progress tracker

type Recommendation ΒΆ added in v1.1.0

type Recommendation struct{}

type RecoveryStep ΒΆ added in v1.1.0

type RecoveryStep struct{}

type RecoveryStrategy ΒΆ added in v1.1.0

type RecoveryStrategy struct {
	Name              string
	Description       string
	TriggerConditions []TriggerCondition
	RecoverySteps     []RecoveryStep

	MaxRecoveryTime time.Duration
	SuccessCriteria []SuccessCriterion
}

RecoveryStrategy defines how to recover from failures

type ReportGenerator ΒΆ added in v1.1.0

type ReportGenerator struct{}

func NewReportGenerator ΒΆ added in v1.1.0

func NewReportGenerator() *ReportGenerator

func (*ReportGenerator) GenerateReport ΒΆ added in v1.1.0

func (rg *ReportGenerator) GenerateReport(results *ExecutionResults, state *GlobalTestState) (*ComprehensiveTestReport, error)

Method stubs for report generator

type ResourceAllocation ΒΆ added in v1.1.0

type ResourceAllocation struct {
	MemoryMB    int
	CPUPercent  float64
	NetworkMBps int
	DiskSpaceMB int
	Priority    int
}

ResourceAllocation defines resource allocation for a test suite

type ResourceAllocationPlan ΒΆ added in v1.1.0

type ResourceAllocationPlan struct {
	TotalMemoryMB    int
	TotalCPUCores    int
	NetworkBandwidth int
	DiskSpaceGB      int

	PerSuiteAllocation map[string]ResourceAllocation
}

ResourceAllocationPlan manages test resource allocation

type ResourceLimits ΒΆ added in v1.1.0

type ResourceLimits struct {
	MaxMemoryMB    uint64
	MaxCPUPercent  float64
	MaxFileHandles int
	MaxThreads     int
}

ResourceLimits defines resource usage limits

type ResourceManager ΒΆ added in v1.1.0

type ResourceManager struct{}

type ResourceRequirements ΒΆ added in v1.1.0

type ResourceRequirements struct{}

type ResourceUsage ΒΆ added in v1.1.0

type ResourceUsage struct{}

type RetryCondition ΒΆ added in v1.1.0

type RetryCondition struct{}

type RetryPolicy ΒΆ added in v1.1.0

type RetryPolicy struct {
	MaxAttempts     int
	RetryInterval   time.Duration
	BackoffStrategy BackoffStrategy
	RetryConditions []RetryCondition

	MaxTotalTime    time.Duration
	RetryOnFailures []FailureType
}

RetryPolicy defines how to handle test retries

func DefaultRetryPolicy ΒΆ added in v1.1.0

func DefaultRetryPolicy() *RetryPolicy

type RiskAssessment ΒΆ added in v1.1.0

type RiskAssessment struct{}

type RollbackOperation ΒΆ added in v1.1.0

type RollbackOperation struct{}

type SetupStep ΒΆ added in v1.1.0

type SetupStep struct{}

type SharedResourcePool ΒΆ added in v1.1.0

type SharedResourcePool struct{}

type SideEffectCheck ΒΆ added in v1.1.0

type SideEffectCheck struct{}

type Size ΒΆ

type Size struct {
	Width  int
	Height int
}

Size represents terminal dimensions

type StateCheck ΒΆ added in v1.1.0

type StateCheck struct{}

type StateCheckpoint ΒΆ added in v1.1.0

type StateCheckpoint struct{}

type StateInspector ΒΆ added in v1.1.0

type StateInspector struct {
	// contains filtered or unexported fields
}

StateInspector provides deep application state inspection capabilities

func NewStateInspector ΒΆ added in v1.1.0

func NewStateInspector(pid int) *StateInspector

NewStateInspector creates a comprehensive state inspector

func (*StateInspector) DetectAnomalies ΒΆ added in v1.1.0

func (si *StateInspector) DetectAnomalies() []Anomaly

DetectAnomalies identifies unusual behavior patterns

func (*StateInspector) GetApplicationState ΒΆ added in v1.1.0

func (si *StateInspector) GetApplicationState() ApplicationState

GetApplicationState returns comprehensive application state

func (*StateInspector) StartInspection ΒΆ added in v1.1.0

func (si *StateInspector) StartInspection() error

StartInspection begins comprehensive state monitoring

func (*StateInspector) StopInspection ΒΆ added in v1.1.0

func (si *StateInspector) StopInspection() error

StopInspection stops all monitoring

func (*StateInspector) ValidateState ΒΆ added in v1.1.0

func (si *StateInspector) ValidateState(validators map[string]StateValidator) error

ValidateState performs comprehensive state validation

type StateValidator ΒΆ added in v1.1.0

type StateValidator func(appState ApplicationState) error

StateValidator validates complex application state

type Step ΒΆ

type Step struct {
	Action      StepAction
	Input       string
	Duration    time.Duration
	Size        *Size
	Screenshot  bool
	Description string
}

Step represents a test step

type StepAction ΒΆ

type StepAction string

StepAction represents types of test actions

const (
	ActionKeys       StepAction = "keys"
	ActionWait       StepAction = "wait"
	ActionResize     StepAction = "resize"
	ActionScreenshot StepAction = "screenshot"
	ActionVerify     StepAction = "verify"
)

type StressTestConfig ΒΆ

type StressTestConfig struct {
	Duration      time.Duration
	InputRate     int // inputs per second
	ResizeRate    int // resizes per second
	PaneCount     int
	MaxMemoryMB   int
	MaxCPUPercent float64
	EnableCrash   bool
	EnableLeak    bool
	EnableHang    bool
}

StressTestConfig configures stress testing

type SuccessCriterion ΒΆ added in v1.1.0

type SuccessCriterion struct{}

type SuitePerformance ΒΆ added in v1.1.0

type SuitePerformance struct{}

type SuiteReport ΒΆ added in v1.1.0

type SuiteReport struct{}

type SuiteResults ΒΆ added in v1.1.0

type SuiteResults struct {
	SuiteID   string
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration
	Tests     map[string]*TestResults
}

type SuiteState ΒΆ added in v1.1.0

type SuiteState struct {
	SuiteID   string
	Status    SuiteStatus
	StartTime time.Time
	EndTime   time.Time

	CompletedTests []string
	FailedTests    []FailureInfo
	Performance    *SuitePerformance
	ResourceUsage  *ResourceUsage
}

SuiteState represents the state of a test suite

type SuiteStatus ΒΆ added in v1.1.0

type SuiteStatus int

type TeardownStep ΒΆ added in v1.1.0

type TeardownStep struct{}

type Terminal ΒΆ

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal represents a virtual terminal for testing

func NewTerminal ΒΆ

func NewTerminal(width, height int) *Terminal

NewTerminal creates a new virtual terminal for testing

func (*Terminal) Close ΒΆ

func (t *Terminal) Close() error

Close stops the terminal and cleans up

func (*Terminal) ConfigureWatchdog ΒΆ added in v1.0.2

func (t *Terminal) ConfigureWatchdog(config WatchdogConfig)

ConfigureWatchdog updates watchdog configuration

func (*Terminal) Contains ΒΆ

func (t *Terminal) Contains(text string) bool

Contains checks if screen contains text

func (*Terminal) ForceStop ΒΆ added in v1.0.2

func (t *Terminal) ForceStop(reason string)

ForceStop triggers emergency stop of the terminal

func (*Terminal) GetScreen ΒΆ

func (t *Terminal) GetScreen() string

GetScreen returns current screen content as string

func (*Terminal) GetWatchdogStats ΒΆ added in v1.0.2

func (t *Terminal) GetWatchdogStats() WatchdogStats

GetWatchdogStats returns watchdog statistics

func (*Terminal) Health ΒΆ

func (t *Terminal) Health() HealthReport

Health returns current health status

func (*Terminal) IsHanging ΒΆ added in v1.0.2

func (t *Terminal) IsHanging() bool

IsHanging checks if the terminal is currently hanging

func (*Terminal) IsRunning ΒΆ

func (t *Terminal) IsRunning() bool

IsRunning checks if the process is still running

func (*Terminal) NotContains ΒΆ

func (t *Terminal) NotContains(text string) bool

NotContains checks if screen does not contain text

func (*Terminal) Resize ΒΆ

func (t *Terminal) Resize(width, height int) error

Resize changes terminal dimensions

func (*Terminal) Screenshot ΒΆ

func (t *Terminal) Screenshot() string

Screenshot returns an ASCII art screenshot of current state

func (*Terminal) SendKeys ΒΆ

func (t *Terminal) SendKeys(keys string) error

SendKeys sends keyboard input to the terminal with hang protection

func (*Terminal) SendRaw ΒΆ

func (t *Terminal) SendRaw(data []byte) error

SendRaw sends raw bytes to the terminal with hang protection

func (*Terminal) SetLogFile ΒΆ

func (t *Terminal) SetLogFile(path string) error

SetLogFile sets the log file for debugging

func (*Terminal) SetTimeouts ΒΆ added in v1.0.2

func (t *Terminal) SetTimeouts(globalTimeout, operationTimeout time.Duration)

SetTimeouts configures terminal timeouts

func (*Terminal) Start ΒΆ

func (t *Terminal) Start(command string, args ...string) error

Start launches an application in the virtual terminal

func (*Terminal) StartRecording ΒΆ

func (t *Terminal) StartRecording()

StartRecording starts recording frames

func (*Terminal) StopRecording ΒΆ

func (t *Terminal) StopRecording() []Frame

StopRecording stops recording and returns frames

func (*Terminal) VerifyColors ΒΆ

func (t *Terminal) VerifyColors() ColorReport

VerifyColors returns color verification report

func (*Terminal) VerifyLayout ΒΆ

func (t *Terminal) VerifyLayout(layout LayoutType) bool

VerifyLayout checks layout properties

func (*Terminal) Wait ΒΆ

func (t *Terminal) Wait(duration time.Duration)

Wait waits for specified duration with watchdog protection

func (*Terminal) WithTimeout ΒΆ added in v1.0.2

func (t *Terminal) WithTimeout(operation string, timeout time.Duration, fn func() error) error

WithTimeout executes a function with timeout protection

type TestCase ΒΆ

type TestCase struct {
	Name        string
	Description string
	Size        Size
	Steps       []Step
	Assertions  []Assertion
	Timeout     time.Duration
}

TestCase represents a complete test scenario

type TestContext ΒΆ added in v1.1.1

type TestContext struct {
	TestName       string
	CurrentStep    int
	TotalSteps     int
	StartTime      time.Time
	TerminalSize   Size
	Screenshot     string
	PreviousOutput string
	Metadata       map[string]interface{}
}

TestContext provides context information during test execution

type TestDataSet ΒΆ added in v1.1.0

type TestDataSet struct{}

type TestOrchestrator ΒΆ added in v1.1.0

type TestOrchestrator struct {
	// contains filtered or unexported fields
}

TestOrchestrator manages complex test execution flows

func NewTestOrchestrator ΒΆ added in v1.1.0

func NewTestOrchestrator() *TestOrchestrator

NewTestOrchestrator creates a comprehensive test orchestrator

func (*TestOrchestrator) AddTestSuite ΒΆ added in v1.1.0

func (to *TestOrchestrator) AddTestSuite(suite TestSuite) error

AddTestSuite adds a test suite to the orchestrator

func (*TestOrchestrator) ExecuteAllTests ΒΆ added in v1.1.0

func (to *TestOrchestrator) ExecuteAllTests(ctx context.Context) (*ComprehensiveTestReport, error)

ExecuteAllTests executes all test suites according to dependencies and plan

type TestPerformanceMonitor ΒΆ added in v1.1.0

type TestPerformanceMonitor struct{}

func NewTestPerformanceMonitor ΒΆ added in v1.1.0

func NewTestPerformanceMonitor() *TestPerformanceMonitor

type TestResult ΒΆ

type TestResult struct {
	TestCase    TestCase
	Passed      bool
	Duration    time.Duration
	Errors      []string
	Screenshots []string
	Metrics     map[string]interface{}
	Health      HealthReport
	Colors      ColorReport
}

TestResult contains test execution results

type TestResults ΒΆ added in v1.1.0

type TestResults struct {
	TestID   string
	Passed   bool
	Duration time.Duration
	Error    error
	Metrics  map[string]interface{}
}

type TestStateManager ΒΆ added in v1.1.0

type TestStateManager struct {
	// contains filtered or unexported fields
}

TestStateManager manages test execution state

func NewTestStateManager ΒΆ added in v1.1.0

func NewTestStateManager() *TestStateManager

type TestSuite ΒΆ added in v1.1.0

type TestSuite struct {
	ID          string
	Name        string
	Description string
	Priority    int
	Tags        []string

	// Dependencies
	Prerequisites    []string
	SoftDependencies []string
	ConflictsWith    []string

	// Setup and teardown
	SetupSteps    []SetupStep
	TeardownSteps []TeardownStep

	// Test cases
	TestCases []EnhancedTestCase

	// Execution configuration
	ParallelSafe   bool
	IsolationLevel IsolationLevel
	RetryPolicy    *RetryPolicy
	Timeout        time.Duration

	// Resource requirements
	ResourceRequirements ResourceRequirements
}

TestSuite represents a comprehensive test suite with complex dependencies

type TestWorker ΒΆ added in v1.1.0

type TestWorker struct {
	ID          string
	Status      WorkerStatus
	CurrentTest *EnhancedTestCase
	Resources   *AllocatedResources
	Performance *WorkerPerformance
}

TestWorker executes individual tests

type TraceCollector ΒΆ added in v1.1.0

type TraceCollector struct{}

type TriggerCondition ΒΆ added in v1.1.0

type TriggerCondition struct{}

type VisualComparator ΒΆ added in v1.1.0

type VisualComparator struct {
	// contains filtered or unexported fields
}

VisualComparator provides advanced visual comparison

func NewVisualComparator ΒΆ added in v1.1.0

func NewVisualComparator() *VisualComparator

NewVisualComparator creates a visual comparison engine

type Watchdog ΒΆ added in v1.0.2

type Watchdog struct {
	// contains filtered or unexported fields
}

Watchdog provides comprehensive hang detection and prevention

func NewWatchdog ΒΆ added in v1.0.2

func NewWatchdog(terminal *Terminal) *Watchdog

NewWatchdog creates a new watchdog for terminal monitoring

func (*Watchdog) Configure ΒΆ added in v1.0.2

func (w *Watchdog) Configure(config WatchdogConfig)

Configure updates watchdog configuration

func (*Watchdog) Emergency ΒΆ added in v1.0.2

func (w *Watchdog) Emergency(reason string)

Emergency triggers immediate emergency stop

func (*Watchdog) EndOperation ΒΆ added in v1.0.2

func (w *Watchdog) EndOperation()

EndOperation notifies watchdog that an operation completed

func (*Watchdog) GetStats ΒΆ added in v1.0.2

func (w *Watchdog) GetStats() WatchdogStats

GetStats returns watchdog statistics

func (*Watchdog) SafeRead ΒΆ added in v1.0.2

func (w *Watchdog) SafeRead(buf []byte, timeout time.Duration) (int, error)

SafeRead provides safe read with timeout

func (*Watchdog) SafeWrite ΒΆ added in v1.0.2

func (w *Watchdog) SafeWrite(data []byte, timeout time.Duration) error

SafeWrite provides safe write with timeout

func (*Watchdog) Start ΒΆ added in v1.0.2

func (w *Watchdog) Start()

Start begins watchdog monitoring

func (*Watchdog) StartOperation ΒΆ added in v1.0.2

func (w *Watchdog) StartOperation(operation string)

StartOperation notifies watchdog that an operation is starting

func (*Watchdog) Stop ΒΆ added in v1.0.2

func (w *Watchdog) Stop()

Stop stops the watchdog

func (*Watchdog) UpdateActivity ΒΆ added in v1.0.2

func (w *Watchdog) UpdateActivity()

UpdateActivity updates the last activity timestamp

func (*Watchdog) WithTimeout ΒΆ added in v1.0.2

func (w *Watchdog) WithTimeout(operation string, timeout time.Duration, fn func() error) error

WithTimeout executes a function with timeout protection

type WatchdogConfig ΒΆ added in v1.0.2

type WatchdogConfig struct {
	MaxResponse      time.Duration
	CheckInterval    time.Duration
	ForceKillTimeout time.Duration
}

WatchdogConfig contains watchdog configuration

type WatchdogStats ΒΆ added in v1.0.2

type WatchdogStats struct {
	TimeoutCount   int
	ForceKillCount int
	HangCount      int
	EmergencyMode  bool
	CurrentOp      string
	LastActivity   time.Time
	IsHanging      bool
}

WatchdogStats contains watchdog statistics

type WorkerPerformance ΒΆ added in v1.1.0

type WorkerPerformance struct{}

type WorkerPool ΒΆ added in v1.1.0

type WorkerPool struct {
	// contains filtered or unexported fields
}

WorkerPool manages test execution workers

type WorkerStatus ΒΆ added in v1.1.0

type WorkerStatus int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL