From 5bf40bb69430499003a426fb28e4baaed73f24c6 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 19 Sep 2025 00:26:18 -0400 Subject: [PATCH] fix(ci): fix tests --- lua/cp/config.lua | 2 +- spec/integration_spec.lua | 10 ++++++++-- spec/test_panel_spec.lua | 13 ++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lua/cp/config.lua b/lua/cp/config.lua index 0a6e7e0..cae943a 100644 --- a/lua/cp/config.lua +++ b/lua/cp/config.lua @@ -144,7 +144,7 @@ function M.setup(user_config) local config = vim.tbl_deep_extend('force', M.defaults, user_config or {}) - for contest_name, contest_config in pairs(config.contests) do + for _, contest_config in pairs(config.contests) do for lang_name, lang_config in pairs(contest_config) do if type(lang_config) == 'table' and not lang_config.extension then if lang_name == 'cpp' then diff --git a/spec/integration_spec.lua b/spec/integration_spec.lua index 63be0d0..48a4c17 100644 --- a/spec/integration_spec.lua +++ b/spec/integration_spec.lua @@ -26,9 +26,13 @@ describe('cp integration', function() table.insert(mock_system_calls, { cmd = cmd, opts = opts }) local result = { code = 0, stdout = '{}', stderr = '' } - if cmd[1] == 'uv' and cmd[2] == 'run' then + if cmd[1] == 'ping' then + result = { code = 0, stdout = '', stderr = '' } + elseif cmd[1] == 'uv' and cmd[2] == 'sync' then + result = { code = 0, stdout = '', stderr = '' } + elseif cmd[1] == 'uv' and cmd[2] == 'run' then if vim.tbl_contains(cmd, 'metadata') then - result.stdout = '{"success": true, "problems": [{"id": "a", "name": "Problem A"}]}' + result.stdout = '{"success": true, "problems": [{"id": "a", "name": "Problem A"}, {"id": "b", "name": "Problem B"}]}' elseif vim.tbl_contains(cmd, 'tests') then result.stdout = '{"success": true, "tests": [{"input": "1 2", "expected": "3"}]}' end @@ -61,6 +65,8 @@ describe('cp integration', function() fnamemodify = function(path, modifier) if modifier == ':e' then return path:match('%.([^.]+)$') or '' + elseif modifier == ':h:h:h' then + return '/test/plugin/path' end return path end, diff --git a/spec/test_panel_spec.lua b/spec/test_panel_spec.lua index 802e44d..c7c77fc 100644 --- a/spec/test_panel_spec.lua +++ b/spec/test_panel_spec.lua @@ -102,6 +102,7 @@ describe('cp test panel', function() has = function() return 1 end, + mkdir = function() end, }) local _original_nvim_create_buf = vim.api.nvim_create_buf @@ -127,11 +128,21 @@ describe('cp test panel', function() end vim.api.nvim_set_current_win = function() end - vim.cmd = { + local cmd_table = { split = function() end, vsplit = function() end, diffthis = function() end, } + + vim.cmd = setmetatable(cmd_table, { + __call = function(_, cmd_str) + if cmd_str and cmd_str:match('silent! %%bwipeout!') then + return + end + end, + __index = cmd_table, + __newindex = cmd_table, + }) vim.keymap = { set = function() end, }