diff options
| author | William Boman <william@redwill.se> | 2023-05-18 17:06:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-18 17:06:38 +0200 |
| commit | 227f8a9aaae495f481c768f8346edfceaf6d2951 (patch) | |
| tree | 8b2dad3c6175fac3c02489690304f759f21b3649 /tests/mason-core/terminator_spec.lua | |
| parent | fix(ui): use vim.cmd("") for nvim-0.7.0 compatibility (#1307) (diff) | |
| download | mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar.gz mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar.bz2 mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar.lz mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar.xz mason-227f8a9aaae495f481c768f8346edfceaf6d2951.tar.zst mason-227f8a9aaae495f481c768f8346edfceaf6d2951.zip | |
feat(installer): lock package installation (#1290)
Diffstat (limited to 'tests/mason-core/terminator_spec.lua')
| -rw-r--r-- | tests/mason-core/terminator_spec.lua | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/mason-core/terminator_spec.lua b/tests/mason-core/terminator_spec.lua index d8d0f2eb..66b48ba4 100644 --- a/tests/mason-core/terminator_spec.lua +++ b/tests/mason-core/terminator_spec.lua @@ -11,23 +11,25 @@ describe("terminator", function() it( "should terminate all active handles on nvim exit", async_test(function() - -- TODO: Tests on CI fail for some reason - sleeping helps - a.sleep(500) spy.on(InstallHandle, "terminate") local dummy = registry.get_package "dummy" local dummy2 = registry.get_package "dummy2" for _, pkg in ipairs { dummy, dummy2 } do - stub(pkg.spec, "install") - pkg.spec.install.invokes(function() + stub(pkg.spec, "install", function() a.sleep(10000) end) end local dummy_handle = dummy:install() local dummy2_handle = dummy2:install() + + assert.wait_for(function() + assert.spy(dummy.spec.install).was_called() + assert.spy(dummy2.spec.install).was_called() + end) + terminator.terminate(5000) - a.wait(vim.schedule) assert.spy(InstallHandle.terminate).was_called(2) assert.spy(InstallHandle.terminate).was_called_with(match.is_ref(dummy_handle)) assert.spy(InstallHandle.terminate).was_called_with(match.is_ref(dummy2_handle)) @@ -41,22 +43,25 @@ describe("terminator", function() it( "should print warning messages", async_test(function() - -- TODO: Tests on CI fail for some reason - sleeping helps - a.sleep(500) spy.on(vim.api, "nvim_echo") spy.on(vim.api, "nvim_err_writeln") spy.on(InstallHandle, "terminate") local dummy = registry.get_package "dummy" local dummy2 = registry.get_package "dummy2" for _, pkg in ipairs { dummy, dummy2 } do - stub(pkg.spec, "install") - pkg.spec.install.invokes(function() + stub(pkg.spec, "install", function() a.sleep(10000) end) end local dummy_handle = dummy:install() local dummy2_handle = dummy2:install() + + assert.wait_for(function() + assert.spy(dummy.spec.install).was_called() + assert.spy(dummy2.spec.install).was_called() + end) + terminator.terminate(5000) assert.spy(vim.api.nvim_echo).was_called(1) @@ -85,8 +90,6 @@ describe("terminator", function() it( "should send SIGTERM and then SIGKILL after grace period", async_test(function() - -- TODO: Tests on CI fail for some reason - sleeping helps - a.sleep(500) spy.on(InstallHandle, "kill") local dummy = registry.get_package "dummy" stub(dummy.spec, "install") |
