Text · 2415 bytes Raw Blame History
1 #!/usr/bin/expect -f
2
3 # Debug version of diagnostics test with verbose output
4
5 set timeout 15
6 log_user 1 ;# Show all output
7
8 puts "=== Starting LSP Diagnostics Debug Test ===\n"
9 puts "Opening file with syntax errors: tests/lsp/sample_errors.c\n"
10
11 spawn ./fac tests/lsp/sample_errors.c
12
13 # Wait for LSP initialization
14 expect {
15 "LSP server initialized" {
16 puts "\n✓ LSP server started successfully"
17 }
18 timeout {
19 puts "\n✗ LSP server failed to initialize"
20 puts " Ensure clangd is installed: which clangd"
21 exit 1
22 }
23 }
24
25 puts "\nWaiting 5 seconds for initial diagnostics to arrive..."
26 sleep 5
27
28 # Try multiple methods to detect diagnostics
29
30 puts "\nMethod 1: Looking for diagnostic markers in display..."
31 send "" ;# Trigger redraw
32 sleep 0.5
33
34 puts "\nMethod 2: Opening diagnostics panel with Ctrl+Shift+D..."
35 send "\033\[68;6u"
36 sleep 2
37
38 puts "\nMethod 3: Checking status bar..."
39 send "" ;# Trigger another redraw
40 sleep 0.5
41
42 puts "\nMethod 4: Manually triggering buffer change to force sync..."
43 # Add a space and delete it to trigger didChange
44 send " "
45 sleep 0.5
46 send "\b"
47 sleep 3 ;# Wait for debounce and processing
48
49 puts "\nMethod 5: Reopening diagnostics panel..."
50 send "\033\[68;6u" ;# Close
51 sleep 0.5
52 send "\033\[68;6u" ;# Open
53 sleep 1
54
55 puts "\n\n=== Current screen content (looking for diagnostics): ===\n"
56 # The expect buffer should contain the screen content
57
58 # Final check for any diagnostic-related text
59 expect {
60 "diagnostic" { puts "\n✓ Found 'diagnostic' keyword" }
61 "error" { puts "\n✓ Found 'error' keyword" }
62 "warning" { puts "\n✓ Found 'warning' keyword" }
63 "expected" { puts "\n✓ Found 'expected' keyword (likely from diagnostic message)" }
64 -re "●|▲|◆|○" { puts "\n✓ Found diagnostic marker symbols" }
65 timeout { puts "\n⚠ No diagnostic indicators found after all attempts" }
66 }
67
68 puts "\n\nQuitting editor..."
69 send "\030" ;# Ctrl+X
70 expect {
71 "Save" {
72 send "n"
73 puts "Declined save prompt"
74 }
75 eof { puts "Editor exited" }
76 }
77
78 wait
79 puts "\n=== Debug test complete ===\n"
80 puts "If no diagnostics were found, possible issues:"
81 puts "1. LSP server (clangd) not sending publishDiagnostics notifications"
82 puts "2. Diagnostics handler not properly connected"
83 puts "3. File URI mismatch between didOpen and publishDiagnostics"
84 puts "4. Need to implement textDocument/didSave for some LSP servers"