feat: fix typign
This commit is contained in:
parent
bd557ab069
commit
1b0d5e4d77
5 changed files with 46 additions and 0 deletions
|
|
@ -17,8 +17,11 @@ local actions = constants.ACTIONS
|
|||
---@field problem_id? string
|
||||
---@field interactor_cmd? string
|
||||
---@field test_index? integer
|
||||
---@field test_indices? integer[]
|
||||
---@field mode? string
|
||||
---@field debug? boolean
|
||||
---@field language? string
|
||||
---@field subcommand? string
|
||||
|
||||
--- Turn raw args into normalized structure to later dispatch
|
||||
---@param args string[] The raw command-line mode args
|
||||
|
|
|
|||
|
|
@ -274,10 +274,25 @@ local function save_all_tests()
|
|||
local is_multi_test = contest_data.problems[contest_data.index_map[problem_id]].multi_test
|
||||
or false
|
||||
|
||||
-- Generate combined test from individual test cases
|
||||
local combined_input = table.concat(
|
||||
vim.tbl_map(function(tc)
|
||||
return tc.input
|
||||
end, edit_state.test_cases),
|
||||
'\n'
|
||||
)
|
||||
local combined_expected = table.concat(
|
||||
vim.tbl_map(function(tc)
|
||||
return tc.expected
|
||||
end, edit_state.test_cases),
|
||||
'\n'
|
||||
)
|
||||
|
||||
cache.set_test_cases(
|
||||
platform,
|
||||
contest_id,
|
||||
problem_id,
|
||||
{ input = combined_input, expected = combined_expected },
|
||||
edit_state.test_cases,
|
||||
edit_state.constraints and edit_state.constraints.timeout_ms or 0,
|
||||
edit_state.constraints and edit_state.constraints.memory_mb or 0,
|
||||
|
|
|
|||
|
|
@ -447,6 +447,11 @@ function M.run_io_view(test_indices_arg, debug, mode)
|
|||
if mode == 'combined' then
|
||||
local combined = cache.get_combined_test(platform, contest_id, problem_id)
|
||||
|
||||
if not combined then
|
||||
logger.log('No combined test found', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
run.load_test_cases()
|
||||
|
||||
local result = run.run_combined_test(debug)
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ class CSESScraper(BaseScraper):
|
|||
"timeout_ms": timeout_ms,
|
||||
"memory_mb": memory_mb,
|
||||
"interactive": interactive,
|
||||
"multi_test": False,
|
||||
}
|
||||
|
||||
tasks = [run_one(p.id) for p in problems]
|
||||
|
|
|
|||
|
|
@ -61,6 +61,16 @@ def test_scraper_offline_fixture_matrix(run_scraper_offline, scraper, mode):
|
|||
tr = TestsResult.model_validate(obj)
|
||||
assert tr.problem_id != ""
|
||||
assert isinstance(tr.tests, list)
|
||||
assert hasattr(tr, "combined"), "Missing combined field"
|
||||
assert tr.combined is not None, "combined field is None"
|
||||
assert hasattr(tr.combined, "input"), "combined missing input"
|
||||
assert hasattr(tr.combined, "expected"), "combined missing expected"
|
||||
assert isinstance(tr.combined.input, str), "combined.input not string"
|
||||
assert isinstance(
|
||||
tr.combined.expected, str
|
||||
), "combined.expected not string"
|
||||
assert hasattr(tr, "multi_test"), "Missing multi_test field"
|
||||
assert isinstance(tr.multi_test, bool), "multi_test not boolean"
|
||||
validated_any = True
|
||||
else:
|
||||
assert "problem_id" in obj
|
||||
|
|
@ -68,5 +78,17 @@ def test_scraper_offline_fixture_matrix(run_scraper_offline, scraper, mode):
|
|||
assert (
|
||||
"timeout_ms" in obj and "memory_mb" in obj and "interactive" in obj
|
||||
)
|
||||
assert "combined" in obj, "Missing combined field in raw JSON"
|
||||
assert isinstance(obj["combined"], dict), "combined not a dict"
|
||||
assert "input" in obj["combined"], "combined missing input key"
|
||||
assert "expected" in obj["combined"], "combined missing expected key"
|
||||
assert isinstance(
|
||||
obj["combined"]["input"], str
|
||||
), "combined.input not string"
|
||||
assert isinstance(
|
||||
obj["combined"]["expected"], str
|
||||
), "combined.expected not string"
|
||||
assert "multi_test" in obj, "Missing multi_test field in raw JSON"
|
||||
assert isinstance(obj["multi_test"], bool), "multi_test not boolean"
|
||||
validated_any = True
|
||||
assert validated_any, "No valid tests payloads validated"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue