Skip to content

Commit

Permalink
Fix handling output file in DOMjudge reactive problem
Browse files Browse the repository at this point in the history
Before this change, DOMJudgeReactiveRunner ignores output file because
reactive problems don't usually have output, and interactor don't
use it.

However, when packing zip to upload, diff file is mandatory, so
even though it just creates an empty file, DOMJudgeReactiveRunner
should make sure diff file is created so that later pack and upload
won't fail due to missing diff file.

Fixes icpc-jag#102.
  • Loading branch information
tossy310 committed Sep 22, 2024
1 parent 1194c9d commit eeaecb6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions rime/plugins/judge_system/domjudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import signal
import subprocess
import tempfile
import threading
import time

Expand Down Expand Up @@ -213,17 +212,17 @@ def Run(self, reactive, args, cwd, input, output, timeout, precise):
if os.path.exists(feedback_dir_name):
shutil.rmtree(feedback_dir_name)
os.makedirs(feedback_dir_name, exist_ok=True)
# 2nd argument is an "expected output" file, which is not supported
# in rime interactive for now.
# As a placeholder, using a temporary file.
with tempfile.NamedTemporaryFile() as tmpfile:
judge_args = reactive.run_args + \
(input, tmpfile.name, feedback_dir_name, )
solution_args = args
task = DOMJudgeReactiveTask(
judge_args, solution_args,
cwd=cwd, timeout=timeout, exclusive=precise)
(judge_proc, solution_proc) = yield task

# Makes sure output file exists.
open(output, 'w').close()

judge_args = reactive.run_args + \
(input, output, feedback_dir_name, )
solution_args = args
task = DOMJudgeReactiveTask(
judge_args, solution_args,
cwd=cwd, timeout=timeout, exclusive=precise)
(judge_proc, solution_proc) = yield task

judge_code = judge_proc.returncode
solution_code = solution_proc.returncode
Expand Down

0 comments on commit eeaecb6

Please sign in to comment.