private Exception Run(string runArgs)
        {
            try
            {
                vstestProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        WorkingDirectory = WorkingDirectory,
                        FileName         = EnginePath,
                        UseShellExecute  = false,
                        CreateNoWindow   = true,
                        Arguments        = runArgs
                    }
                };

                PipeSinkServer.ParseLogMessage = ParseLogMessage;
                PipeSinkServer.Start(PipeName);

                vstestProcess.Start();
                vstestProcess.WaitForExit();
            }
            catch (Exception exception)
            {
                PipeSinkServer.Stop();
                return(exception);
            }
            return(null);
        }
Beispiel #2
0
        private Exception Run(string runArgs, CancellationToken cancellationToken)
        {
            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                vstestProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        WorkingDirectory      = WorkingDirectory,
                        FileName              = EnginePath,
                        UseShellExecute       = false,
                        CreateNoWindow        = false,
                        Arguments             = "test " + runArgs,
                        RedirectStandardError = true,
                    }
                };

                PipeSinkServer.ParseLogMessage = ParseLogMessage;
                PipeSinkServer.Start(PipeName);

                vstestProcess.Start();

                while (true)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        TerminateProcessTree(vstestProcess.Id);

                        cancellationToken.ThrowIfCancellationRequested();
                    }

                    if (vstestProcess.WaitForExit(ProcessWaitInterval))
                    {
                        break;
                    }
                }

                int err = vstestProcess.ExitCode;
                if (err != 0)
                {
                    string errorMsg = vstestProcess.StandardError.ReadToEnd();
                    Console.Error.WriteLine();
                    Console.Error.WriteLine(StringResource.RunCaseError);
                    Console.Error.WriteLine(errorMsg);
                }
                ;
            }
            catch (Exception exception)
            {
                PipeSinkServer.Stop();
                Console.WriteLine(exception.Message);
                return(exception);
            }

            PipeSinkServer.Stop();
            return(null);
        }
        /// <summary>
        /// Start to get the output.
        /// </summary>
        public void Run()
        {
            string line;

            while ((line = SR.ReadLine()) != null)
            {
                if (!IgnoreLogs && PipeSinkServer.ParseLogMessage != null)
                {
                    PipeSinkServer.ParseLogMessage(line);
                }
            }
        }
        private void ExecutionFinished(Exception e)
        {
            if (TestFinished != null)
            {
                TestFinished(this,
                             new TestFinishedEventArgs(
                                 logger.GroupByOutcome.PassedTestCases.TestCaseList.Count,
                                 logger.GroupByOutcome.FailedTestCases.TestCaseList.Count,
                                 logger.GroupByOutcome.OtherTestCases.TestCaseList.Count,
                                 e));
            }

            htmlResultChecker.Stop();
            logger.IndexHtmlFilePath = htmlResultChecker.IndexHtmlFilePath;
            logger.FinishTest();
            PipeSinkServer.Stop();
        }
        private Exception Run(string runArgs)
        {
            try
            {
                vstestProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        WorkingDirectory = WorkingDirectory,
                        FileName         = EnginePath,
                        UseShellExecute  = true,
                        CreateNoWindow   = false,
                        Arguments        = "test " + runArgs,
                    }
                };

                PipeSinkServer.ParseLogMessage = ParseLogMessage;
                PipeSinkServer.Start(PipeName);

                vstestProcess.Start();
                vstestProcess.WaitForExit();
                int err = vstestProcess.ExitCode;
                if (err != 0)
                {
                    Console.Error.WriteLine();
                    Console.Error.WriteLine(StringResource.RunCaseError);
                }
                ;
            }
            catch (Exception exception)
            {
                PipeSinkServer.Stop();
                Console.WriteLine(exception.Message);
                return(exception);
            }

            PipeSinkServer.Stop();
            return(null);
        }