示例#1
0
        public string EnqueueTestPlan(string testPlanId, IDictionary <string, string> args)
        {
            // Create a new run
            string runId = results.CreateRun("Run at " + DateTime.Now.TimeOfDay);

            lock (queue)
            {
                queue.Add(delegate()
                {
                    SystemStatus stat = new SystemStatus();

                    stat.CurrentTestPlan = testPlanId;
                    stat.CurrentTestRun  = runId;
                    stat.MicroStatus     = "Initializing Test Plan";

                    UpdateStatus(stat);                         // Atomic

                    string testPlanCode;
                    using (Stream tpStream = testPlans.ReadTestPlan(testPlanId))
                    {
                        using (StreamReader reader = new StreamReader(tpStream))
                        {
                            testPlanCode = reader.ReadToEnd();
                        }
                    }

                    // Environment for this run
                    IJSTestProvider provider = new TestProvider(
                        machines.Drivers.SelectMany(d => d.Machines),
                        testDriverManager.Drivers,
                        results,
                        runId);

                    // Javascript runner
                    using (JSTestRunner runner = new JSTestRunner("TEST_INIT", args, provider))
                    {
                        try
                        {
                            stat.MicroStatus = "Running Test Plan";
                            UpdateStatus(stat);

                            // Run our javascript
                            runner.Execute(testPlanCode, new Dictionary <string, string>());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }


                        stat.MicroStatus = "Cleaning Up Snapshots";
                        UpdateStatus(stat);

                        // This will get run by the "using" block, regardless.
                        runner.CleanUp();
                    }

                    stat.CurrentTestPlan = null;
                    stat.CurrentTestRun  = null;
                    stat.CurrentMachine  = null;
                    stat.MicroStatus     = null;
                    UpdateStatus(stat);
                });
            }

            return(runId);
        }
        public string EnqueueTestPlan(string testPlanId, IDictionary<string, string> args)
        {
            // Create a new run
            string runId = results.CreateRun("Run at " + DateTime.Now.TimeOfDay);

            lock(queue)
            {
                queue.Add (delegate()
                {

                    SystemStatus stat = new SystemStatus();

                    stat.CurrentTestPlan = testPlanId;
                    stat.CurrentTestRun = runId;
                    stat.MicroStatus = "Initializing Test Plan";

                    UpdateStatus(stat);	// Atomic

                    string testPlanCode;
                    using(Stream tpStream = testPlans.ReadTestPlan(testPlanId))
                    {
                        using(StreamReader reader = new StreamReader(tpStream))
                        {
                            testPlanCode = reader.ReadToEnd();
                        }
                    }

                    // Environment for this run
                    IJSTestProvider provider = new TestProvider(
                        machines.Drivers.SelectMany (d => d.Machines),
                        testDriverManager.Drivers,
                        results,
                        runId);

                    // Javascript runner
                    using(JSTestRunner runner = new JSTestRunner("TEST_INIT", args, provider))
                    {
                        try
                        {
                            stat.MicroStatus = "Running Test Plan";
                            UpdateStatus(stat);

                            // Run our javascript
                            runner.Execute(testPlanCode, new Dictionary<string, string>());
                        }
                        catch(Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }

                        stat.MicroStatus = "Cleaning Up Snapshots";
                        UpdateStatus(stat);

                        // This will get run by the "using" block, regardless.
                        runner.CleanUp();
                    }

                    stat.CurrentTestPlan = null;
                    stat.CurrentTestRun = null;
                    stat.CurrentMachine = null;
                    stat.MicroStatus = null;
                    UpdateStatus(stat);
                });
            }

            return runId;
        }