diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java index fd5ab4836..aa912aea4 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java @@ -49,7 +49,6 @@ public abstract class BlackboxGradingEngine implements GradingEngine { private File gradingDir; private File compilationDir; private File evaluationDir; - private File scoringDir; private GradingConfig config; private GradingLanguage language; @@ -141,8 +140,6 @@ private void createGradingDirs() throws PreparationException { FileUtils.forceMkdir(compilationDir); evaluationDir = new File(gradingDir, "evaluation"); FileUtils.forceMkdir(evaluationDir); - scoringDir = new File(gradingDir, "scoring"); - FileUtils.forceMkdir(scoringDir); } catch (IOException e) { throw new PreparationException(e); } diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/DiffScorer.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/DiffScorer.java index 2068747d0..b73acc4a9 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/DiffScorer.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/DiffScorer.java @@ -9,6 +9,12 @@ import judgels.gabriel.api.Verdict; public class DiffScorer implements Scorer { + private final File evaluationDir; + + public DiffScorer(File evaluationDir) { + this.evaluationDir = evaluationDir; + } + @Override public ScoringResult score(File input, File output, File evaluationOutput) throws ScoringException { String[] scoringCommand = new String[]{"/bin/bash", "-c", String.format("" @@ -16,11 +22,13 @@ public ScoringResult score(File input, File output, File evaluationOutput) throw + "cat \"%s\" | tr '[\\t\\r\\n]' ' ' | xargs > _evaluation_tokenized.out; " + "diff --brief _output_tokenized.out _evaluation_tokenized.out; result=$?; " + "rm _output_tokenized.out _evaluation_tokenized.out; " - + "exit $result;", + + "exit $result", output.getAbsolutePath(), evaluationOutput.getAbsolutePath())}; ProcessBuilder pb = new ProcessBuilder(scoringCommand); + pb.directory(evaluationDir); + int exitCode; try { exitCode = pb.start().waitFor(); diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/ScorerRegistry.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/ScorerRegistry.java index 092904f38..97e3da702 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/ScorerRegistry.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/scorer/ScorerRegistry.java @@ -18,7 +18,7 @@ private ScorerRegistry() {} public static Scorer getAndPrepare( Optional customScorer, Map helperFiles, - @Nullable Sandbox sandbox, + @Nullable Sandbox sandbox, File evaluationDir) throws PreparationException { if (customScorer.isPresent()) { @@ -27,7 +27,7 @@ public static Scorer getAndPrepare( scorer.prepare(sandbox, evaluationDir, language, scorerFile); return scorer; } else { - return new DiffScorer(); + return new DiffScorer(evaluationDir); } } }