Text · 1507 bytes Raw Blame History
1 #!/usr/bin/expect -f
2
3 # Test that initial diagnostics are received when opening a file
4 # This focuses on the textDocument/didOpen notification
5
6 set timeout 10
7 spawn ./fac tests/lsp/sample_errors.c
8
9 # Wait for editor and LSP initialization
10 expect {
11 "LSP server initialized" {
12 puts "✓ LSP server started for C file"
13 }
14 timeout {
15 puts "✗ LSP server did not initialize"
16 puts " Check that clangd is installed: which clangd"
17 exit 1
18 }
19 }
20
21 # Wait for initial diagnostics to arrive
22 sleep 4
23
24 # Try to see diagnostics in status bar or gutter
25 expect {
26 -re "●|▲|◆|○" {
27 puts "✓ Diagnostic markers visible in gutter"
28 }
29 "error" {
30 puts "✓ Error indicator found"
31 }
32 timeout {
33 puts "⚠ No visual diagnostic indicators found"
34 }
35 }
36
37 # Open diagnostics panel
38 send "\033\[68;6u" ;# Ctrl+Shift+D
39 sleep 1
40
41 # Check for diagnostics in panel
42 expect {
43 "Diagnostics" { puts "✓ Diagnostics panel opened" }
44 timeout { puts "⚠ Diagnostics panel did not open" }
45 }
46
47 expect {
48 -re "\\d+ diagnostic" { puts "✓ Diagnostics count displayed" }
49 "expected" { puts "✓ Diagnostic message visible" }
50 "syntax" { puts "✓ Syntax error detected" }
51 "No diagnostics" { puts "✗ No diagnostics received from LSP" }
52 timeout { puts "⚠ Could not read diagnostics content" }
53 }
54
55 # Quit
56 send "\030" ;# Ctrl+X
57 expect {
58 "Save" { send "n" }
59 eof { }
60 }
61
62 wait
63 puts "\n=== Initial diagnostics test complete ===\n"