private static Failure?RunToDone(IExecutionState state, uint maxTestIters, int testIndex, int testCount, ref long overflowIters) { // Clear completion indicator state.Done = false; // Run for max allowed number of lines var err1 = state.Run(maxTestIters, TimeSpan.FromMilliseconds(600)); if (err1 != null) { return(new Failure(FailureType.Other, err1)); } // This test case didn't finish yet, run it some more with the overflow pool if (!state.Done) { var executed = state.TotalLinesExecuted; var err2 = state.Run((uint)overflowIters, TimeSpan.FromMilliseconds(600)); if (err2 != null) { return(new Failure(FailureType.Other, err2)); } // Shrink the overflow pool by however many ticks that just used overflowIters -= (uint)(state.TotalLinesExecuted - executed); //Once the overflow pool is empty too, fail if (overflowIters <= 0 || !state.Done) { return(new Failure(FailureType.RuntimeTooLong, $"Completed {testIndex}/{testCount} tests.")); } } return(null); }