fix(ci): fix tests
This commit is contained in:
parent
531784778a
commit
5bf40bb694
3 changed files with 21 additions and 4 deletions
|
|
@ -144,7 +144,7 @@ function M.setup(user_config)
|
||||||
|
|
||||||
local config = vim.tbl_deep_extend('force', M.defaults, user_config or {})
|
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
|
for lang_name, lang_config in pairs(contest_config) do
|
||||||
if type(lang_config) == 'table' and not lang_config.extension then
|
if type(lang_config) == 'table' and not lang_config.extension then
|
||||||
if lang_name == 'cpp' then
|
if lang_name == 'cpp' then
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,13 @@ describe('cp integration', function()
|
||||||
table.insert(mock_system_calls, { cmd = cmd, opts = opts })
|
table.insert(mock_system_calls, { cmd = cmd, opts = opts })
|
||||||
local result = { code = 0, stdout = '{}', stderr = '' }
|
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
|
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
|
elseif vim.tbl_contains(cmd, 'tests') then
|
||||||
result.stdout = '{"success": true, "tests": [{"input": "1 2", "expected": "3"}]}'
|
result.stdout = '{"success": true, "tests": [{"input": "1 2", "expected": "3"}]}'
|
||||||
end
|
end
|
||||||
|
|
@ -61,6 +65,8 @@ describe('cp integration', function()
|
||||||
fnamemodify = function(path, modifier)
|
fnamemodify = function(path, modifier)
|
||||||
if modifier == ':e' then
|
if modifier == ':e' then
|
||||||
return path:match('%.([^.]+)$') or ''
|
return path:match('%.([^.]+)$') or ''
|
||||||
|
elseif modifier == ':h:h:h' then
|
||||||
|
return '/test/plugin/path'
|
||||||
end
|
end
|
||||||
return path
|
return path
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ describe('cp test panel', function()
|
||||||
has = function()
|
has = function()
|
||||||
return 1
|
return 1
|
||||||
end,
|
end,
|
||||||
|
mkdir = function() end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local _original_nvim_create_buf = vim.api.nvim_create_buf
|
local _original_nvim_create_buf = vim.api.nvim_create_buf
|
||||||
|
|
@ -127,11 +128,21 @@ describe('cp test panel', function()
|
||||||
end
|
end
|
||||||
vim.api.nvim_set_current_win = function() end
|
vim.api.nvim_set_current_win = function() end
|
||||||
|
|
||||||
vim.cmd = {
|
local cmd_table = {
|
||||||
split = function() end,
|
split = function() end,
|
||||||
vsplit = function() end,
|
vsplit = function() end,
|
||||||
diffthis = 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 = {
|
vim.keymap = {
|
||||||
set = function() end,
|
set = function() end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue