Exemplo n.º 1
0
        public IAsyncOperation RunTest(UnitTest test, IExecutionHandler context, bool buildOwnerObject)
        {
            string testName = test.FullName;

            if (buildOwnerObject)
            {
                IBuildTarget bt = test.OwnerObject as IBuildTarget;
                if (bt != null && bt.NeedsBuilding(IdeApp.Workspace.ActiveConfiguration))
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted();
                    }

                    AsyncOperation retOper = new AsyncOperation();

                    IAsyncOperation op = IdeApp.ProjectOperations.Build(bt);
                    retOper.TrackOperation(op, false);

                    op.Completed += delegate {
                        // The completed event of the build operation is run in the gui thread,
                        // so we need a new thread, because refreshing must be async
                        System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                            if (op.Success)
                            {
                                RefreshTests();
                                test = SearchTest(testName);
                                if (test != null)
                                {
                                    Gtk.Application.Invoke(delegate {
                                        // RunTest must run in the gui thread
                                        retOper.TrackOperation(RunTest(test, context, false), true);
                                    });
                                }
                                else
                                {
                                    retOper.SetCompleted(false);
                                }
                            }
                        });
                    };

                    return(retOper);
                }
            }

            Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.NUnit.TestResultsPad", GettextCatalog.GetString("Test results"), "Bottom", "md-solution");
            }

            resultsPad.BringToFront();
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content);

            session.Start();
            return(session);
        }
Exemplo n.º 2
0
        internal static CheckResult CheckBeforeDebugging(IBuildTarget target)
        {
            if (IdeApp.Preferences.BuildBeforeExecuting)
            {
                return(CheckResult.BuildBeforeRun);
            }

            if (!target.NeedsBuilding(IdeApp.Workspace.ActiveConfiguration))
            {
                return(CheckResult.Run);
            }

            AlertButton bBuild = new AlertButton(GettextCatalog.GetString("Build"));
            AlertButton bRun   = new AlertButton(Gtk.Stock.Execute, true);
            AlertButton res    = MessageService.AskQuestion(
                GettextCatalog.GetString("Outdated Debug Information"),
                GettextCatalog.GetString("The project you are executing has changes done after the last time it was compiled. The debug information may be outdated. Do you want to continue?"),
                2,
                AlertButton.Cancel,
                bBuild,
                bRun);

            // This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
            // drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
            DispatchService.RunPendingEvents();

            if (res == AlertButton.Cancel)
            {
                return(CheckResult.Cancel);
            }
            else if (res == bRun)
            {
                return(CheckResult.Run);
            }
            else
            {
                return(CheckResult.BuildBeforeRun);
            }
        }
Exemplo n.º 3
0
		internal static CheckResult CheckBeforeDebugging (IBuildTarget target)
		{
			if (IdeApp.Preferences.BuildBeforeExecuting)
				return CheckResult.BuildBeforeRun;
			
			if (!target.NeedsBuilding (IdeApp.Workspace.ActiveConfiguration))
				return CheckResult.Run;
			
			AlertButton bBuild = new AlertButton (GettextCatalog.GetString ("Build"));
			AlertButton bRun = new AlertButton (Gtk.Stock.Execute, true);
			AlertButton res = MessageService.AskQuestion (
			                                 GettextCatalog.GetString ("Outdated Debug Information"), 
			                                 GettextCatalog.GetString ("The project you are executing has changes done after the last time it was compiled. The debug information may be outdated. Do you want to continue?"),
			                                 2,
			                                 AlertButton.Cancel,
			                                 bBuild,
			                                 bRun);

			// This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
			// drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
			DispatchService.RunPendingEvents ();

			if (res == AlertButton.Cancel)
				return CheckResult.Cancel;

			if (res == bRun)
				return CheckResult.Run;

			return CheckResult.BuildBeforeRun;
		}
Exemplo n.º 4
0
        internal IAsyncOperation RunTest(UnitTest test, IExecutionHandler context, bool buildOwnerObject, bool checkCurrentRunOperation)
        {
            string testName = test.FullName;

            if (buildOwnerObject)
            {
                IBuildTarget bt = test.OwnerObject as IBuildTarget;
                if (bt != null && bt.NeedsBuilding(IdeApp.Workspace.ActiveConfiguration))
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted();
                    }

                    AsyncOperation retOper = new AsyncOperation();

                    IAsyncOperation op = IdeApp.ProjectOperations.Build(bt);
                    retOper.TrackOperation(op, false);

                    op.Completed += delegate {
                        // The completed event of the build operation is run in the gui thread,
                        // so we need a new thread, because refreshing must be async
                        System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                            if (op.Success)
                            {
                                RefreshTests();
                                test = SearchTest(testName);
                                if (test != null)
                                {
                                    Gtk.Application.Invoke(delegate {
                                        // RunTest must run in the gui thread
                                        retOper.TrackOperation(RunTest(test, context, false), true);
                                    });
                                }
                                else
                                {
                                    retOper.SetCompleted(false);
                                }
                            }
                        });
                    };

                    return(retOper);
                }
            }

            if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation())
            {
                return(NullProcessAsyncOperation.Failure);
            }

            Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.NUnit.TestResultsPad", GettextCatalog.GetString("Test results"), "Bottom", "md-solution");
            }

            // Make the pad sticky while the tests are runnig, so the results pad is always visible (even if minimized)
            // That's required since when running in debug mode, the layout is automatically switched to debug.

            resultsPad.Sticky = true;
            resultsPad.BringToFront();

            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content);

            session.Completed += delegate {
                Gtk.Application.Invoke(delegate {
                    resultsPad.Sticky = false;
                });
            };

            OnTestSessionStarting(new TestSessionEventArgs {
                Session = session, Test = test
            });

            session.Start();

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.CurrentRunOperation = session;
            }

            return(session);
        }