/** * Is there time to execute a test case? * This not only depends on which phase we are in, but * also on how maximum long a test case can be left run * before trying to kill its threads if timeout. * * @return */ public synchronized boolean hasTimeToExecuteATestCase(){ return isThereStillTimeInThisPhase(Properties.TIMEOUT); }
public synchronized boolean isThereStillTimeInThisPhase(){ return isThereStillTimeInThisPhase(1); }
private boolean isTimeoutReached() { return !TimeController.getInstance().isThereStillTimeInThisPhase(); }
private boolean isTimeoutReached() { return !TimeController.getInstance().isThereStillTimeInThisPhase(); }
private boolean isTimeoutReached() { return !TimeController.getInstance().isThereStillTimeInThisPhase(); }
@Override public void testStarted(Description description) throws Exception { if (TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.info("Not yet reached maximum time to carve unit tests - executing test with carver"); Capturer.startCapture(); } else { logger.info("Reached maximum time to carve unit tests - executing test without carver"); } }
public static void capture(final int captureId, final Object receiver, final String methodName, final String methodDesc, final Object[] methodParams) { try { if (isCapturing()) { //(currentLog) { setCapturing(false); if (logger.isDebugEnabled()) { logger.debug("Method call captured: captureId={} receiver={} type={} method={} methodDesc={} params={}", captureId, System.identityHashCode(receiver), receiver.getClass().getName(), methodName, methodDesc, Arrays.toString(methodParams)); } currentLog.log(captureId, receiver, methodName, methodDesc, methodParams); if(TimeController.getInstance().isThereStillTimeInThisPhase()) setCapturing(true); //} } } catch(Throwable t) { // TODO: Handle properly? logger.debug(t.toString()); } }
/** * Resets the classes passes in the list using the given class loader * * @param classesToReset * @param loader */ public void resetClasses(List<String> classesToReset, ClassLoader loader) { // try to reset each collected class ClassResetter.getInstance().setClassLoader(loader); long start = System.currentTimeMillis(); for (String className : classesToReset) { // re-initialization can be expensive long elapsed = System.currentTimeMillis() - start; if (!className.equals(Properties.TARGET_CLASS) && (!TimeController.getInstance().isThereStillTimeInThisPhase() || elapsed > Properties.TIMEOUT_RESET)) { // Note: we no longer cancel the class re-initialization since // it might leave the static data in an inconsistent state } resetClass(className); } }
while (!dependencies.isEmpty() && TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.debug("Dependencies left: {}", dependencies.size());
private static int checkAllTestsIfTime(List<TestCase> testCases, long delta) { if (TimeController.getInstance().hasTimeToExecuteATestCase() && TimeController.getInstance().isThereStillTimeInThisPhase(delta)) { return JUnitAnalyzer.handleTestsThatAreUnstable(testCases); } return 0; }
@Override public void testFinished(Description description) throws Exception { final CaptureLog log = Capturer.stopCapture(); if (TimeController.getInstance().isThereStillTimeInThisPhase()) { LoggingUtils.getEvoLogger().info(" - Carving test {}.{}", description.getClassName(), description.getMethodName()); this.processLog(description, log); } Capturer.clear(); }
if (!TimeController.getInstance().isThereStillTimeInThisPhase()) { Properties.USE_SEPARATE_CLASSLOADER = junitSeparateClassLoader; return; if (!TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.warn("JUnit checking timed out");
break; if(!TimeController.getInstance().isThereStillTimeInThisPhase()) break;
if (! TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.info("Reached maximum time to generate assertions!"); break;
if (! TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.warn("Reached maximum time to generate assertions, aborting assertion generation"); break;