Esempio n. 1
0
        public void Launch(EngineSettings settings)
        {
            Console.WriteLine ("=====================");
            Console.WriteLine ("Launching Game Engine");
            Console.WriteLine ("=====================");

            // TODO: Should this be dependent on "verbose" flag?
            //Console.WriteDebugLine ("Engine ID: " + engineId);

            var context = EngineContext.New (settings);

            context.Settings.OutputType = ConsoleOutputType.Game;

            context.PopulateFromSettings ();

            context.AddCompleteLogic ();

            context.Initialize ();
            //EngineProcess engine = null; // TODO: Remove if not needed
            try
            {
                using(var engine = new EngineProcess (context))
                {
                    engine.Run();
                }
            }
            catch (GameException ex) {
                context.Console.WriteDebugLine (ex.Message);
            }
            //finally {
            //	if (engine != null)
            //		engine.Dispose ();
        }
Esempio n. 2
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();
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
        public void Run_IncorrectClangHelpShouldNotReutrnExitCodeOfOne()
        {
            var process = new EngineProcess(
                new EngineProcessData()
            {
                WaitForExit      = 10000,
                Command          = "clang++",
                Arguments        = "help",
                WorkingDirectory = Directory.GetCurrentDirectory()
            });
            var code = process.Run();

            Assert.AreNotEqual(0, code);
        }
Esempio n. 5
0
        public void Run_IncorrectClangHelpShouldHaveErrorOutput()
        {
            var process = new EngineProcess(
                new EngineProcessData()
            {
                WaitForExit      = 10000,
                Command          = "clang++",
                Arguments        = "help",
                WorkingDirectory = Directory.GetCurrentDirectory()
            });

            process.Run();
            var error = process.StandardError;

            Assert.IsFalse(error.EndOfStream);
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
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;
     }
 }
Esempio n. 8
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();
        }
Esempio n. 9
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();
        }
Esempio n. 10
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();
        }