@@ -3,6 +3,62 @@ local ui = require('opencode.ui.ui')
33local helpers = require (' tests.helpers' )
44local output_window = require (' opencode.ui.output_window' )
55
6+ local function assert_output_matches (expected , actual )
7+ local normalized_extmarks = helpers .normalize_namespace_ids (actual .extmarks )
8+
9+ assert .equal (
10+ # expected .lines ,
11+ # actual .lines ,
12+ string.format (
13+ ' Line count mismatch: expected %d, got %d.\n First difference at index %d:\n Expected: %s\n Actual: %s' ,
14+ # expected .lines ,
15+ # actual .lines ,
16+ math.min (# expected .lines , # actual .lines ) + 1 ,
17+ vim .inspect (expected .lines [math.min (# expected .lines , # actual .lines ) + 1 ]),
18+ vim .inspect (actual .lines [math.min (# expected .lines , # actual .lines ) + 1 ])
19+ )
20+ )
21+
22+ for i = 1 , # expected .lines do
23+ assert .equal (
24+ expected .lines [i ],
25+ actual .lines [i ],
26+ string.format (
27+ ' Line %d mismatch:\n Expected: %s\n Actual: %s' ,
28+ i ,
29+ vim .inspect (expected .lines [i ]),
30+ vim .inspect (actual .lines [i ])
31+ )
32+ )
33+ end
34+
35+ assert .equal (
36+ # expected .extmarks ,
37+ # normalized_extmarks ,
38+ string.format (
39+ ' Extmark count mismatch: expected %d, got %d.\n First difference at index %d:\n Expected: %s\n Actual: %s' ,
40+ # expected .extmarks ,
41+ # normalized_extmarks ,
42+ math.min (# expected .extmarks , # normalized_extmarks ) + 1 ,
43+ vim .inspect (expected .extmarks [math.min (# expected .extmarks , # normalized_extmarks ) + 1 ]),
44+ vim .inspect (normalized_extmarks [math.min (# expected .extmarks , # normalized_extmarks ) + 1 ])
45+ )
46+ )
47+
48+ for i = 1 , # expected .extmarks do
49+ assert .same (
50+ expected .extmarks [i ],
51+ normalized_extmarks [i ],
52+ string.format (
53+ ' Extmark %d mismatch:\n Expected: %s\n Actual: %s' ,
54+ i ,
55+ vim .inspect (expected .extmarks [i ]),
56+ vim .inspect (normalized_extmarks [i ])
57+ )
58+ )
59+ end
60+ end
61+
662describe (' renderer' , function ()
763 local restore_time_ago
864
@@ -34,9 +90,7 @@ describe('renderer', function()
3490 vim .wait (200 )
3591
3692 local actual = helpers .capture_output (state .windows .output_buf , output_window .namespace )
37-
38- assert .are .same (expected .lines , actual .lines )
39- assert .are .same (expected .extmarks , helpers .normalize_namespace_ids (actual .extmarks ))
93+ assert_output_matches (expected , actual )
4094 end )
4195
4296 it (' replays ' .. name .. ' correctly (full session load)' , function ()
@@ -50,9 +104,7 @@ describe('renderer', function()
50104 vim .wait (200 )
51105
52106 local actual = helpers .capture_output (state .windows .output_buf , output_window .namespace )
53-
54- assert .are .same (expected .lines , actual .lines )
55- assert .are .same (expected .extmarks , helpers .normalize_namespace_ids (actual .extmarks ))
107+ assert_output_matches (expected , actual )
56108 end )
57109 end
58110 end
0 commit comments