Skip to content

Commit

Permalink
grader: always run pretest_test_cases if available
Browse files Browse the repository at this point in the history
Ref #1068.
  • Loading branch information
Xyene committed Nov 1, 2022
1 parent b24be1c commit 2bcba25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
19 changes: 16 additions & 3 deletions dmoj/graders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, judge, problem, language, source):
self.problem = problem
self.judge = judge
self.binary = self._generate_binary()
self.is_pretested = self.problem.meta.pretests_only and 'pretest_test_cases' in self.problem.config
self.run_pretests_only = self.problem.meta.pretests_only
self._abort_requested = False
self._current_proc = None
self._batch_counter = 0
Expand Down Expand Up @@ -48,5 +48,18 @@ def _resolve_testcases(self, cfg, batch_no=0):
return cases

def cases(self):
key = 'pretest_test_cases' if self.is_pretested else 'test_cases'
return self._resolve_testcases(self.problem.config[key])
pretest_test_cases = self.problem.config.pretest_test_cases
if self.run_pretests_only and pretest_test_cases:
return self._resolve_testcases(pretest_test_cases)

test_cases = self._resolve_testcases(self.problem.config.test_cases)
if pretest_test_cases:
pretest_test_cases = self._resolve_testcases(pretest_test_cases)

# Hack: force short-circuiting behavior
for case in pretest_test_cases:
case.points = 0

test_cases = pretest_test_cases + test_cases

return test_cases
2 changes: 1 addition & 1 deletion dmoj/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def _grade_cases(self) -> Generator[Tuple[IPC, tuple], None, None]:
if hasattr(binary, 'warning') and binary.warning is not None:
yield IPC.COMPILE_MESSAGE, (binary.warning,)

yield IPC.GRADING_BEGIN, (self.grader.is_pretested,)
yield IPC.GRADING_BEGIN, (self.grader.run_pretests_only,)

flattened_cases: List[Tuple[Optional[int], Union[TestCase, BatchedTestCase]]] = []
batch_number = 0
Expand Down
10 changes: 0 additions & 10 deletions testsuite/aplusb/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ symlinks: {

hints: [nobigmath]

pretest_test_cases:
- {in: aplusb.1.in, out: aplusb.1.out, points: 5}
- {in: aplusb.2.in, out: aplusb.2.out, points: 20}
- {in: aplusb.3.in, out: aplusb.3.out, points: 75}
- {in: aplusb.1.in, out: aplusb.1.out, points: 5}
- {in: aplusb.2.in, out: aplusb.2.out, points: 20}
- {in: aplusb.3.in, out: aplusb.3.out, points: 75}
- {in: aplusb.1.in, out: aplusb.1.out, points: 5}
- {in: aplusb.2.in, out: aplusb.2.out, points: 20}
- {in: aplusb.3.in, out: aplusb.3.out, points: 75}
test_cases:
- {in: aplusb.1.in, out: aplusb.1.out, points: 5}
- {in: aplusb.2.in, out: aplusb.2.out, points: 20}
Expand Down

0 comments on commit 2bcba25

Please sign in to comment.