Exemplo n.º 1
0
        static void RunPreload(string pathToAssemblies)
        {
            mLog.Debug("Preload started. Path To assemblies:" + pathToAssemblies);
            InitServices.InitNUnitServices();

            PNUnitTestRunner runner = new PNUnitTestRunner(pathToAssemblies);

            runner.Preload();

            int pidOfThisExpectedByAgent = Codice.Test.PlatformIdentifier.IsWindows() ?
                                           System.Diagnostics.Process.GetCurrentProcess().Id :
                                           Mono.Unix.UnixEnvironment.GetParentProcessId();

            string testInfoFile = Path.Combine(
                Path.GetTempPath(),
                PNUnit.Agent.AssemblyPreload.PRELOADED_PROCESS_FILE_PREFIX + pidOfThisExpectedByAgent.ToString());

            int count = 0;

            while (!File.Exists(testInfoFile))
            {
                System.Threading.Thread.Sleep(150);
                mLog.DebugFormat("Waiting for testinfo file to be created...: {0}", testInfoFile);

                count++;

                if (count >= 6000) //wait 1,5 minutes for test arrival
                {
                    mLog.Fatal("Tired of waiting: Cannot execute tests without information; exiting ...");
                    Environment.Exit(1);
                }
            }

            mLog.DebugFormat("Preload read {0} from file", testInfoFile);

            PNUnitTestInfo info = TestInfoReader.ReadTestInfo(testInfoFile);

            if (info == null)
            {
                mLog.Fatal("Cannot execute tests without information; exiting ...");
                Environment.Exit(1);
            }

            ProcessNameSetter.SetProcessName(info.TestName);

            IPNUnitServices services =
                PNUnitServices.GetPNunitServicesProxy(info.PNUnitServicesServer);

            runner.Run(info, services, null);
        }