Ejemplo n.º 1
0
        private RunningTestBuilder CreateTest_(string testName)
        {
            RunningTest test = new RunningTest(new RenderBrowserInfo(browserInfo_), logger_);

            test.TestName = testName;
            RunningTestBuilder builder = new RunningTestBuilder(test);

            return(builder);
        }
Ejemplo n.º 2
0
        void CheckRunningTests()
        {
            RunningTest timedOutTest = null;

            lock (mRunningTests)
            {
                for (int i = mRunningTests.Count - 1; i >= 0; --i)
                {
                    RunningTest current = mRunningTests[i];

                    int testRunningTimeSecs =
                        (int)(DateTime.Now - current.TestProcess.StartTime).TotalSeconds;

                    if (current.TestProcess.HasExited)
                    {
                        mRunningTests.RemoveAt(i);
                        continue;
                    }

                    if ((testRunningTimeSecs > mTestsTimeoutSecs) && !mNoTimeout)
                    {
                        timedOutTest = current;
                        break;
                    }
                }

                if (timedOutTest == null)
                {
                    return;
                }

                try
                {
                    SafeKillProcessTree(timedOutTest);

                    PNUnitAgent.NotifyError(
                        new Exception("Test killed due to timeout!"),
                        timedOutTest.TestInfo);

                    mLog.WarnFormat(
                        "Test killed due to timeout! [{0}]",
                        timedOutTest.TestInfo.TestName);
                }
                catch (Exception e)
                {
                    mLog.ErrorFormat(
                        "An error occurred killing processes. Error:[{0} - {1}]", e.Message, e.StackTrace);
                }
            }
        }
Ejemplo n.º 3
0
        void SafeKillProcessTree(RunningTest runningTest)
        {
            if (runningTest == null)
            {
                return;
            }

            if (runningTest.TestProcess.HasExited)
            {
                return;
            }

            try
            {
                int ini = Environment.TickCount;

                string processPid = runningTest.TestProcess.Id.ToString();
                mLog.DebugFormat(
                    "SafeKillProcessTree: About to kill test with process tree PID [{0}] (Test name [{1}])",
                    processPid, runningTest.TestInfo.TestName);

                Codice.Test.OSProcessKillerCmd.KillProcessTree(processPid);

                PNUnitServices.Get().WriteLine(string.Format(
                                                   "Kill [{0}] took [{1} ms]",
                                                   runningTest.TestInfo.TestName,
                                                   Environment.TickCount - ini));
            }
            catch (Exception e)
            {
                mLog.ErrorFormat(
                    "SafeKillProcessTree: An error occurred trying " +
                    " to kill test process tree: {0}", e.Message);

                mLog.Debug(e.StackTrace);
            }
        }
Ejemplo n.º 4
0
 internal RunningTestBuilder(RunningTest runningTest)
 {
     runningTest_ = runningTest;
 }