diff options
author | Keting Yang <ketyang@microsoft.com> | 2019-09-17 16:38:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 16:38:05 +0300 |
commit | 1abc0b5c2336147e0cbeca63a068fd006e71b00b (patch) | |
tree | 237b49967bd43c64fe1d9bbe91d45e85ae425676 /main | |
parent | 8f5ff39d3625dfb56c420c6f9f46dab1766e4aab (diff) | |
parent | 358ee0bcb03493a33f4d5bbd686589085a0f253c (diff) |
Merge pull request #8424 from mono/vsts-802586-debug-all-tests
[Debugger] Add Debug All Test command
Diffstat (limited to 'main')
21 files changed, 114 insertions, 14 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs b/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs index 6d0a84150d..7c1b64b284 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs @@ -29,6 +29,7 @@ using MonoDevelop.Components.Commands; using MonoDevelop.Projects; using MonoDevelop.Ide; +using MonoDevelop.Core; namespace MonoDevelop.UnitTesting.Commands { @@ -43,6 +44,7 @@ namespace MonoDevelop.UnitTesting.Commands ShowTestDetails, GoToFailure, RerunTest, + DebugAllTests, } public enum TestChartCommands @@ -72,7 +74,7 @@ namespace MonoDevelop.UnitTesting.Commands { protected override void Run () { - WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject; + SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder; if (ob != null) { UnitTest test = UnitTestService.FindRootTest (ob); if (test != null) @@ -82,7 +84,45 @@ namespace MonoDevelop.UnitTesting.Commands protected override void Update (CommandInfo info) { - WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject; + SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder; + if (ob != null) { + UnitTest test = UnitTestService.FindRootTest (ob); + info.Enabled = (test != null); + } else + info.Enabled = false; + } + } + + class DebugAllTestsHandler : CommandHandler + { + protected async override void Run () + { + SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder; + if (ob != null) { + var testGroup = UnitTestService.FindRootTest (ob) as UnitTestGroup; + var tests = testGroup.Tests; + if (tests == null) + return; + + var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode (); + if (debugModeSet == null) + return; + + foreach (UnitTest test in tests) { + foreach (var mode in debugModeSet.ExecutionModes) { + if (test.CanRun (mode.ExecutionHandler)) { + ExecutionContext context = new ExecutionContext (mode.ExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null); + await UnitTestService.RunTests (new UnitTest [] { test }, context, true).Task; + continue; + } + } + } + } + } + + protected override void Update (CommandInfo info) + { + SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder; if (ob != null) { UnitTest test = UnitTestService.FindRootTest (ob); info.Enabled = (test != null); diff --git a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs index 235d0213f1..5b26fa011a 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs @@ -82,7 +82,7 @@ namespace MonoDevelop.UnitTesting ArrayList testNavigationHistory = new ArrayList (); - Button buttonRunAll, buttonStop; + Button buttonRunAll, buttonStop,buttonDebugAll; public override void Initialize (NodeBuilder[] builders, TreePadOption[] options, string menuPath) { @@ -94,10 +94,7 @@ namespace MonoDevelop.UnitTesting VBox vbox = new VBox (); DockItemToolbar topToolbar = Window.GetToolbar (DockPositionType.Top); - var hbox = new HBox { Spacing = 6 }; - hbox.PackStart (new ImageView (ImageService.GetIcon ("md-execute-all", IconSize.Menu)), false, false, 0); - hbox.PackStart (new Label (GettextCatalog.GetString ("Run All")), false, false, 0); - buttonRunAll = new Button (hbox); + buttonRunAll = new Button (new ImageView (ImageService.GetIcon ("md-execute-all", IconSize.Menu))); buttonRunAll.Accessible.Name = "TestPad.RunAll"; buttonRunAll.Accessible.Description = GettextCatalog.GetString ("Start a test run and run all the tests"); buttonRunAll.Clicked += new EventHandler (OnRunAllClicked); @@ -105,6 +102,14 @@ namespace MonoDevelop.UnitTesting buttonRunAll.TooltipText = GettextCatalog.GetString ("Run all tests"); topToolbar.Add (buttonRunAll); + buttonDebugAll = new Button (new ImageView (ImageService.GetIcon ("md-debug-all", IconSize.Menu))); + buttonDebugAll.Accessible.Name = "TestPad.DebugAll"; + buttonDebugAll.Accessible.Description = GettextCatalog.GetString ("Debug all the tests"); + buttonDebugAll.Clicked += new EventHandler (OnDebugAllClicked); + buttonDebugAll.Sensitive = true; + buttonDebugAll.TooltipText = GettextCatalog.GetString ("Debug all tests"); + topToolbar.Add (buttonDebugAll); + buttonStop = new Button (new ImageView (Ide.Gui.Stock.Stop, IconSize.Menu)); buttonStop.Clicked += new EventHandler (OnStopClicked); buttonStop.Sensitive = false; @@ -485,7 +490,7 @@ namespace MonoDevelop.UnitTesting } void StopRunningTests () - {
+ { if (runningTestOperation != null) runningTestOperation.Cancel (); } @@ -537,6 +542,7 @@ namespace MonoDevelop.UnitTesting UnitTestService.ResetResult (test.RootTest); this.buttonRunAll.Sensitive = false; + this.buttonDebugAll.Sensitive = false; this.buttonStop.Sensitive = true; ExecutionContext context = new ExecutionContext (mode, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null); @@ -553,7 +559,39 @@ namespace MonoDevelop.UnitTesting { RunTest (TreeView.GetRootNode (), null); } - + + async void OnDebugAllClicked (object sender, EventArgs args) + { + var nav = TreeView.GetRootNode (); + if (nav == null) + return; + + var testGroup = nav.DataItem as UnitTestGroup; + var tests = testGroup.Tests; + if (tests == null) + return; + + var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode (); + if (debugModeSet == null) + return; + + this.buttonRunAll.Sensitive = false; + this.buttonDebugAll.Sensitive = false; + this.buttonStop.Sensitive = true; + + foreach (UnitTest test in tests) { + foreach (var mode in debugModeSet.ExecutionModes) { + if (test.CanRun (mode.ExecutionHandler)) { + ExecutionContext context = new ExecutionContext (mode.ExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null); + await UnitTestService.RunTests (new UnitTest [] { test }, context, true).Task; + continue; + } + } + } + + OnTestSessionCompleted (); + } + void RunSelectedTest (IExecutionHandler mode) { RunTests (TreeView.GetSelectedNodes (), mode); @@ -565,6 +603,7 @@ namespace MonoDevelop.UnitTesting runningTestOperation = null; this.buttonRunAll.Sensitive = true; this.buttonStop.Sensitive = false; + this.buttonDebugAll.Sensitive = true; } @@ -964,19 +1003,19 @@ namespace MonoDevelop.UnitTesting protected override bool OnExposeEvent (Gdk.EventExpose args) { - using (Gdk.GC gc = new Gdk.GC (GdkWindow)) {
- gc.ClipRectangle = Allocation;
+ using (Gdk.GC gc = new Gdk.GC (GdkWindow)) { + gc.ClipRectangle = Allocation; GdkWindow.DrawLayout (gc, padding, padding, layout); } return true; } - protected override void OnDestroyed ()
+ protected override void OnDestroyed () { if (layout != null) { layout.Dispose (); layout = null; - }
- base.OnDestroyed ();
+ } + base.OnDestroyed (); } } } diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml index 4fd591a678..c09038a505 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml @@ -62,6 +62,10 @@ <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.DebugTest" _label = "Debug Test" type="array" /> + <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.DebugAllTests" + _label = "Debug All Tests" + _description="Debug all tests of the current selected project." + defaultHandler="MonoDevelop.UnitTesting.Commands.DebugAllTestsHandler"/> <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.RunTest" _label = "Run Test" /> <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.ShowTestCode" _label = "Show test source code" /> <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.GoToFailure" _label = "Go to failure" /> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml index 8662e41e90..4ce8f48003 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml @@ -99,6 +99,7 @@ <StockIcon stockid="md-command" resource="command-16.png" size="Menu" /> <StockIcon stockid="md-comment" resource="comment-16.png" size="Menu" /> <StockIcon stockid="md-console" resource="pad-application-output-16.png" size="Menu" /> + <StockIcon stockid="md-debug-all" resource="debug-all-16.png" size="Menu" /> <StockIcon stockid="md-delegate" resource="element-delegate-16.png" size="Menu" imageid="909;910;911;912;913;914" /> <StockIcon stockid="md-delete" resource="remove-16.png" size="Menu" /> <StockIcon stockid="md-delete-simple" resource="remove-simple-16.png" size="Menu" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index b40e1d2fcd..0c471f9ea1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -1030,6 +1030,14 @@ <EmbeddedResource Include="icons\tabbar-menu-hover-12%402x.png" /> <EmbeddedResource Include="icons\tabbar-menu-hover-12~dark.png" /> <EmbeddedResource Include="icons\tabbar-menu-hover-12~dark%402x.png" /> + <EmbeddedResource Include="icons\test-failed-16.png" /> + <EmbeddedResource Include="icons\test-failed-16%402x.png" /> + <EmbeddedResource Include="icons\test-failed-16~dark.png" /> + <EmbeddedResource Include="icons\test-failed-16~dark%402x.png" /> + <EmbeddedResource Include="icons\test-failed-16~dark~sel.png" /> + <EmbeddedResource Include="icons\test-failed-16~dark~sel%402x.png" /> + <EmbeddedResource Include="icons\test-failed-16~sel.png" /> + <EmbeddedResource Include="icons\test-failed-16~sel%402x.png" /> <EmbeddedResource Include="icons\breadcrumb-prev-16.png" /> <EmbeddedResource Include="icons\breadcrumb-prev-16%402x.png" /> <EmbeddedResource Include="icons\breadcrumb-prev-16~dark.png" /> @@ -2746,6 +2754,14 @@ <EmbeddedResource Include="icons\checkmark-16~sel%402x.png" /> <EmbeddedResource Include="icons\checkmark-16~dark~sel.png" /> <EmbeddedResource Include="icons\checkmark-16~dark~sel%402x.png" /> + <EmbeddedResource Include="icons\debug-all-16.png" /> + <EmbeddedResource Include="icons\debug-all-16%402x.png" /> + <EmbeddedResource Include="icons\debug-all-16~dark.png" /> + <EmbeddedResource Include="icons\debug-all-16~dark%402x.png" /> + <EmbeddedResource Include="icons\debug-all-16~dark~sel.png" /> + <EmbeddedResource Include="icons\debug-all-16~dark~sel%402x.png" /> + <EmbeddedResource Include="icons\debug-all-16~sel.png" /> + <EmbeddedResource Include="icons\debug-all-16~sel%402x.png" /> <EmbeddedResource Include="icons\dependency-16.png" /> <EmbeddedResource Include="icons\dependency-16%402x.png" /> <EmbeddedResource Include="icons\dependency-16~dark.png" /> diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16.png Binary files differnew file mode 100755 index 0000000000..f1c6f8f57d --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16@2x.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16@2x.png Binary files differnew file mode 100755 index 0000000000..c0234c6f3c --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark.png Binary files differnew file mode 100755 index 0000000000..c13b3db8c3 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark@2x.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark@2x.png Binary files differnew file mode 100755 index 0000000000..b7fdf50950 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel.png Binary files differnew file mode 100755 index 0000000000..0008cfd57f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel@2x.png Binary files differnew file mode 100755 index 0000000000..048a93893f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~dark~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel.png Binary files differnew file mode 100755 index 0000000000..0008cfd57f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel@2x.png Binary files differnew file mode 100755 index 0000000000..048a93893f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/debug-all-16~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16.png Binary files differnew file mode 100755 index 0000000000..85a7bd54bf --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16@2x.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16@2x.png Binary files differnew file mode 100755 index 0000000000..c83516c7a4 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark.png Binary files differnew file mode 100755 index 0000000000..28daa2158a --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark@2x.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark@2x.png Binary files differnew file mode 100755 index 0000000000..a41e5bc120 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel.png Binary files differnew file mode 100755 index 0000000000..83656b0ac9 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel@2x.png Binary files differnew file mode 100755 index 0000000000..fc86f87a4a --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~dark~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel.png Binary files differnew file mode 100755 index 0000000000..83656b0ac9 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel@2x.png Binary files differnew file mode 100755 index 0000000000..fc86f87a4a --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/test-failed-16~sel@2x.png |