Пример #1
0
        internal static async Task RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            if (buildOwnerObject)
            {
                var build_targets = new HashSet <IBuildTarget> ();
                foreach (var t in tests)
                {
                    if (t.OwnerObject is IBuildTarget bt)
                    {
                        build_targets.Add(bt);
                    }
                }

                var res = await IdeApp.ProjectOperations.CheckAndBuildForExecute(
                    build_targets, IdeApp.Workspace.ActiveConfiguration, IdeApp.Preferences.BuildBeforeRunningTests,
                    false, null, cs.Token);

                if (!res)
                {
                    return;
                }

                var test_names = new HashSet <string> (tests.Select((v) => v.FullName));

                await RefreshTests(cs.Token);

                tests = test_names.Select((fullName) => SearchTest(fullName)).Where((t) => t != null).ToList();

                if (tests.Any())
                {
                    await RunTests(tests, context, false, checkCurrentRunOperation, cs);
                }
                return;
            }

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

            Pad resultsPad = GetTestResultsPad();

            var         test    = tests.Count() == 1 ? tests.First() : new UnitTestSelection(tests, tests.First().OwnerObject);
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

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

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.AddRunOperation(session);
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
        internal static async Task RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            string testName = test.FullName;

            if (buildOwnerObject)
            {
                IBuildTarget bt = test.OwnerObject as IBuildTarget;
                if (bt != null)
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        await IdeApp.ProjectOperations.CurrentRunOperation.Task;
                    }

                    var res = await IdeApp.ProjectOperations.Build(bt, cs.Token).Task;

                    if (res.HasErrors)
                    {
                        return;
                    }

                    await RefreshTests(cs.Token);

                    test = SearchTest(testName);
                    if (test != null)
                    {
                        await RunTest(test, context, false, checkCurrentRunOperation, cs);
                    }
                    return;
                }
            }

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

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

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.UnitTesting.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, cs);

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

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

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
Пример #3
0
        internal static async Task RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            if (buildOwnerObject)
            {
                var build_targets = new HashSet <IBuildTarget> ();
                foreach (var t in tests)
                {
                    IBuildTarget bt = t.OwnerObject as IBuildTarget;
                    if (bt != null)
                    {
                        build_targets.Add(bt);
                    }
                }
                if (build_targets.Count > 0)
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        await IdeApp.ProjectOperations.CurrentRunOperation.Task;
                    }

                    foreach (var bt in build_targets)
                    {
                        var res = await IdeApp.ProjectOperations.Build(bt, cs.Token).Task;

                        if (res.HasErrors)
                        {
                            return;
                        }
                    }

                    var test_names = new HashSet <string> (tests.Select((v) => v.FullName));

                    await RefreshTests(cs.Token);

                    tests = test_names.Select((fullName) => SearchTest(fullName)).Where((t) => t != null).ToList();

                    if (tests.Any())
                    {
                        await RunTests(tests, context, false, checkCurrentRunOperation, cs);
                    }
                    return;
                }
            }

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

            Pad resultsPad = GetTestResultsPad();

            var         test    = tests.Count() == 1 ? tests.First() : new UnitTestSelection(tests, tests.First().OwnerObject);
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

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

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.AddRunOperation(session);
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
Пример #4
0
		internal static async Task RunTest (UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
		{
			string testName = test.FullName;
			
			if (buildOwnerObject) {
				IBuildTarget bt = test.OwnerObject as IBuildTarget;
				if (bt != null) {
					if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) {
						MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations ();
						await IdeApp.ProjectOperations.CurrentRunOperation.Task;
					}
	
					var res = await IdeApp.ProjectOperations.Build (bt, cs.Token).Task;
					if (res.HasErrors)
						return;

					await RefreshTests (cs.Token);
					test = SearchTest (testName);
					if (test != null)
						await RunTest (test, context, false, checkCurrentRunOperation, cs);
					return;
				}
			}
			
			if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation ())
				return;
			
			Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();
			if (resultsPad == null) {
				resultsPad = IdeApp.Workbench.ShowPad (new TestResultsPad (), "MonoDevelop.UnitTesting.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, cs);
			
			OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test });

			if (checkCurrentRunOperation)
				IdeApp.ProjectOperations.CurrentRunOperation = session;
			
			try {
				await session.Start ();
			} finally {
				resultsPad.Sticky = false;
			}
		}
Пример #5
0
        internal static async Task RunTests(IEnumerable <UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
        {
            if (buildOwnerObject)
            {
                var build_targets = new HashSet <IBuildTarget> ();
                foreach (var t in tests)
                {
                    IBuildTarget bt = t.OwnerObject as IBuildTarget;
                    if (bt != null)
                    {
                        build_targets.Add(bt);
                    }
                }
                if (build_targets.Count > 0)
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        await IdeApp.ProjectOperations.CurrentRunOperation.Task;
                    }

                    foreach (var bt in build_targets)
                    {
                        var res = await IdeApp.ProjectOperations.Build(bt, cs.Token).Task;

                        if (res.HasErrors)
                        {
                            return;
                        }
                    }

                    var test_names = new HashSet <string> (tests.Select((v) => v.FullName));

                    await RefreshTests(cs.Token);

                    tests = test_names.Select((fullName) => SearchTest(fullName)).Where((t) => t != null).ToList();

                    if (tests.Any())
                    {
                        await RunTests(tests, context, false, checkCurrentRunOperation, cs);
                    }
                    return;
                }
            }

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

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

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.UnitTesting.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();

            var         test    = tests.Count() == 1 ? tests.First() : new UnitTestSelection(tests, tests.First().OwnerObject);
            TestSession session = new TestSession(test, context, (TestResultsPad)resultsPad.Content, cs);

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

            if (checkCurrentRunOperation)
            {
                IdeApp.ProjectOperations.AddRunOperation(session);
            }

            try {
                await session.Start();
            } finally {
                resultsPad.Sticky = false;
            }
        }
Пример #6
0
		internal static async Task RunTests (IEnumerable<UnitTest> tests, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
		{
			if (buildOwnerObject) {
				var build_targets = new HashSet<IBuildTarget> ();
				foreach (var t in tests) {
					IBuildTarget bt = t.OwnerObject as IBuildTarget;
					if (bt != null)
						build_targets.Add (bt);
				}
				if (build_targets.Count > 0) {
					if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) {
						MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations ();
						await IdeApp.ProjectOperations.CurrentRunOperation.Task;
					}

					foreach (var bt in build_targets) {
						var res = await IdeApp.ProjectOperations.Build (bt, cs.Token).Task;
						if (res.HasErrors)
							return;
					}

					var test_names = new HashSet<string> (tests.Select ((v) => v.FullName));

					await RefreshTests (cs.Token);

					tests = test_names.Select ((fullName) => SearchTest (fullName)).Where ((t) => t != null).ToList ();

					if (tests.Any ())
						await RunTests (tests, context, false, checkCurrentRunOperation, cs);
					return;
				}
			}
			
			if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation ())
				return;
			
			Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();
			if (resultsPad == null) {
				resultsPad = IdeApp.Workbench.ShowPad (new TestResultsPad (), "MonoDevelop.UnitTesting.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 ();
			
			var test = tests.Count () == 1 ? tests.First () : new UnitTestSelection (tests, tests.First ().OwnerObject);
			TestSession session = new TestSession (test, context, (TestResultsPad) resultsPad.Content, cs);
			
			OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test });

			if (checkCurrentRunOperation)
				IdeApp.ProjectOperations.AddRunOperation (session);
			
			try {
				await session.Start ();
			} finally {
				resultsPad.Sticky = false;
			}
		}