private boolean isTimeoutReached() { return !TimeController.getInstance().isThereStillTimeInThisPhase(); }
private boolean isTimeoutReached() { return !TimeController.getInstance().isThereStillTimeInThisPhase(); }
public static void resetSingleton(){ getInstance().init(); }
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"); } }
private static int checkAllTestsIfTime(List<TestCase> testCases, long delta) { if (TimeController.getInstance().hasTimeToExecuteATestCase() && TimeController.getInstance().isThereStillTimeInThisPhase(delta)) { return JUnitAnalyzer.handleTestsThatAreUnstable(testCases); } return 0; }
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()); } }
if(!TimeController.getInstance().hasTimeToExecuteATestCase()) { break;
@Override public void changeState(ClientState state, ClientStateInformation information) { if (this.state != state){ logger.info(ClientProcess.getPrettyPrintIdentifier() + "Client changing state from " + this.state + " to " + state); } this.state = state; TimeController.getInstance().updateState(state); try { masterNode.evosuite_informChangeOfStateInClient(clientRmiIdentifier, state,information); } catch (RemoteException e) { logger.error("Cannot inform master of change of state", e); } if (this.state.equals(ClientState.DONE)) { doneLatch.countDown(); } if (this.state.equals(ClientState.FINISHED)) { finishedLatch.countDown(); } }
/** * 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());
@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().hasTimeToExecuteATestCase()) { logger.error("Ran out of time while checking tests"); return numUnstable;
/** * Add assertions to all tests in a test suite * * @param suite */ public void addAssertions(TestSuiteChromosome suite) { setupClassLoader(suite); for(TestChromosome test : suite.getTestChromosomes()) { if(!TimeController.getInstance().hasTimeToExecuteATestCase()) break; addAssertions(test.getTestCase()); } }
if (!TimeController.getInstance().isThereStillTimeInThisPhase()) { Properties.USE_SEPARATE_CLASSLOADER = junitSeparateClassLoader; return; Iterator<TestCase> iter = testCases.iterator(); while (iter.hasNext()) { if (!TimeController.getInstance().hasTimeToExecuteATestCase()) { break; if (!TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.warn("JUnit checking timed out");
TestCase test = testCases.get(i); boolean added = false; if(!TimeController.getInstance().hasTimeToExecuteATestCase()) { logger.info("Using cached result"); for(ExecutionResult result : cachedResults) {
if (! TimeController.getInstance().isThereStillTimeInThisPhase()) { logger.warn("Reached maximum time to generate assertions, aborting assertion generation"); break; if(!timeIsShort && TimeController.getInstance().getPhasePercentage() > Properties.ASSERTION_MINIMIZATION_FALLBACK_TIME) { if(numTest < Properties.ASSERTION_MINIMIZATION_FALLBACK * suite.size()) { logger.warn("Assertion minimization is taking too long ({}% of time used, but only {}/{} tests minimized), falling back to using all assertions", TimeController.getInstance().getPhasePercentage(), numTest, suite.size()); timeIsShort = true;
TimeController.getInstance().getPhasePercentage() >= Properties.REFLECTION_START_PERCENT && Randomness.nextDouble() < Properties.P_REFLECTION_ON_PRIVATE){ return insertRandomReflectionCallOnObject(test, var, position, 0);
VariableReference ret = null; if( canUseFunctionalMocks && TimeController.getInstance().getPhasePercentage() >= Properties.FUNCTIONAL_MOCKING_PERCENT && Randomness.nextDouble() < Properties.P_FUNCTIONAL_MOCKING && FunctionalMockStatement.canBeFunctionalMocked(type)) {
TimeController.getInstance().getPhasePercentage() >= Properties.REFLECTION_START_PERCENT && (Randomness.nextDouble() < Properties.P_REFLECTION_ON_PRIVATE || TestCluster.getInstance().getNumTestCalls() == 0)){ logger.debug("Going to insert random reflection call");