private int LaunchAgentProcess()
        {
            //ProcessStartInfo startInfo = new ProcessStartInfo( TestAgentExePath, ServerUtilities.MakeUrl( this.uri, this.port ) );
            //startInfo.CreateNoWindow = true;
            Process p = new Process();

            if (Type.GetType("Mono.Runtime", false) != null)
            {
                p.StartInfo.FileName  = @"C:\Program Files\mono-1.2.5\bin\mono.exe";
                p.StartInfo.Arguments = TestAgentExePath + " " + ServerUtilities.MakeUrl(this.uri, this.port);
            }
            else
            {
                p.StartInfo.FileName  = TestAgentExePath;
                p.StartInfo.Arguments = ServerUtilities.MakeUrl(this.uri, this.port);
            }

            //NTrace.Debug( "Launching {0}" p.StartInfo.FileName );
            p.Start();
            agentData.Add(new AgentRecord(p.Id, p, null, AgentStatus.Starting));
            return(p.Id);
        }
Example #2
0
        //public void DestroyAgent( ITestAgent agent )
        //{
        //    AgentRecord r = agentData[agent.Id];
        //    if ( r != null )
        //    {
        //        if( !r.Process.HasExited )
        //            r.Agent.Stop();
        //        agentData[r.Id] = null;
        //    }
        //}
        #endregion

        #region Helper Methods
        private Guid LaunchAgentProcess(RuntimeFramework targetRuntime)
        {
            string agentExePath = NUnitConfiguration.GetTestAgentExePath(targetRuntime.Version);

            if (agentExePath == null)
            {
                throw new ArgumentException(
                          string.Format("NUnit components for version {0} of the CLR are not installed",
                                        targetRuntime.Version.ToString(3)), "targetRuntime");
            }

            // TODO: Replace adhoc code
            //if (targetRuntime.Version.Major == 1 && RuntimeFramework.CurrentFramework.Version.Major == 2)
            //{
            //    agentExePath = agentExePath
            //        .Replace("2.0", "1.1")
            //        .Replace("vs2008", "vs2003")
            //        .Replace("vs2005", "vs2003");
            //}
            //else if (targetRuntime.Version.Major == 2 && RuntimeFramework.CurrentFramework.Version.Major == 1)
            //{
            //    agentExePath = agentExePath
            //        .Replace("1.1", "2.0")
            //        .Replace("1.0", "2.0")
            //        .Replace("vs2003", "vs2008");
            //}

            log.Debug("Using nunit-agent at " + agentExePath);

            Process p = new Process();

            p.StartInfo.UseShellExecute = false;
            Guid   agentId = Guid.NewGuid();
            string arglist = agentId.ToString() + " " + ServerUtilities.MakeUrl(this.uri, this.port);

            switch (targetRuntime.Runtime)
            {
            case RuntimeType.Mono:
                // TODO: Replace hard-coded path
                p.StartInfo.FileName  = NUnitConfiguration.MonoExePath;
                p.StartInfo.Arguments = string.Format("\"{0}\" {1}", agentExePath, arglist);
                break;

            case RuntimeType.Net:
                p.StartInfo.FileName = agentExePath;
                if (targetRuntime.Version == new Version("1.0.3705"))
                {
                    p.StartInfo.EnvironmentVariables["COMPLUS_Version"] = "v1.0.3705";
                }
                p.StartInfo.Arguments = arglist;
                break;

            default:
                p.StartInfo.FileName  = agentExePath;
                p.StartInfo.Arguments = arglist;
                break;
            }

            //p.Exited += new EventHandler(OnProcessExit);
            p.Start();
            log.Info("Launched Agent process {0} - see nunit-agent_{0}.log", p.Id);
            log.Info("Command line: \"{0}\" {1}", p.StartInfo.FileName, p.StartInfo.Arguments);

            agentData.Add(new AgentRecord(agentId, p, null, AgentStatus.Starting));
            return(agentId);
        }