Exemplo n.º 1
0
        public void RunTestMethod(JavaTestClass javaTestClass, JavaTestMethod javaTestMethod,
                                  string originalCodeDirectory,
                                  string traceDirectory, string referenceCode = null)
        {
            var packageClassAndMethod = $"{javaTestClass.Package}.{javaTestClass.Name}#{javaTestMethod.Name}";
            var commandOptions        = GetCommandOptions(packageClassAndMethod, originalCodeDirectory, javaTestClass.ClassPath, javaTestClass.Name, javaTestMethod.Name, traceDirectory, referenceCode);

            var process = new EngineProcess(Command, commandOptions, originalCodeDirectory);

            try
            {
                var exitCode = process.Run();
                javaTestMethod.Passed = exitCode == 0;
            }
            catch (Exception e)
            {
                var exception = new EngineExceptionDto()
                {
                    Report = JavaEngineReportExceptionFactory
                             .GenerateReportForJunitTestRunnerTestMethodProcess(process, e, javaTestClass, javaTestMethod)
                };
                process.Stop();
                throw exception;
            }
            process.Stop();
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 3
0
        public async Task <ICollection <UnitTest> > GenerateResults(PreAssignment assignment, DirectoryHandler handler, string root)
        {
            using (var testHandler = new DirectoryHandler(GetTestDirectory(handler.Directory)))
            {
                var testProject = new TestProjectObj(testHandler.Directory, assignment.TestProject);

                if (!Directory.Exists(testProject.TestFolder))
                {
                    throw new EngineAssignmentExceptionData()
                          {
                              Report = new PreAssignmentBadTestFolderReport()
                          }
                }
                ;

                testProject.MoveFilesToProject(root);

                var preprocessorArguments = GetPreprocessorArguments(assignment.Solution.MethodDeclarations);

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

                var exitCode = process.Run();

                if (exitCode == 0)
                {
                    process.Stop();
                    return(GetUnitTestResults(ResultsFile(testHandler.Directory)));
                }

                EngineAssignmentExceptionData exception;

                using (var reader = process.StandardError)
                {
                    exception = new EngineAssignmentExceptionData()
                    {
                        Report = new PreAssignmentBuildFailureReport()
                        {
                            Report = reader.ReadToEnd(),
                        }
                    };
                }
                process.Stop();
                throw exception;
            }
        }
Exemplo n.º 4
0
        public void Compile(string workingDirectory, IList <string> sourceFiles)
        {
            var process = new EngineProcess(Command, GetCommandOptions(sourceFiles), workingDirectory);

            RunProcess(process);
            VerifyCompilation(process, sourceFiles);
            process.Stop();
        }
Exemplo n.º 5
0
        public void SetupJUnitCore(string workingDirectory, IList <JavaTestClass> javaClasses)
        {
            var process = new EngineProcess(Command, GetCommonOptionsForJunitCore(javaClasses), workingDirectory);

            try
            {
                process.Run();
            }
            catch (Exception e)
            {
                var exception = new EngineExceptionDto()
                {
                    Report = JavaEngineReportExceptionFactory
                             .GenerateReportForRawCoveragerJunitCore(process, e, javaClasses)
                };
                process.Stop();
                throw exception;
            }
            process.Stop();
        }
Exemplo n.º 6
0
        public void GenerateXmlForJavaClass(string codeDirectory, string reflectionDirectory, JavaTestClass javaTestClass)
        {
            var process = new EngineProcess(Command, GetCommandOptions(codeDirectory, javaTestClass, reflectionDirectory), codeDirectory);

            try
            {
                process.Run();
            }
            catch (Exception e)
            {
                var exception = new EngineExceptionDto()
                {
                    Report = JavaEngineReportExceptionFactory
                             .GenerateReportForReflectionProcess(process, e, javaTestClass)
                };
                process.Stop();
                throw exception;
            }
            process.Stop();
        }
Exemplo n.º 7
0
        public void TraceJavaMethod(JavaTestClass javaTestClass, JavaTestMethod testMethod, string workingDirectory)
        {
            var commandOptions = GetCommandOptions(javaTestClass.Name, testMethod.Name, javaTestClass.ClassPath);
            var process        = new EngineProcess(Command, commandOptions, workingDirectory);

            try
            {
                process.Run();
            }
            catch (Exception e)
            {
                var exception = new EngineExceptionDto()
                {
                    Report = JavaEngineReportExceptionFactory
                             .GenerateReportForTraceJavaMethod(process, e, javaTestClass, testMethod)
                };
                process.Stop();
                throw exception;
            }
            process.Stop();
        }
Exemplo n.º 8
0
 private void VerifyCompilation(EngineProcess process, IList <string> sourceFiles)
 {
     if (!VerifyCompile(sourceFiles))
     {
         var exception = new EngineExceptionDto()
         {
             Report = JavaEngineReportExceptionFactory.GenerateReportForCompileVerification(process, sourceFiles),
         };
         process.Stop();
         throw exception;
     }
 }
Exemplo n.º 9
0
 private void RunProcess(EngineProcess process)
 {
     try
     {
         process.Run();
     }
     catch (Exception e)
     {
         var exception = new EngineExceptionDto()
         {
             Report = JavaEngineReportExceptionFactory
                      .GenerateReportForCompileProcess(process, e)
         };
         process.Stop();
         throw exception;
     }
 }