Skip to content

Commit

Permalink
Merge pull request #440 from dodona-edu/fix/bash
Browse files Browse the repository at this point in the history
Fix a few bugs
  • Loading branch information
niknetniko authored Sep 21, 2023
2 parents 24d4786 + ad15f91 commit 5e3508c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 7 additions & 4 deletions tested/judge/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
3 changes: 1 addition & 2 deletions tested/judge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tested/judge/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions tested/languages/bash/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,21 @@ 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)
result += indent + convert_statement(tc.input.input_statement()) + "\n"
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"

Expand Down

0 comments on commit 5e3508c

Please sign in to comment.