Skip to content

Commit 7f447ee

Browse files
author
Martin Kruliš
authored
Recodex judge (#223)
* Updating JudgeBox to use new recodex-token-judge when possible. * Updating call arguments of judges for better BC. * Fixing conflict in new judge args.
1 parent a71ef44 commit 7f447ee

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

app/helpers/ExerciseConfig/Pipeline/Box/Boxes/JudgeBox.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,27 @@ private function getJudgeBinaryAndArgs(): array {
116116
// Translation of judge type to command and args. The first item is the default.
117117
static $judgeTypes = null;
118118
if ($judgeTypes === null) {
119+
// TODO - this is work in progress, a more elaborate way to define recodex-token-judge parameters will be devised soon
120+
// TODO - shuffle-rows and shuffle-all versions are not implemented yet in recodex-token-judge
121+
// Note: recodex-token-judge is the new judge, which provides more verbose output for the logs
122+
$commonArgs = ['--log-limit', '4k', '--ignore-trailing-whitespace'];
123+
$commonArgsLineEnds = ['--log-limit', '4k', '--ignore-line-ends'];
119124
$judgeTypes = [
120-
'recodex-judge-normal' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-normal', []], // default token judge (respecting newlines)
121-
'recodex-judge-float' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-normal', ['-r']], // judge comparing float values with some margin of error
122-
'recodex-judge-normal-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-normal', ['-n']], // default token judge (which treats \n as normal whitespace)
123-
'recodex-judge-float-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-normal', ['-rn']], // judge comparing float values (which treats \n as normal whitespace)
124-
'recodex-judge-shuffle' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-shuffle', ['-i']], // judge ignoring order of tokens on a line
125+
'recodex-judge-normal' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge', $commonArgs], // default token judge (respecting newlines)
126+
'recodex-judge-float' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge',
127+
array_merge($commonArgs, ['--numeric']) ], // judge comparing float values with some margin of error
128+
'recodex-judge-normal-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge',
129+
$commonArgsLineEnds ], // default token judge (which treats \n as normal whitespace)
130+
'recodex-judge-float-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge',
131+
array_merge($commonArgsLineEnds, ['--numeric']) ], // judge comparing float values (which treats \n as normal whitespace)
132+
133+
'recodex-judge-shuffle' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge',
134+
array_merge($commonArgs, ['--shuffled-tokens']) ], // judge ignoring order of tokens on a line
125135
'recodex-judge-shuffle-rows' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-shuffle', ['-r']], // judge ignoring order of rows
126136
'recodex-judge-shuffle-all' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-shuffle', ['-ir']], // judge ignoring order of tokens on a each line and order of rows
127-
'recodex-judge-shuffle-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-shuffle', ['-in']],// judge ignoring order of tokens (which treats \n ...)
137+
'recodex-judge-shuffle-newline' => [ConfigParams::$JUDGES_DIR . 'recodex-token-judge',
138+
array_merge($commonArgsLineEnds, ['--shuffled-tokens']) ], // judge ignoring order of tokens (which treats \n ...)
139+
128140
'recodex-judge-passthrough' => [ConfigParams::$JUDGES_DIR . 'recodex-judge-passthrough', []], // judge which writes its input file (first) to the stdout
129141
'diff' => ["/usr/bin/diff", []], // diff (binary-safe) judge
130142
];

tests/ExerciseConfig/Compilation/BaseCompiler.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ class TestBaseCompiler extends Tester\TestCase
434434
Assert::count(3, $testAJudgeTask->getDependencies());
435435
Assert::equal([$testACopyTask->getId(), $testARunTask->getId(), $testAMkdir->getId()],
436436
$testAJudgeTask->getDependencies());
437-
Assert::equal(ConfigParams::$JUDGES_DIR . "recodex-judge-normal", $testAJudgeTask->getCommandBinary());
438-
Assert::equal([ConfigParams::$EVAL_DIR . "expected.out", ConfigParams::$EVAL_DIR . "actual.out"], $testAJudgeTask->getCommandArguments());
437+
Assert::equal(ConfigParams::$JUDGES_DIR . "recodex-token-judge", $testAJudgeTask->getCommandBinary());
438+
Assert::equal(["--log-limit", "4k", "--ignore-trailing-whitespace",
439+
ConfigParams::$EVAL_DIR . "expected.out", ConfigParams::$EVAL_DIR . "actual.out"],
440+
$testAJudgeTask->getCommandArguments());
439441
Assert::equal(TaskType::$EVALUATION, $testAJudgeTask->getType());
440442
Assert::equal("testA", $testAJudgeTask->getTestId());
441443
Assert::notEqual(null, $testAJudgeTask->getSandboxConfig());

0 commit comments

Comments
 (0)