예제 #1
0
 /**
  * Gets the counter part of this {@link TestResult} in the specified run.
  *
  * @return null if no such counter part exists.
  */
 public TestResult getResultInBuild(AbstractBuild<?, ?> build) {
   AbstractTestResultAction tra = build.getAction(getParentAction().getClass());
   if (tra == null) {
     tra = build.getAction(AbstractTestResultAction.class);
   }
   return (tra == null) ? null : tra.findCorrespondingResult(this.getId());
 }
    /** Makes sure that the data fields are up to date. */
    private synchronized void upToDateCheck() {
      // up to date check
      if (lastUpdated > lastChanged) return;
      lastUpdated = lastChanged + 1;

      int failCount = 0;
      int totalCount = 0;
      List<AbstractTestResultAction> individuals = new ArrayList<AbstractTestResultAction>();
      List<AbstractProject> didntRun = new ArrayList<AbstractProject>();
      List<AbstractProject> noFingerprints = new ArrayList<AbstractProject>();
      for (AbstractProject job : getJobs()) {
        RangeSet rs = owner.getDownstreamRelationship(job);
        if (rs.isEmpty()) {
          // is this job expected to produce a test result?
          Run b;
          if (includeFailedBuilds) {
            b = job.getLastBuild();
          } else {
            b = job.getLastSuccessfulBuild();
          }
          if (b != null && b.getAction(AbstractTestResultAction.class) != null) {
            if (b.getAction(FingerprintAction.class) != null) {
              didntRun.add(job);
            } else {
              noFingerprints.add(job);
            }
          }
        } else {
          for (int n : rs.listNumbersReverse()) {
            Run b = job.getBuildByNumber(n);
            if (b == null) continue;
            Result targetResult;
            if (includeFailedBuilds) {
              targetResult = Result.FAILURE;
            } else {
              targetResult = Result.UNSTABLE;
            }

            if (b.isBuilding() || b.getResult().isWorseThan(targetResult))
              continue; // don't count them

            for (AbstractTestResultAction ta : b.getActions(AbstractTestResultAction.class)) {
              failCount += ta.getFailCount();
              totalCount += ta.getTotalCount();
              individuals.add(ta);
            }
            break;
          }
        }
      }

      this.failCount = failCount;
      this.totalCount = totalCount;
      this.individuals = individuals;
      this.didntRun = didntRun;
      this.noFingerprints = noFingerprints;
    }
예제 #3
0
 /**
  * Gets the counter part of this {@link TestResult} in the previous run.
  *
  * @return null if no such counter part exists.
  */
 public TestResult getPreviousResult() {
   AbstractBuild<?, ?> b = getOwner();
   if (b == null) {
     return null;
   }
   while (true) {
     b = b.getPreviousBuild();
     if (b == null) return null;
     AbstractTestResultAction r = b.getAction(getParentAction().getClass());
     if (r != null) {
       TestResult result = r.findCorrespondingResult(this.getId());
       if (result != null) return result;
     }
   }
 }