Skip to content

Commit 28916f6

Browse files
committed
Record testcase directory in judging runs.
This makes it much easier to find out where to go for debugging.
1 parent 89fe096 commit 28916f6

File tree

6 files changed

+71
-4
lines changed

6 files changed

+71
-4
lines changed

judge/judgedaemon.main.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@ function judge(array $judgeTask): bool
14441444
'metadata' => rest_encode_file($testcasedir . '/program.meta', false),
14451445
'output_diff' => rest_encode_file($testcasedir . '/feedback/judgemessage.txt', $output_storage_limit),
14461446
'hostname' => $myhost,
1447+
'testcasedir' => $testcasedir,
14471448
];
14481449

14491450
if (file_exists($testcasedir . '/feedback/teammessage.txt')) {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20240212190713 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return 'Add optional testcase directory to judging run.';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE judging_run ADD testcase_dir VARCHAR(256) DEFAULT NULL COMMENT \'The path to the testcase directory on the judgehost.\'');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE judging_run DROP testcase_dir');
30+
}
31+
32+
public function isTransactional(): bool
33+
{
34+
return false;
35+
}
36+
}

webapp/src/Controller/API/JudgehostController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,15 @@ public function addJudgingRunAction(
634634
$outputSystem = $request->request->get('output_system');
635635
$teamMessage = $request->request->get('team_message');
636636
$metadata = $request->request->get('metadata');
637+
$testcasedir = $request->request->get('testcasedir');
637638

638639
$judgehost = $this->em->getRepository(Judgehost::class)->findOneBy(['hostname' => $hostname]);
639640
if (!$judgehost) {
640641
throw new BadRequestHttpException("Who are you and why are you sending us any data?");
641642
}
642643

643644
$hasFinalResult = $this->addSingleJudgingRun($judgeTaskId, $hostname, $runResult, $runTime,
644-
$outputSystem, $outputError, $outputDiff, $outputRun, $teamMessage, $metadata);
645+
$outputSystem, $outputError, $outputDiff, $outputRun, $teamMessage, $metadata, $testcasedir);
645646
$judgehost = $this->em->getRepository(Judgehost::class)->findOneBy(['hostname' => $hostname]);
646647
$judgehost->setPolltime(Utils::now());
647648
$this->em->flush();
@@ -905,7 +906,8 @@ private function addSingleJudgingRun(
905906
string $outputDiff,
906907
string $outputRun,
907908
?string $teamMessage,
908-
string $metadata
909+
string $metadata,
910+
?string $testcasedir
909911
): bool {
910912
$resultsRemap = $this->config->get('results_remap');
911913
$resultsPrio = $this->config->get('results_prio');
@@ -925,7 +927,8 @@ private function addSingleJudgingRun(
925927
$outputDiff,
926928
$outputRun,
927929
$teamMessage,
928-
$metadata
930+
$metadata,
931+
$testcasedir
929932
) {
930933
$judgingRun = $this->em->getRepository(JudgingRun::class)->findOneBy(
931934
['judgetaskid' => $judgeTaskId]);
@@ -938,7 +941,8 @@ private function addSingleJudgingRun(
938941
$judgingRun
939942
->setRunresult($runResult)
940943
->setRuntime((float)$runTime)
941-
->setEndtime(Utils::now());
944+
->setEndtime(Utils::now())
945+
->setTestcasedir($testcasedir);
942946
$judgingRunOutput
943947
->setOutputRun(base64_decode($outputRun))
944948
->setOutputDiff(base64_decode($outputDiff))

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ public function viewAction(
394394
'/\[output storage truncated after \d* B\]/',
395395
(string)$runResult['output_run_last_bytes']
396396
);
397+
if ($firstJudgingRun) {
398+
$runResult['testcasedir'] = $firstJudgingRun->getTestcaseDir();
399+
}
397400
$runsOutput[] = $runResult;
398401
}
399402
}

webapp/src/Entity/JudgingRun.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ class JudgingRun extends BaseApiEntity
8686
#[Serializer\Exclude]
8787
private ?JudgeTask $judgetask = null;
8888

89+
#[ORM\Column(
90+
length: 256,
91+
nullable: true,
92+
options: ['comment' => 'The path to the testcase directory on the judgehost.']
93+
)]
94+
#[Serializer\Exclude]
95+
private ?string $testcaseDir = null;
96+
8997
public function __construct()
9098
{
9199
$this->output = new ArrayCollection();
@@ -221,4 +229,15 @@ public function getOutput(): ?JudgingRunOutput
221229
{
222230
return $this->output->first() ?: null;
223231
}
232+
233+
public function setTestcaseDir(?string $testcaseDir): JudgingRun
234+
{
235+
$this->testcaseDir = $testcaseDir;
236+
return $this;
237+
}
238+
239+
public function getTestcaseDir(): ?string
240+
{
241+
return $this->testcaseDir;
242+
}
224243
}

webapp/templates/jury/submission.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@
677677
-#})
678678
{% endif %}
679679
{% endif %}
680+
{% if runsOutput[runIdx].testcasedir is not null %}
681+
| <code>.../{{ runsOutput[runIdx].testcasedir | split('/') | last }}</code>{#-
682+
-#}<button type="button" class="btn btn-link" onclick="navigator.clipboard.writeText('{{ runsOutput[runIdx].testcasedir }}')"><i class="fa-regular fa-copy"></i></button>
683+
{% endif %}
680684
<span style="float: right;">
681685
<a href="{{ path('jury_problem_testcase_fetch', {'probId': submission.problem.probid, 'rank': run.rank, 'type': 'input'}) }}">
682686
<button class="btn btn-sm btn-outline-secondary" >

0 commit comments

Comments
 (0)