@@ -218,9 +218,9 @@ mod.run = function(file)
218218 print (" \n " .. HEADER )
219219 print (" Testing: " , file )
220220
221- local loaded , msg = loadfile ( file )
221+ local ok , msg = pcall ( dofile , file )
222222
223- if not loaded then
223+ if not ok then
224224 print (HEADER )
225225 print " FAILED TO LOAD FILE"
226226 print (color_string (" red" , msg ))
@@ -232,37 +232,33 @@ mod.run = function(file)
232232 end
233233 end
234234
235- coroutine.wrap (function ()
236- loaded ()
237-
238- -- If nothing runs (empty file without top level describe)
239- if not results .pass then
240- if is_headless then
241- return vim .cmd " 0cq"
242- else
243- return
244- end
235+ -- If nothing runs (empty file without top level describe)
236+ if not results .pass then
237+ if is_headless then
238+ return vim .cmd " 0cq"
239+ else
240+ return
245241 end
242+ end
246243
247- mod .format_results (results )
244+ mod .format_results (results )
248245
249- if # results .errs ~= 0 then
250- print (" We had an unexpected error: " , vim .inspect (results .errs ), vim .inspect (results ))
251- if is_headless then
252- return vim .cmd " 2cq"
253- end
254- elseif # results .fail > 0 then
255- print " Tests Failed. Exit: 1"
246+ if # results .errs ~= 0 then
247+ print (" We had an unexpected error: " , vim .inspect (results .errs ), vim .inspect (results ))
248+ if is_headless then
249+ return vim .cmd " 2cq"
250+ end
251+ elseif # results .fail > 0 then
252+ print " Tests Failed. Exit: 1"
256253
257- if is_headless then
258- return vim .cmd " 1cq"
259- end
260- else
261- if is_headless then
262- return vim .cmd " 0cq"
263- end
254+ if is_headless then
255+ return vim .cmd " 1cq"
264256 end
265- end )()
257+ else
258+ if is_headless then
259+ return vim .cmd " 0cq"
260+ end
261+ end
266262end
267263
268264return mod
0 commit comments