Beispiel #1
0
        public void Start()
        {
            NTrace.Info("Starting");
            this.channel = ServerUtilities.GetTcpChannel();
            NTrace.Debug("Acquired Tcp Channel");

            try
            {
                this.agency = (TestAgency)Activator.GetObject(typeof(TestAgency), agencyUrl);
                NTrace.DebugFormat("Connected to TestAgency at {0}", agencyUrl);
            }
            catch (Exception ex)
            {
                NTrace.ErrorFormat("Unable to connect to test agency at {0}", agencyUrl);
                NTrace.Error(ex.Message);
            }

            try
            {
                this.agency.Register(this, ProcessId);
                NTrace.Debug("Registered with TestAgency");
            }
            catch (Exception ex)
            {
                NTrace.Error("Failed to register with TestAgency", ex);
            }
        }
Beispiel #2
0
        public virtual void Start()
        {
            if (uri != null && uri != string.Empty)
            {
                lock ( theLock )
                {
                    this.channel = ServerUtilities.GetTcpChannel(uri + "Channel", port, 100);

                    RemotingServices.Marshal(this, uri);
                    this.isMarshalled = true;
                }
            }
        }
        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);
        }
Beispiel #4
0
        public virtual void Start()
        {
            if (uri != null && uri != string.Empty)
            {
                lock (theLock)
                {
                    this.channel = ServerUtilities.GetTcpChannel(uri + "Channel", port, 100);

                    RemotingServices.Marshal(this, uri);
                    this.isMarshalled = true;
                }

                if (this.port == 0)
                {
                    ChannelDataStore store = this.channel.ChannelData as ChannelDataStore;
                    if (store != null)
                    {
                        string channelUri = store.ChannelUris[0];
                        this.port = int.Parse(channelUri.Substring(channelUri.LastIndexOf(':') + 1));
                    }
                }
            }
        }
Beispiel #5
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);
        }