Ejemplo n.º 1
0
  @TaskAction
  public void executeTests() {
    for (LogLevel level : LogLevel.values()) {
      if (!LOGGER.isEnabled(level)) {
        continue;
      }
      TestLogging levelLogging = testLogging.get(level);
      TestExceptionFormatter exceptionFormatter = getExceptionFormatter(testLogging);
      TestEventLogger eventLogger =
          new TestEventLogger(outputListener, level, levelLogging, exceptionFormatter);
      addTestListener(eventLogger);
      addTestOutputListener(eventLogger);
    }

    ProgressLoggerFactory progressLoggerFactory = getServices().get(ProgressLoggerFactory.class);
    TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory);
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor =
        new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());
    testExecuter.execute(this, resultProcessor);

    testFramework.report();

    testFramework = null;

    if (!getIgnoreFailures() && testCountLogger.hadFailures()) {
      throw new GradleException(
          "There were failing tests. See the report at " + getTestReportUrl() + ".");
    }
  }
Ejemplo n.º 2
0
 // only way I know of to determine current log level
 private LogLevel getCurrentLogLevel() {
   for (LogLevel level : LogLevel.values()) {
     if (getLogger().isEnabled(level)) {
       return level;
     }
   }
   throw new AssertionError("could not determine current log level");
 }
Ejemplo n.º 3
0
    private LogLevelWrapper(LogLevel logLevel) {
      this.logLevel = logLevel;

      String temp =
          logLevel
              .toString()
              .toLowerCase()
              .replace('_', ' '); // replace underscores in the name with spaces
      this.toString = Character.toUpperCase(temp.charAt(0)) + temp.substring(1);

      // add the command line character to the end (so if an error message says use a log level, you
      // can easily translate)
      String commandLineCharacter =
          new LoggingCommandLineConverter().getLogLevelCommandLine(logLevel);
      if (commandLineCharacter != null && !commandLineCharacter.equals("")) {
        this.toString += " (-" + commandLineCharacter + ")";
      }
    }
Ejemplo n.º 4
0
  /** Creates a panel that has a combo box to select a log level */
  private Component createLogLevelPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    logLevelComboBox = new JComboBox(getLogLevelWrappers());

    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Log Level")));
    panel.add(Utility.addLeftJustifiedComponent(logLevelComboBox));

    // initialize our value
    String logLevelName = settingsNode.getValueOfChild(LOG_LEVEL, null);
    LogLevel logLevel = gradlePluginLord.getLogLevel();
    if (logLevelName != null) {
      try {
        logLevel = LogLevel.valueOf(logLevelName);
      } catch (
          IllegalArgumentException
              e) // this may happen if the enum changes. We don't want this to stop the whole UI
      {
        logger.error("Converting log level text to log level enum '" + logLevelName + "'", e);
      }
    }

    gradlePluginLord.setLogLevel(logLevel);
    setLogLevelComboBoxSetting(logLevel);

    logLevelComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            LogLevelWrapper wrapper = (LogLevelWrapper) logLevelComboBox.getSelectedItem();
            if (wrapper != null) {
              gradlePluginLord.setLogLevel(wrapper.logLevel);
              settingsNode.setValueOfChild(LOG_LEVEL, wrapper.logLevel.name());
            }
          }
        });

    return panel;
  }
 private boolean isLevelAtMost(LogLevel levelLimit) {
   return levelLimit.compareTo(context.getLevel()) >= 0;
 }