fix(ci) : problem types
This commit is contained in:
parent
2f3912a1fa
commit
83a91e1985
6 changed files with 77 additions and 14 deletions
|
|
@ -126,11 +126,14 @@ function M.setup(user_config)
|
|||
end
|
||||
|
||||
if user_config.scrapers then
|
||||
for _, contest_name in ipairs(user_config.scrapers) do
|
||||
if not vim.tbl_contains(constants.PLATFORMS, contest_name) then
|
||||
for _, platform_name in ipairs(user_config.scrapers) do
|
||||
if type(platform_name) ~= 'string' then
|
||||
error(('Invalid scraper value type. Expected string, got %s'):format(type(platform_name)))
|
||||
end
|
||||
if not vim.tbl_contains(constants.PLATFORMS, platform_name) then
|
||||
error(
|
||||
("Invalid contest '%s' in scrapers config. Valid contests: %s"):format(
|
||||
contest_name,
|
||||
("Invalid platform '%s' in scrapers config. Valid platforms: %s"):format(
|
||||
platform_name,
|
||||
table.concat(constants.PLATFORMS, ', ')
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ if __name__ == "__main__":
|
|||
}
|
||||
|
||||
local user_overrides = {}
|
||||
for _, snippet in ipairs(config.snippets) do
|
||||
for _, snippet in ipairs(config.snippets or {}) do
|
||||
user_overrides[snippet.trigger] = snippet
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ describe('cp.config', function()
|
|||
|
||||
it('validates scraper platforms', function()
|
||||
local invalid_config = {
|
||||
scrapers = { invalid_platform = true },
|
||||
scrapers = { 'invalid_platform' },
|
||||
}
|
||||
|
||||
assert.has_error(function()
|
||||
|
|
@ -54,9 +54,9 @@ describe('cp.config', function()
|
|||
end)
|
||||
end)
|
||||
|
||||
it('validates scraper values are booleans', function()
|
||||
it('validates scraper values are strings', function()
|
||||
local invalid_config = {
|
||||
scrapers = { atcoder = 'not_boolean' },
|
||||
scrapers = { 123 },
|
||||
}
|
||||
|
||||
assert.has_error(function()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ describe('cp.health', function()
|
|||
local health
|
||||
|
||||
before_each(function()
|
||||
local original_gsub = string.gsub
|
||||
string.gsub = original_gsub
|
||||
|
||||
vim.fn = vim.tbl_extend('force', vim.fn, {
|
||||
executable = function()
|
||||
return 1
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ describe('cp integration', function()
|
|||
default_language = 'cpp',
|
||||
timeout_ms = 2000,
|
||||
cpp = {
|
||||
extension = 'cpp',
|
||||
compile = { 'g++', '{source}', '-o', '{binary}' },
|
||||
run = { '{binary}' },
|
||||
},
|
||||
|
|
@ -201,7 +202,19 @@ describe('cp integration', function()
|
|||
|
||||
it('handles scraper communication properly', function()
|
||||
vim.system = function(cmd)
|
||||
if cmd[1] == 'uv' and vim.tbl_contains(cmd, 'metadata') then
|
||||
if cmd[1] == 'ping' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif cmd[1] == 'uv' and cmd[2] == 'sync' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif cmd[1] == 'uv' and vim.tbl_contains(cmd, 'metadata') then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 1, stderr = 'network error' }
|
||||
|
|
@ -232,7 +245,19 @@ describe('cp integration', function()
|
|||
|
||||
it('processes scraper output correctly', function()
|
||||
vim.system = function(cmd)
|
||||
if vim.tbl_contains(cmd, 'metadata') then
|
||||
if cmd[1] == 'ping' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif cmd[1] == 'uv' and cmd[2] == 'sync' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif vim.tbl_contains(cmd, 'metadata') then
|
||||
return {
|
||||
wait = function()
|
||||
return {
|
||||
|
|
@ -339,7 +364,19 @@ describe('cp integration', function()
|
|||
|
||||
it('recovers from interrupted operations', function()
|
||||
vim.system = function(cmd)
|
||||
if vim.tbl_contains(cmd, 'metadata') then
|
||||
if cmd[1] == 'ping' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif cmd[1] == 'uv' and cmd[2] == 'sync' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif vim.tbl_contains(cmd, 'metadata') then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 1, stderr = 'interrupted' }
|
||||
|
|
@ -394,7 +431,19 @@ describe('cp integration', function()
|
|||
|
||||
it('maintains system stability on errors', function()
|
||||
vim.system = function(cmd)
|
||||
if vim.tbl_contains(cmd, 'metadata') then
|
||||
if cmd[1] == 'ping' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif cmd[1] == 'uv' and cmd[2] == 'sync' then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 0 }
|
||||
end,
|
||||
}
|
||||
elseif vim.tbl_contains(cmd, 'metadata') then
|
||||
return {
|
||||
wait = function()
|
||||
return { code = 1, stderr = 'scraper failed' }
|
||||
|
|
|
|||
|
|
@ -154,7 +154,11 @@ describe('cp test panel', function()
|
|||
},
|
||||
})
|
||||
|
||||
vim.cmd('silent! %bwipeout!')
|
||||
vim.cmd = function(cmd_str)
|
||||
if cmd_str:match('silent! %%bwipeout!') then
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
|
|
@ -163,7 +167,11 @@ describe('cp test panel', function()
|
|||
package.loaded['cp.test'] = nil
|
||||
package.loaded['cp.problem'] = nil
|
||||
package.loaded['cp.execute'] = nil
|
||||
vim.cmd('silent! %bwipeout!')
|
||||
vim.cmd = function(cmd_str)
|
||||
if cmd_str:match('silent! %%bwipeout!') then
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
describe('panel creation', function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue