Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ require('competitest').setup {

save_current_file = true,
save_all_files = false,
run_empty_testcase = false,
compile_directory = ".",
compile_command = {
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
Expand Down Expand Up @@ -385,6 +386,7 @@ require('competitest').setup {
- `horizontal_layout`: a table describing horizontal split UI layout. For further details see [here](#customize-ui-layout)
- `save_current_file`: if true save current file before running testcases
- `save_all_files`: if true save all the opened files before running testcases
- `run_empty_testcase` if true and no testcases are provided, run an empty one
- `compile_directory`: execution directory of compiler, relatively to current file's path
- `compile_command`: configure the command used to compile code for every different language, see [here](#customize-compile-and-run-commands)
- `running_directory`: execution directory of your solutions, relatively to current file's path
Expand Down
2 changes: 2 additions & 0 deletions lua/competitest/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
---@field split_ui competitest.Config.split_ui
---@field save_current_file boolean save current file before running testcases
---@field save_all_files boolean save all the opened files before running testcases
---@field run_empty_testcase boolean if no testcases are provided, run an empty one
---@field compile_directory string working directory of compiler, relative to current file path
---@field compile_command { [string]: competitest.SystemCommand } command used to compile code, for each file type
---@field running_directory string working directory of your solutions, relative to current file path
Expand Down Expand Up @@ -200,6 +201,7 @@ local default_config = {

save_current_file = true,
save_all_files = false,
run_empty_testcase = false,
compile_directory = ".",
compile_command = {
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
Expand Down
3 changes: 3 additions & 0 deletions lua/competitest/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ function TCRunner:run_testcases(tctbl, compile)
if self.compile then -- if compilation is needed we add it as a testcase
table.insert(self.tcdata, { stdin = {}, expout = nil, tcnum = "Compile" })
end
if self.config.run_empty_testcase and tctbl[0] == nil then
tctbl[0] = { input = "" }
end
for tcnum, tc in pairs(tctbl) do
table.insert(self.tcdata, {
stdin = vim.split(tc.input, "\n", { plain = true }),
Expand Down