From bffa69f281ad816c972896f12a24aae29111c364 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 21 Sep 2023 14:43:33 +0200 Subject: [PATCH 1/2] Fix ignored tests when existing prematurely --- tested/judge/collector.py | 11 +++++++---- tested/judge/core.py | 3 +-- tested/judge/evaluation.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tested/judge/collector.py b/tested/judge/collector.py index 82cc2ec9..35752fab 100644 --- a/tested/judge/collector.py +++ b/tested/judge/collector.py @@ -112,26 +112,29 @@ def terminate( assert isinstance(status_if_unclosed, StatusMessage) status = status_if_unclosed - self.add(EscalateStatus(status=status)) + if status.enum != Status.CORRECT: + self.add(EscalateStatus(status=status)) + + open_tab, open_context, open_testcase = self.currently_open while self.open_stack: open_level = self.open_stack[-1] if open_level == "test": self.add(CloseTest(generated="", status=status)) elif open_level == "testcase": - self.add(CloseTestcase(accepted=False)) + self.add(CloseTestcase(accepted=False), open_testcase) if until == open_level: return elif open_level == "context": if until == "testcase": return - self.add(CloseContext()) + self.add(CloseContext(), open_context) if until == open_level: return elif open_level == "tab": if until in ("context", "testcase"): return - self.add(CloseTab()) + self.add(CloseTab(), open_tab) if until == open_level: return elif open_level == "judgement": diff --git a/tested/judge/core.py b/tested/judge/core.py index c0a19d18..57b58968 100644 --- a/tested/judge/core.py +++ b/tested/judge/core.py @@ -200,8 +200,7 @@ def _process_one_unit( return # Close the last tab. - collector.add(CloseTab(), currently_open_tab) - collector.add(CloseJudgement()) + terminate(bundle, collector, Status.CORRECT) def _execute_one_unit( diff --git a/tested/judge/evaluation.py b/tested/judge/evaluation.py index bbbf27eb..dbb94992 100644 --- a/tested/judge/evaluation.py +++ b/tested/judge/evaluation.py @@ -523,7 +523,7 @@ def complete_evaluation(bundle: Bundle, collector: OutputManager): collector.add(CloseContext(accepted=False)) collector.add(CloseTab()) context_start = 0 # For the next tab, start from the beginning. - collector.add(CloseJudgement(accepted=False)) + collector.add(CloseJudgement()) def terminate( From ad15f91a7cce08ac974ee6b5c50b5d3da667efd8 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 21 Sep 2023 15:17:19 +0200 Subject: [PATCH 2/2] Improve bash generation --- tested/languages/bash/generators.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tested/languages/bash/generators.py b/tested/languages/bash/generators.py index f5a2c8f0..6c206c29 100644 --- a/tested/languages/bash/generators.py +++ b/tested/languages/bash/generators.py @@ -210,7 +210,7 @@ def convert_execution_unit(pu: PreparedExecutionUnit) -> str: # Prepare command arguments if needed. if tc.testcase.is_main_testcase(): assert isinstance(tc.input, MainInput) - result += f"{indent}source {pu.submission_name}.sh " + result += f"{indent}bash {pu.submission_name}.sh " result += " ".join(shlex.quote(s) for s in tc.input.arguments) + "\n" else: assert isinstance(tc.input, PreparedTestcaseStatement) @@ -218,11 +218,13 @@ def convert_execution_unit(pu: PreparedExecutionUnit) -> str: result += "\n" result += indent + ctx.after + "\n" + result += indent + "return $?" + "\n" result += "}\n" for i, ctx in enumerate(pu.contexts): result += "write_context_separator\n" - result += f"context_{i}\n" + result += f"context_{i} || (exit $?)\n" + result += f"" result += "exit $?\n"