@@ -39,7 +39,10 @@ local function with_helpers(options, callback)
3939 if value == " error" then error " child RPC failed" end
4040 return value == nil and false or value
4141 end ,
42- lua = function (expression ) table.insert (state .lua_calls , expression ) end ,
42+ lua = function (expression )
43+ table.insert (state .lua_calls , expression )
44+ if options .lua_error then error (options .lua_error ) end
45+ end ,
4346 start = function (arguments )
4447 state .start_arguments = arguments
4548 if options .start_error then error (options .start_error ) end
@@ -165,6 +168,33 @@ T["WAIT-01 retries child RPC conditions after a false result"] = function()
165168 end )
166169end
167170
171+ T [" WAIT-02 reports a dead child instead of masking the RPC error as a timeout" ] = function ()
172+ with_helpers ({ wait_values = { " error" }, child_running = false }, function (helpers , state )
173+ local child = helpers .start_child ()
174+ local ok , err = pcall (helpers .wait_until , child , " ready" , " child readiness" , 100 )
175+
176+ assert .is_false (ok )
177+ assert_contains (err , " Child Neovim exited while waiting for child readiness" )
178+ assert_contains (err , " child RPC failed" )
179+ assert .equals (1 , state .lua_get_calls )
180+ assert .equals (0 , state .wait_calls )
181+ helpers .stop_child (child )
182+ end )
183+ end
184+
185+ T [" WAIT-03 retains the final RPC error when a live child never becomes ready" ] = function ()
186+ with_helpers ({ wait_values = { " error" } }, function (helpers , state )
187+ local child = helpers .start_child ()
188+ local ok , err = pcall (helpers .wait_until , child , " ready" , " child readiness" , 100 )
189+
190+ assert .is_false (ok )
191+ assert_contains (err , " Timed out waiting for child readiness" )
192+ assert_contains (err , " child RPC failed" )
193+ assert .is_true (state .lua_get_calls > 1 )
194+ helpers .stop_child (child )
195+ end )
196+ end
197+
168198T [" CHILD-01 starts a ready child and loads requested plugins" ] = function ()
169199 with_helpers ({ wait_values = { true } }, function (helpers , state , root )
170200 local child = helpers .start_ready_child { " astrolsp" }
@@ -177,6 +207,32 @@ T["CHILD-01 starts a ready child and loads requested plugins"] = function()
177207 end )
178208end
179209
210+ T [" CHILD-02 cleans a child when readiness fails before the caller receives it" ] = function ()
211+ with_helpers ({ wait_values = { false } }, function (helpers , state , root )
212+ local ok , err = pcall (helpers .start_ready_child )
213+ local fixture_available = pcall (helpers .fixture_project , state .child )
214+
215+ assert .is_false (ok )
216+ assert_contains (err , " Timed out waiting for VimEnter and LazyDone" )
217+ assert .equals (1 , state .stop_attempts )
218+ assert .same ({ root }, state .deleted_roots )
219+ assert .is_false (fixture_available )
220+ end )
221+ end
222+
223+ T [" CHILD-03 cleans a child when requested plugin loading fails" ] = function ()
224+ with_helpers ({ wait_values = { true }, lua_error = " plugin loading failed" }, function (helpers , state , root )
225+ local ok , err = pcall (helpers .start_ready_child , { " astrolsp" })
226+ local fixture_available = pcall (helpers .fixture_project , state .child )
227+
228+ assert .is_false (ok )
229+ assert_contains (err , " plugin loading failed" )
230+ assert .equals (1 , state .stop_attempts )
231+ assert .same ({ root }, state .deleted_roots )
232+ assert .is_false (fixture_available )
233+ end )
234+ end
235+
180236T [" PORT-01 creates fixtures under the platform temp directory and copies them through libuv" ] = function ()
181237 with_helpers ({}, function (helpers , state , root )
182238 local child = helpers .start_child ()
0 commit comments