private SubmitRunResult Run(Task task, string input, string runString) { var runService = new RunService(_runnerPath, _workingDirectory); var configuration = new Configuration(runString, _workingDirectory, task.TimeLimitMilliseconds, task.MemoryLimitBytes); configuration.InputFile = input; configuration.OutputFile = "output.txt"; //TODO var runResult = runService.Run(configuration); var result = new SubmitRunResult { Description = runResult.Description, Output = runResult.Output, PeakMemoryBytes = runResult.PeakMemoryBytes, RunStatus = runResult.RunStatus, TextStatus = runResult.TextStatus, TimeConsumedMilliseconds = runResult.TimeConsumedMilliseconds, TimePassedMilliseconds = runResult.TimePassedMilliseconds }; if (runResult.RunStatus == RunStatus.Success) { var checkAnswerResult = CheckAnswer(configuration); result.CheckMessage = checkAnswerResult.Message; result.CheckStatus = checkAnswerResult.CheckStatus; } return(result); }
public JudgeResult Check(SubmitResult submitResult) { CreateWorkingDirectory(); Language language; Task task; using (var uow = this.unitOfWorkFactory.GetUnitOfWork()) { language = uow.LanguageRepository.Get(submitResult.Submit.LanguageId); task = uow.TaskRepository.Get(submitResult.Submit.ProblemId); } CompileResult compileResult; if (language.IsCompilable) { compileResult = Compile(language, submitResult.Submit.FileName, submitResult.Submit.SourceCode); this.logger.Info($"Compile result: {compileResult.CompileStatus}"); } else { File.WriteAllText(Path.Combine(_workingDirectory, submitResult.Submit.FileName), submitResult.Submit.SourceCode); compileResult = CompileResult.GetEmpty(submitResult.Submit.FileName); } ICollection <SubmitRunResult> results = null; SubmitRunResult lastRunResult = null; if (compileResult.CompileStatus == CompileStatus.Success) { var runString = GetRunString(language, compileResult.FileName); this.logger.Info($"Run string: {runString}"); CopyChecker(task); results = Run(task, runString); lastRunResult = results.Last(); } RemoveWorkingDirectory(); return(new JudgeResult { CompileResult = compileResult, RunStatus = lastRunResult?.RunStatus, Description = lastRunResult?.Description, Output = lastRunResult?.Output, TextStatus = lastRunResult?.TextStatus, PeakMemoryBytes = results?.Max(o => o.PeakMemoryBytes), TimeConsumedMilliseconds = results?.Max(o => o.TimeConsumedMilliseconds), TimePassedMilliseconds = results?.Max(o => o.TimePassedMilliseconds), TestRunsCount = results?.Count ?? 0, CheckStatus = lastRunResult?.CheckStatus }); }