Example #1
0
 public List<String> getRawSelectors() {
   List<String> rawSelectors = new ArrayList<>();
   for (TestSelector testSelector : testSelectors) {
     String rawSelector = testSelector.getRawSelector();
     rawSelectors.add(rawSelector);
   }
   return rawSelectors;
 }
Example #2
0
  public boolean isIncluded(TestDescription description) {
    for (TestSelector testSelector : testSelectors) {
      if (testSelector.matches(description)) {
        return testSelector.isInclusive();
      }
    }

    return defaultIsInclusive;
  }
Example #3
0
 public TestSelectorList build() {
   // Default to being inclusive only if all selectors are *exclusive*.
   boolean defaultIsInclusive = true;
   for (TestSelector testSelector : testSelectors) {
     if (testSelector.isInclusive()) {
       defaultIsInclusive = false;
       break;
     }
   }
   return new TestSelectorList(testSelectors, defaultIsInclusive);
 }
 protected void keyPressed(int keyCode) {
   switch (keyCode) {
     case '0':
       logScrollBottom();
       break;
     case '3':
       TestSelector.selectTest();
       break;
     case '*':
       Runnable r =
           new Runnable() {
             public void run() {
               TestSelector.runTest();
             }
           };
       ThreadUtils.invokeLater(r, "RunTests");
       break;
     case '1':
       runContinue();
       break;
     case '#':
       clearLog();
       break;
     default:
       logLinesMove(getGameAction(keyCode));
   }
   repaint();
 }
Example #5
0
 private Builder addRawSelector(String rawSelector) {
   if (rawSelector.charAt(0) == '@') {
     try {
       String pathString = rawSelector.substring(1);
       if (pathString.isEmpty()) {
         throw new TestSelectorParseException("Doesn't mention a path!");
       }
       File file = new File(pathString);
       loadFromFile(file);
     } catch (TestSelectorParseException | IOException e) {
       String message =
           String.format("Error with test-selector '%s': %s", rawSelector, e.getMessage());
       throw new RuntimeException(message, e);
     }
     return this;
   } else {
     TestSelector testSelector = TestSelector.buildFromSelectorString(rawSelector);
     this.testSelectors.add(testSelector);
   }
   return this;
 }
Example #6
0
  public List<String> getExplanation() {
    List<String> lines = new ArrayList<>();
    for (TestSelector testSelector : testSelectors) {
      lines.add(testSelector.getExplanation());
    }

    // If the last selector matches everything, derive our default behavior from that test selector
    // and replace the last line of explanation.
    int lastIndex = testSelectors.size() - 1;
    TestSelector lastTestSelector = testSelectors.get(lastIndex);
    if (lastTestSelector.isMatchAnyClass() && lastTestSelector.isMatchAnyMethod()) {
      String lastLine = formatEverythingElseLine(lastTestSelector.isInclusive());
      lines.set(lastIndex, lastLine);
    } else {
      // Otherwise describe our default behavior.
      lines.add(formatEverythingElseLine(defaultIsInclusive));
    }
    return lines;
  }