private void CheckBuildAndTests(string code, string fileDescription, bool shouldPassTests) { var result = new DockerSandboxRunner().Run(ex.CreateSubmission(Utils.NewNormalizedGuid(), code)); if (!ReportSlideError(ex.ExerciseType == ExerciseType.CheckOutput && result.Verdict != Verdict.Ok, $"{fileDescription} verdict is not OK. RunResult = {result}")) { var not = shouldPassTests ? "not " : ""; ReportSlideError(shouldPassTests ^ ex.IsCorrectRunResult(result), $"{fileDescription} is {not}solution. RunResult = {result}. " + $"ExpectedOutput = {ex.ExpectedOutput.NormalizeEoln()} " + $"RealOutput = {result.GetOutput().NormalizeEoln()}"); } }
private static RunSolutionResult GetRunResult(AbstractExerciseBlock exercise, string code) { var buildResult = exercise.BuildSolution(code); if (buildResult.HasErrors) { return new RunSolutionResult { IsCompileError = true, ErrorMessage = buildResult.ErrorMessage, ExecutionServiceName = "uLearn" } } ; RunSolutionResult runSolutionResult; if (exercise is UniversalExerciseBlock) { var result = new DockerSandboxRunner().Run(exercise.CreateSubmission(Utils.NewNormalizedGuid(), code)); runSolutionResult = new RunSolutionResult { IsRightAnswer = exercise.IsCorrectRunResult(result), ActualOutput = result.GetOutput()?.NormalizeEoln() ?? "", ErrorMessage = result.CompilationOutput, ExecutionServiceName = "course.exe", IsCompileError = result.Verdict == Verdict.CompilationError, ExpectedOutput = exercise.ExpectedOutput?.NormalizeEoln() ?? "", SubmissionId = 0, }; } else { var result = new CsSandboxRunnerClient().Run(exercise.CreateSubmission(Utils.NewNormalizedGuid(), code)); runSolutionResult = new RunSolutionResult { IsRightAnswer = exercise.IsCorrectRunResult(result), ActualOutput = result.GetOutput()?.NormalizeEoln() ?? "", ErrorMessage = result.CompilationOutput, ExecutionServiceName = "course.exe", IsCompileError = result.Verdict == Verdict.CompilationError, ExpectedOutput = exercise.ExpectedOutput?.NormalizeEoln() ?? "", SubmissionId = 0, }; } if (buildResult.HasStyleErrors) { runSolutionResult.IsStyleViolation = true; runSolutionResult.StyleMessage = string.Join("\n", buildResult.StyleErrors.Select(e => e.GetMessageWithPositions())); } return(runSolutionResult); }