Skip to content

Commit af2b9b5

Browse files
committed
fix!: better handling of pending jobs
- Now job id is nil when no job is running - Adjust the test adding a bit of time delay between them
1 parent 4000183 commit af2b9b5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lua/love2d/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ end
1414
---@param path string: The path to the Love2D project
1515
love2d.run = function(path)
1616
love2d.job = {} -- reset job
17-
vim.notify("Running Love2D project at " .. path, vim.log.levels.INFO)
17+
vim.notify("Running LÖVE project at " .. path)
1818
local cmd = require("love2d.config").options.path_to_love .. " " .. path
1919
love2d.job.id = vim.fn.jobstart(cmd, {
2020
on_exit = function(_, code)
21-
vim.print("Love2D exited with code " .. code)
2221
love2d.job.exit_code = code
22+
love2d.job.id = nil
2323
end,
2424
})
2525
end

tests/love2d/love2d_spec.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ describe("love2d mac", function()
55
love2d.setup({ path_to_love = "/Applications/love.app/Contents/MacOS/foo" })
66
love2d.run("tests/game")
77
vim.wait(1000)
8-
assert.equal(0, vim.fn.jobstop(love2d.job.id))
8+
assert.equal(nil, love2d.job.id)
9+
vim.wait(500)
910
end)
1011
it("starts", function()
1112
love2d.setup({ path_to_love = "/Applications/love.app/Contents/MacOS/love" })
1213
love2d.run("tests/game")
1314
vim.wait(1000)
1415
assert.equal(1, vim.fn.jobstop(love2d.job.id))
16+
vim.wait(500)
1517
end)
1618
it("does not run foo with wrong path to game", function()
1719
love2d.setup({ path_to_love = "/Applications/love.app/Contents/MacOS/love" })
1820
love2d.run("tests/foo")
1921
vim.wait(1000)
2022
assert.equal(1, vim.fn.jobstop(love2d.job.id))
21-
vim.wait(500) -- wait for on_exit to be called
23+
vim.wait(500)
2224
assert.equal(1, love2d.job.exit_code)
2325
end)
2426
it("runs game", function()

0 commit comments

Comments
 (0)