MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / testCLIWithTmux

Function testCLIWithTmux

cli/src/__tests__/tmux-poc.ts:51–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50// Main test function
51async function testCLIWithTmux() {
52 const sessionName = 'codebuff-test-' + Date.now()
53
54 console.log('🚀 Starting tmux-based CLI test...')
55 console.log(`📦 Session: ${sessionName}`)
56
57 // 1. Check if tmux is installed
58 if (!isTmuxAvailable()) {
59 console.error('❌ tmux not found')
60 console.error('\n📦 Installation:')
61 console.error(' macOS: brew install tmux')
62 console.error(' Ubuntu: sudo apt-get install tmux')
63 console.error(' Windows: Use WSL and run sudo apt-get install tmux')
64 console.error(
65 '\nℹ️ This is just a proof-of-concept. See the documentation for alternatives.',
66 )
67 process.exit(1)
68 }
69
70 try {
71 const version = await tmux(['-V'])
72 console.log(`✅ tmux is installed: ${version.trim()}`)
73
74 // 2. Create new detached tmux session running the CLI
75 console.log('\n📺 Creating tmux session...')
76 await tmux([
77 'new-session',
78 '-d',
79 '-s',
80 sessionName,
81 '-x',
82 '120', // width
83 '-y',
84 '30', // height
85 'bun',
86 'run',
87 'src/index.tsx',
88 '--help',
89 ])
90 console.log('✅ Session created')
91
92 // 3. Wait for CLI to start
93 await sleep(1000)
94
95 // 4. Capture initial output
96 console.log('\n📸 Capturing initial output...')
97 const initialOutput = await capturePane(sessionName)
98 const cleanOutput = stripAnsi(initialOutput)
99
100 console.log('\n--- Output ---')
101 console.log(cleanOutput)
102 console.log('--- End Output ---\n')
103
104 // 5. Verify output contains expected text
105 const checks = [
106 { text: '--agent', pass: cleanOutput.includes('--agent') },
107 { text: 'Usage:', pass: cleanOutput.includes('Usage:') },
108 { text: '--help', pass: cleanOutput.includes('--help') },

Callers 1

tmux-poc.tsFile · 0.85

Calls 5

isTmuxAvailableFunction · 0.90
sleepFunction · 0.90
capturePaneFunction · 0.85
stripAnsiFunction · 0.85
tmuxFunction · 0.70

Tested by

no test coverage detected