Skip to content

Commit 90b2a9e

Browse files
feat: remove compiled binary after all test cases
1 parent c3cb0e2 commit 90b2a9e

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
@@ -285,6 +285,7 @@ require('competitest').setup {
285285
save_current_file = true,
286286
save_all_files = false,
287287
compile_directory = ".",
288+
remove_compiled_binary = false,
288289
compile_command = {
289290
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
290291
cpp = { exec = "g++", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
@@ -382,6 +383,7 @@ require('competitest').setup {
382383
- `save_current_file`: if true save current file before running testcases
383384
- `save_all_files`: if true save all the opened files before running testcases
384385
- `compile_directory`: execution directory of compiler, relatively to current file's path
386+
- `remove_compiled_binary`: if true remove compiled binary after running testcases
385387
- `compile_command`: configure the command used to compile code for every different language, see [here](#customize-compile-and-run-commands)
386388
- `running_directory`: execution directory of your solutions, relatively to current file's path
387389
- `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
@@ -104,6 +104,7 @@ local default_config = {
104104
save_current_file = true,
105105
save_all_files = false,
106106
compile_directory = ".", -- working directory of compile_command, relatively to current file's path
107+
remove_compiled_binary = false,
107108
compile_command = {
108109
c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } },
109110
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
@@ -115,6 +115,9 @@ function TCRunner:run_testcases(tctbl, compile)
115115
return
116116
end
117117
if next_tc > tc_size then
118+
if self.compile and self.config.remove_compiled_binary and vim.fn.filereadable(self.rc.exec) then
119+
os.remove(self.rc.exec)
120+
end
118121
return
119122
end
120123
next_tc = next_tc + 1

0 commit comments

Comments
 (0)