Skip to content

Commit 9069d14

Browse files
authored
fix(tests): use :cq instead of os.exit() (#289)
This allows the running neovim instance to clean up resources before exiting, for example terminating running LSP servers.
1 parent 2a26cbe commit 9069d14

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lua/plenary/busted.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ mod.run = function(file)
225225
print(color_string("red", msg))
226226
print(HEADER)
227227
if is_headless then
228-
os.exit(2)
228+
return vim.cmd "2cq"
229229
else
230230
return
231231
end
@@ -234,7 +234,7 @@ mod.run = function(file)
234234
-- If nothing runs (empty file without top level describe)
235235
if not results.pass then
236236
if is_headless then
237-
os.exit(0)
237+
return vim.cmd "0cq"
238238
else
239239
return
240240
end
@@ -245,17 +245,17 @@ mod.run = function(file)
245245
if #results.fatal ~= 0 then
246246
print("We had an unexpected error: ", vim.inspect(results.fatal), vim.inspect(results))
247247
if is_headless then
248-
os.exit(2)
248+
return vim.cmd "2cq"
249249
end
250250
elseif #results.fail > 0 then
251251
print "Tests Failed. Exit: 1"
252252

253253
if is_headless then
254-
os.exit(1)
254+
return vim.cmd "1cq"
255255
end
256256
else
257257
if is_headless then
258-
os.exit(0)
258+
return vim.cmd "0cq"
259259
end
260260
end
261261
end

lua/plenary/test_harness.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ function harness.test_directory(directory, opts)
158158

159159
if headless then
160160
if failure then
161-
os.exit(1)
161+
return vim.cmd "1cq"
162162
end
163163

164-
os.exit(0)
164+
return vim.cmd "0cq"
165165
end
166166
end
167167

0 commit comments

Comments
 (0)