From: Marek Safar Date: Tue, 24 Jun 2014 12:19:54 +0000 (+0200) Subject: [corlib] Fix racy test X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=a58aeafe1d3cc93dbb84e4b852dfda90cf466e8c;p=mono.git [corlib] Fix racy test --- diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs index a403d5287e2..b8fd573a366 100644 --- a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs @@ -102,6 +102,7 @@ namespace MonoTests.System.Runtime.CompilerServices string progress; SynchronizationContext sc; + ManualResetEvent mre; [SetUp] public void Setup () @@ -270,6 +271,7 @@ namespace MonoTests.System.Runtime.CompilerServices [Test] public void CompletionOnDifferentCustomSynchronizationContext () { + mre = new ManualResetEvent (false); progress = ""; var syncContext = new SingleThreadSynchronizationContext (); SynchronizationContext.SetSynchronizationContext (syncContext); @@ -293,14 +295,18 @@ namespace MonoTests.System.Runtime.CompilerServices { await Wait2 (ctx); - progress += "2"; + if (mre.WaitOne (5000)) + progress += "2"; } async Task Wait2 (SynchronizationContext ctx) { await Task.Delay (10); // Force block suspend/return - ctx.Post (l => progress += "3", null); + ctx.Post (l => { + progress += "3"; + mre.Set (); + }, null); progress += "1";