Skip to content

Commit

Permalink
pass compilation, but still have four test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
KengoTODA committed Apr 16, 2015
1 parent 6578ce5 commit a58f944
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.436</version>
<version>1.596</version>
</parent>
<artifactId>regression-report-plugin</artifactId>
<name>Regression Report Plugin</name>
Expand Down Expand Up @@ -73,6 +73,16 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package jp.skypencil.jenkins.regression;

import hudson.tasks.junit.CaseResult;
import hudson.tasks.test.TestResult;

import com.google.common.base.Predicate;

class RegressionPredicate implements Predicate<CaseResult> {
class RegressionPredicate implements Predicate<TestResult> {
@Override
public boolean apply(CaseResult input) {
return input.getStatus().isRegression();
public boolean apply(TestResult input) {
if (input instanceof CaseResult) {
CaseResult caseResult = (CaseResult) input;
return caseResult.getStatus().isRegression();
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import hudson.tasks.Mailer;
import hudson.tasks.junit.CaseResult;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.TestResult;

import java.io.PrintStream;
import java.util.Date;
Expand All @@ -33,6 +34,7 @@
import javax.mail.internet.MimeMessage;

import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;

import org.kohsuke.stapler.DataBoundConstructor;

Expand Down Expand Up @@ -103,8 +105,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}

logger.println("regression reporter starts now...");
List<CaseResult> failedTest = testResultAction.getFailedTests();
List<CaseResult> regressionedTests = Lists.newArrayList(Iterables.filter(failedTest, new RegressionPredicate()));
List<CaseResult> regressionedTests = listRegressions(testResultAction);

writeToConsole(regressionedTests, listener);
try {
Expand All @@ -117,6 +118,15 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
return true;
}

private List<CaseResult> listRegressions(
AbstractTestResultAction<?> testResultAction) {
List<? extends TestResult> failedTest = testResultAction.getFailedTests();
Iterable<? extends TestResult> filtered = Iterables.filter(failedTest, new RegressionPredicate());
List<CaseResult> regressionedTests =
Lists.newArrayList(Iterables.transform(filtered, new TestResultToCaseResult()));
return regressionedTests;
}

private void writeToConsole(List<CaseResult> regressions,
BuildListener listener) {
if (regressions.isEmpty()) {
Expand Down Expand Up @@ -147,8 +157,8 @@ private void mailReport(List<CaseResult> regressions, String recipients,
if (Jenkins.getInstance() != null) {
rootUrl = Jenkins.getInstance().getRootUrl();
session = Mailer.descriptor().createSession();
adminAddress = new InternetAddress(Mailer.descriptor()
.getAdminAddress());
adminAddress = new InternetAddress(
JenkinsLocationConfiguration.get().getAdminAddress());
}
builder.append(Util.encode(rootUrl));
builder.append(Util.encode(build.getUrl()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package jp.skypencil.jenkins.regression;

import hudson.tasks.junit.CaseResult;
import hudson.tasks.test.TestResult;

import com.google.common.base.Function;

class TestResultToCaseResult implements Function<TestResult, CaseResult> {
@Override
public CaseResult apply(TestResult input) {
return (CaseResult) input;
}
}

0 comments on commit a58f944

Please sign in to comment.