Prevents multiple continuous tests from running interleaved.
This commit is contained in:
parent
73c49b42c6
commit
3dcbb78204
|
@ -13,6 +13,7 @@ namespace ContinuousTests
|
|||
private readonly StartupChecker startupChecker;
|
||||
private readonly CancellationToken cancelToken;
|
||||
private readonly EventWaitHandle runFinishedHandle = new EventWaitHandle(true, EventResetMode.ManualReset);
|
||||
private static object testLock = new object();
|
||||
|
||||
public TestLoop(EntryPointFactory entryPointFactory, TaskFactory taskFactory, Configuration config, ILog overviewLog, Type testType, TimeSpan runsEvery, StartupChecker startupChecker, CancellationToken cancelToken)
|
||||
{
|
||||
|
@ -40,6 +41,10 @@ namespace ContinuousTests
|
|||
NumberOfPasses = 0;
|
||||
NumberOfFailures = 0;
|
||||
while (!cancelToken.IsCancellationRequested)
|
||||
{
|
||||
lock (testLock)
|
||||
// In the original design, multiple tests are allowed to interleave their test-moments, increasing test through-put.
|
||||
// Since we're still stabilizing some of the basics, this lock limits us to 1 test run at a time.
|
||||
{
|
||||
WaitHandle.WaitAny(new[] { runFinishedHandle, cancelToken.WaitHandle });
|
||||
|
||||
|
@ -49,6 +54,8 @@ namespace ContinuousTests
|
|||
|
||||
cancelToken.WaitHandle.WaitOne(runsEvery);
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue