Text · 2148 bytes Raw Blame History
1 #!/usr/bin/expect -f
2 # Test LSP diagnostics display in fac editor
3 set timeout 5
4 log_user 1
5
6 puts "\n=== Testing LSP Diagnostics Display ==="
7 puts "Opening diagnostics_test.c with known errors..."
8
9 set test_file "tests/lsp/diagnostics_test.c"
10
11 spawn ./fac $test_file
12
13 # Wait for editor to start and LSP to initialize
14 sleep 2
15
16 puts "\n--- Checking for diagnostic markers in gutter ---"
17
18 # Look for error markers (●) on lines with errors
19 expect {
20 -re "●.*10" {
21 puts "✓ Error marker found on line 10 (missing semicolon)"
22 exp_continue
23 }
24 -re "▲.*16" {
25 puts "✓ Warning marker found on line 16 (type mismatch)"
26 exp_continue
27 }
28 timeout {
29 puts "! Timeout waiting for diagnostic markers"
30 }
31 }
32
33 puts "\n--- Testing status bar diagnostic messages ---"
34
35 # Navigate to line with error (line 10)
36 # Send Ctrl+G for goto
37 send "\007"
38 expect "Go to line:"
39 send "10\r"
40
41 # Wait for cursor to move and status bar to update
42 sleep 0.5
43
44 # Check if diagnostic message appears in status bar
45 expect {
46 -re "expected.*';'" {
47 puts "✓ Diagnostic message shown in status bar for missing semicolon"
48 }
49 -re "semicolon" {
50 puts "✓ Diagnostic message shown in status bar"
51 }
52 timeout {
53 puts "✗ No diagnostic message in status bar"
54 }
55 }
56
57 # Navigate to line with undefined variable (line 13)
58 send "\033\[B" ;# Down arrow
59 send "\033\[B" ;# Down arrow
60 send "\033\[B" ;# Down arrow
61
62 sleep 0.5
63
64 expect {
65 -re "undeclared|undefined.*'y'" {
66 puts "✓ Diagnostic for undefined variable shown"
67 }
68 timeout {
69 puts "✗ Undefined variable diagnostic not shown"
70 }
71 }
72
73 puts "\n--- Test complete, quitting editor ---"
74
75 # Quit
76 send "q"
77 expect {
78 "Save changes?" {
79 send "n"
80 exp_continue
81 }
82 eof {
83 puts "Editor exited"
84 }
85 }
86
87 puts "\n=== Diagnostics Test Complete ===\n"
88 puts "Summary:"
89 puts "- Diagnostic markers: Check gutter for ● (errors) and ▲ (warnings)"
90 puts "- Status bar: Shows diagnostic message when cursor is on error line"
91 puts "- Next step: Implement diagnostics panel (Ctrl+E) to list all issues\n"