Skip to content

Commit

Permalink
Record testcase directory in judging runs.
Browse files Browse the repository at this point in the history
This makes it much easier to find out where to go for debugging.
  • Loading branch information
meisterT committed Feb 17, 2024
1 parent a61710f commit 09b76d2
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 4 deletions.
1 change: 1 addition & 0 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,7 @@ function judge(array $judgeTask): bool
'metadata' => rest_encode_file($testcasedir . '/program.meta', false),
'output_diff' => rest_encode_file($testcasedir . '/feedback/judgemessage.txt', $output_storage_limit),
'hostname' => $myhost,
'testcasedir' => $testcasedir,
];

if (file_exists($testcasedir . '/feedback/teammessage.txt')) {
Expand Down
36 changes: 36 additions & 0 deletions webapp/migrations/Version20240212190713.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240212190713 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add optional testcase directory to judging run.';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE judging_run ADD testcase_dir VARCHAR(256) DEFAULT NULL COMMENT \'The path to the testcase directory on the judgehost.\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE judging_run DROP testcase_dir');
}

public function isTransactional(): bool
{
return false;
}
}
12 changes: 8 additions & 4 deletions webapp/src/Controller/API/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,15 @@ public function addJudgingRunAction(
$outputSystem = $request->request->get('output_system');
$teamMessage = $request->request->get('team_message');
$metadata = $request->request->get('metadata');
$testcasedir = $request->request->get('testcasedir');

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

$hasFinalResult = $this->addSingleJudgingRun($judgeTaskId, $hostname, $runResult, $runTime,
$outputSystem, $outputError, $outputDiff, $outputRun, $teamMessage, $metadata);
$outputSystem, $outputError, $outputDiff, $outputRun, $teamMessage, $metadata, $testcasedir);
$judgehost = $this->em->getRepository(Judgehost::class)->findOneBy(['hostname' => $hostname]);
$judgehost->setPolltime(Utils::now());
$this->em->flush();
Expand Down Expand Up @@ -905,7 +906,8 @@ private function addSingleJudgingRun(
string $outputDiff,
string $outputRun,
?string $teamMessage,
string $metadata
string $metadata,
?string $testcasedir
): bool {
$resultsRemap = $this->config->get('results_remap');
$resultsPrio = $this->config->get('results_prio');
Expand All @@ -925,7 +927,8 @@ private function addSingleJudgingRun(
$outputDiff,
$outputRun,
$teamMessage,
$metadata
$metadata,
$testcasedir
) {
$judgingRun = $this->em->getRepository(JudgingRun::class)->findOneBy(
['judgetaskid' => $judgeTaskId]);
Expand All @@ -938,7 +941,8 @@ private function addSingleJudgingRun(
$judgingRun
->setRunresult($runResult)
->setRuntime((float)$runTime)
->setEndtime(Utils::now());
->setEndtime(Utils::now())
->setTestcasedir($testcasedir);
$judgingRunOutput
->setOutputRun(base64_decode($outputRun))
->setOutputDiff(base64_decode($outputDiff))
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/Controller/Jury/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ public function viewAction(
'/\[output storage truncated after \d* B\]/',
(string)$runResult['output_run_last_bytes']
);
if ($firstJudgingRun) {
$runResult['testcasedir'] = $firstJudgingRun->getTestcaseDir();
}
$runsOutput[] = $runResult;
}
}
Expand Down
19 changes: 19 additions & 0 deletions webapp/src/Entity/JudgingRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class JudgingRun extends BaseApiEntity
#[Serializer\Exclude]
private ?JudgeTask $judgetask = null;

#[ORM\Column(
length: 256,
nullable: true,
options: ['comment' => 'The path to the testcase directory on the judgehost.']
)]
#[Serializer\Exclude]
private ?string $testcaseDir = null;

public function __construct()
{
$this->output = new ArrayCollection();
Expand Down Expand Up @@ -221,4 +229,15 @@ public function getOutput(): ?JudgingRunOutput
{
return $this->output->first() ?: null;
}

public function setTestcaseDir(?string $testcaseDir): JudgingRun
{
$this->testcaseDir = $testcaseDir;
return $this;
}

public function getTestcaseDir(): ?string
{
return $this->testcaseDir;
}
}
4 changes: 4 additions & 0 deletions webapp/templates/jury/submission.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@
-#})
{% endif %}
{% endif %}
{% if runsOutput[runIdx].testcasedir is not null %}
| <code>.../{{ runsOutput[runIdx].testcasedir | split('/') | last }}</code>{#-
-#}<button type="button" class="btn btn-link" onclick="navigator.clipboard.writeText('{{ runsOutput[runIdx].testcasedir }}')"><i class="fa-regular fa-copy"></i></button>
{% endif %}
<span style="float: right;">
<a href="{{ path('jury_problem_testcase_fetch', {'probId': submission.problem.probid, 'rank': run.rank, 'type': 'input'}) }}">
<button class="btn btn-sm btn-outline-secondary" >
Expand Down

0 comments on commit 09b76d2

Please sign in to comment.