update pyproject

This commit is contained in:
Barrett Ruth 2025-10-03 22:38:24 -04:00
parent b8c79401da
commit 179b333505
7 changed files with 471 additions and 411 deletions

View file

@ -31,7 +31,7 @@ local function substitute_template(cmd_template, substitutions)
return out
end
local function build_command(cmd_template, executable, substitutions)
function M.build_command(cmd_template, executable, substitutions)
local cmd = substitute_template(cmd_template, substitutions)
if executable then
table.insert(cmd, 1, executable)
@ -198,10 +198,4 @@ function M.compile_problem(contest_config, is_debug)
return { success = true, output = nil }
end
M._util = {
get_language_from_file = get_language_from_file,
substitute_template = substitute_template,
build_command = build_command,
}
return M

View file

@ -78,8 +78,8 @@ end
---@param substitutions table<string, string>
---@return string[]
local function build_command(language_config, substitutions)
local exec_util = require('cp.runner.execute')._util
return exec_util.build_command(language_config.test, language_config.executable, substitutions)
local execute = require('cp.runner.execute')
return execute.build_command(language_config.test, language_config.executable, substitutions)
end
---@param contest_config ContestConfig
@ -98,28 +98,6 @@ local function run_single_test_case(contest_config, cp_config, test_case)
local binary_file = state.get_binary_file()
local substitutions = { source = source_file, binary = binary_file }
if language_config.compile and binary_file and vim.fn.filereadable(binary_file) == 0 then
local cr = exec.compile(language_config, substitutions)
local ansi = require('cp.ui.ansi')
local clean = ansi.bytes_to_string(cr.stdout or '')
if cr.code ~= 0 then
return {
status = 'fail',
actual = clean,
actual_highlights = {},
error = 'Compilation failed',
stderr = clean,
time_ms = 0,
rss_mb = 0,
code = cr.code,
ok = false,
signal = nil,
tled = false,
mled = false,
}
end
end
local cmd = build_command(language_config, substitutions)
local stdin_content = (test_case.input or '') .. '\n'
local timeout_ms = (run_panel_state.constraints and run_panel_state.constraints.timeout_ms) or 0

View file

@ -177,12 +177,8 @@ function M.scrape_all_tests(platform, contest_id, callback)
local expected_file = 'io/' .. base_name .. '.' .. i .. '.cpout'
local input_content = t.input:gsub('\r', '')
local expected_content = t.expected:gsub('\r', '')
pcall(vim.fn.writefile, vim.split(input_content, '\n', { trimempty = true }), input_file)
pcall(
vim.fn.writefile,
vim.split(expected_content, '\n', { trimempty = true }),
expected_file
)
vim.fn.writefile(vim.split(input_content, '\n', { trimempty = true }), input_file)
vim.fn.writefile(vim.split(expected_content, '\n', { trimempty = true }), expected_file)
end
if type(callback) == 'function' then
callback({