Skip to content

Commit e210c4c

Browse files
feat: remove compiled binary after all test cases
1 parent b42c06c commit e210c4c

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ require('competitest').setup {
288288
save_current_file = true,
289289
save_all_files = false,
290290
compile_directory = ".",
291+
remove_compiled_binary = false,
291292
compile_command = {
292293
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
293294
cpp = { exec = "g++", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
@@ -386,6 +387,7 @@ require('competitest').setup {
386387
- `save_current_file`: if true save current file before running testcases
387388
- `save_all_files`: if true save all the opened files before running testcases
388389
- `compile_directory`: execution directory of compiler, relatively to current file's path
390+
- `remove_compiled_binary`: if true remove compiled binary after running testcases
389391
- `compile_command`: configure the command used to compile code for every different language, see [here](#customize-compile-and-run-commands)
390392
- `running_directory`: execution directory of your solutions, relatively to current file's path
391393
- `run_command`: configure the command used to run your solutions for every different language, see [here](#customize-compile-and-run-commands)

lua/competitest/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ local default_config = {
201201
save_current_file = true,
202202
save_all_files = false,
203203
compile_directory = ".",
204+
remove_compiled_binary = false,
204205
compile_command = {
205206
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
206207
cpp = { exec = "g++", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },

lua/competitest/runner.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ end
127127
---Run the next unprocessed testcase, if any, and when it finishes run the successive unprocessed testcase, if any
128128
function TCRunner:run_next_testcase()
129129
if self.next_tc > #self.tcdata then
130+
local sep = vim.fn.has("win32") and "\\" or "/"
131+
local rc_exec = self.running_directory .. sep .. self.rc.exec
132+
os.remove(rc_exec)
130133
return
131134
end
132135
self.next_tc = self.next_tc + 1

0 commit comments

Comments
 (0)