private void killInterpreterIfStillRunning(Thread t) {
   if (t.isAlive()) {
     log.error(
         "Scenario did not respond to thread.kill() after timeout, will now kill the interpreter");
     System.exit(1);
   }
 }
 private void stopThreadIfStillRunning(Thread t) {
   if (t.isAlive()) {
     log.error(
         "Scenario did not respond to interrupt after timeout, "
             + "will stop the interpreter thread and fail the tests");
     t.stop(); // this will trigger a ThreadDeath exception which we should allow to propagate
     // and will terminate the interpreter
   }
 }
 public void runFeatures(ExecutionToken executionToken, List<FeatureToken> features) {
   // RUN EACH FEATURE
   for (FeatureToken feature : features) {
     try {
       runFeature(executionToken, feature);
     } catch (Throwable t) {
       log.error("Exception while running feature " + feature, t);
       executionToken.incrementFeaturesFailed();
     }
   }
 }
  private void runFeature(ExecutionToken executionToken, FeatureToken feature) {

    executionListenerSupport.notifyFeatureStarted(executionToken, feature);
    // notify we started, even if there are missing handlers
    // (but nothing will be done)
    // this is still important so execution listeners at least see the feature (but will show as
    // 'unimplemented')
    String config = feature.isConfiguration() ? " in config " + feature.getConfigurationName() : "";
    log.info("Running feature from file: " + feature.getFeatureFile() + config);

    // check that the required handler classes are all available and list them in order of
    // precedence
    List<Class> orderedHandlerClasses = new ArrayList<>();
    StringBuilder unavailableHandlersMessage =
        handlerClassDiscovery.findHandlerClasses(allHandlerClasses, feature, orderedHandlerClasses);
    boolean foundAllHandlerClasses = unavailableHandlersMessage.length() == 0;

    // run the scenarios in the feature
    if (foundAllHandlerClasses) {
      log.debug("The following handlers will be used " + orderedHandlerClasses);
      List<ScenarioToken> scenarios = feature.getScenarios();

      try {
        HandlerManager handlerManager =
            new HandlerManager(
                feature,
                orderedHandlerClasses,
                springContextSupport,
                subsystemManager,
                executionToken.getProfile());
        handlerManager.createFeatureScopedHandlers();
        handlerManager.processStartOfFeature();

        runScenarios(executionToken, feature, scenarios, handlerManager);

        handlerManager.processEndOfFeature();
      } catch (Exception e) {
        log.error("Exception while running feature " + feature.getName(), e);
      }

      String description =
          feature.getEndState() == EndState.PASSED
              ? " passed! "
              : feature.getEndState() == EndState.PENDING ? " pending! " : " failed! ";
      log.trace("The feature " + description);

      if (feature.getEndState() == EndState.PASSED) {
        executionToken.incrementFeaturesPassed();
      } else if (feature.getEndState() == EndState.PENDING) {
        executionToken.incrementFeaturesPending();
      } else {
        executionToken.incrementFeaturesFailed();
      }
    } else {
      log.warn(
          "The following handlers were not available, failing feature "
              + feature.getName()
              + " "
              + unavailableHandlersMessage);
      feature.setUnavailableHandlersMessage(unavailableHandlersMessage.toString());
      executionToken.incrementUnavailableHandlers();
      executionToken.incrementFeaturesFailed();
    }

    executionListenerSupport.notifyFeatureCompleted(executionToken, feature);
  }