Пример #1
0
        public AbstractSyntaxTreeNode CreateFromFile(SubmissionData data, string path)
        {
            using (var handler =
                       new DirectoryHandler(GetCompilationDirectory(data)))
            {
                var process  = GetEngineProcess(GetEngineProcessData(handler.Directory, path));
                var exitCode = process.Run();
                if (exitCode == 0)
                {
                    process.Stop();
                    using (var reader = new StreamReader(GetOutputFile(handler.Directory)))
                    {
                        return(Extractor.Extract(reader));
                    }
                }
                EngineReportExceptionData exception;

                using (var reader = process.StandardError)
                {
                    exception = new EngineReportExceptionData(reader.ReadToEnd())
                    {
                        Type = "Compilation",
                    };
                }
                process.Stop();
                throw exception;
            }
        }
Пример #2
0
        public async Task <ICollection <UnitTestResult> > GenerateResultsImpl(SubmissionData data, string snapshot, DevAssignment assignment,
                                                                              ICollection <SnapshotMethod> snapshotMethods)
        {
            using (var handler =
                       new DirectoryHandler(GetTestDirectory(data)))
            {
                var testProject = new TestProjectObj(handler.Directory, assignment.TestProject);
                testProject.MoveFilesToProject(data.SnapshotSourceFiles(snapshot));

                var preprocessorArguments = GetPreprocessorArguments(snapshotMethods);

                var process = new EngineProcess(GetEngineProcessData(handler.Directory,
                                                                     testProject, preprocessorArguments));

                var exitCode = process.Run();
                if (exitCode == 0)
                {
                    process.Stop();
                    return(GetUnitTestResults(assignment.TestProject,
                                              ResultsFile(handler.Directory)));
                }

                EngineReportExceptionData exception;

                using (var reader = process.StandardError)
                {
                    exception = new EngineReportExceptionData(reader.ReadToEnd())
                    {
                        Type = "Build",
                    };
                }
                process.Stop();
                throw exception;
            }
        }