diff options
author | Mike Krüger <mikkrg@microsoft.com> | 2018-11-06 17:12:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-06 17:12:58 +0300 |
commit | 54f76816e87b3cc3ada36205c803178c8917dfaf (patch) | |
tree | e79842b1d5934ae01e009cbdffa28a71cd335a1c /main/src/addins/MonoDevelop.UnitTesting | |
parent | a7b0aae880e51f9e2e70e48575f10b3fe0f6ec5d (diff) | |
parent | a07743ecfb92f6697b5fa4681875cd7952d73cdd (diff) |
Merge pull request #6405 from mono/master-vsts700296
Fixes VSTS User Story 700296: UnitTestService rebuilds tests multiple
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs index 9e6bf497ae..aaa2daa49d 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs @@ -49,7 +49,7 @@ namespace MonoDevelop.UnitTesting public static class UnitTestService { static ArrayList providers = new ArrayList (); - static UnitTest[] rootTests; + static UnitTest[] rootTests = Array.Empty<UnitTest> (); static UnitTestService () { @@ -321,13 +321,7 @@ namespace MonoDevelop.UnitTesting static void ProjectOperations_PackageReferencesModified(object sender, EventArgs e) { - throttling.Cancel (); - throttling = new CancellationTokenSource (); - Task.Delay (1000, throttling.Token).ContinueWith ((task) => { - if (task.IsCanceled) - return; - RebuildTests (); - }, throttling.Token, TaskContinuationOptions.None, Runtime.MainTaskScheduler); + RebuildTests (); } static bool IsSolutionGroupPresent (Solution sol, IEnumerable<UnitTest> tests) @@ -347,14 +341,21 @@ namespace MonoDevelop.UnitTesting static CancellationTokenSource rebuildTestsCts = new CancellationTokenSource (); - async static void RebuildTests () + const int ThrottlingTimeout = 2000; + + static async void RebuildTests () { + throttling.Cancel (); + throttling = new CancellationTokenSource (); try { + await Task.Delay (ThrottlingTimeout, throttling.Token); + if (throttling.Token.IsCancellationRequested) + return; + if (rootTests != null) { foreach (IDisposable t in rootTests) t.Dispose (); } - rootTests = Array.Empty<UnitTest> (); List<UnitTest> list = new List<UnitTest> (); rebuildTestsCts.Cancel (); rebuildTestsCts = new CancellationTokenSource (); |