Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grader: always run pretest_test_cases if available #1070

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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