提交 66460f95 编写于 作者: A Andrew Bayer

Get rid of isBuilding() check on previous build's culprits.

上级 31bc4173
......@@ -117,13 +117,11 @@ public interface RunWithSCM<JobT extends Job<JobT, RunT> & Queue.Task,
default Set<User> calculateCulprits() {
Set<User> r = new HashSet<>();
RunT p = ((RunT)this).getPreviousCompletedBuild();
if (p != null && ((RunT)this).isBuilding()) {
if (p != null) {
Result pr = p.getResult();
if (pr != null && pr.isWorseThan(Result.SUCCESS)) {
// we are still building, so this is just the current latest information,
// but we seems to be failing so far, so inherit culprits from the previous build.
// isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
// this information
r.addAll(p.getCulprits());
}
}
......
......@@ -34,8 +34,12 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import hudson.tasks.LogRotatorTest;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.CaptureEnvironmentBuilder;
......@@ -132,6 +136,8 @@ public class AbstractBuildTest {
FakeChangeLogSCM scm = new FakeChangeLogSCM();
p.setScm(scm);
LogRotatorTest.StallBuilder sync = new LogRotatorTest.StallBuilder();
// 1st build, successful, no culprits
scm.addChange().withAuthor("alice");
FreeStyleBuild b = j.buildAndAssertSuccess(p);
......@@ -144,8 +150,15 @@ public class AbstractBuildTest {
assertCulprits(b, "bob");
// 3rd build. bob continues to be in culprit
p.getBuildersList().add(sync);
scm.addChange().withAuthor("charlie");
b = j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get());
b = p.scheduleBuild2(0).waitForStart();
sync.waitFor(b.getNumber(), 1, TimeUnit.SECONDS);
// Verify that we can get culprits while running.
assertCulprits(b, "bob", "charlie");
sync.release(b.getNumber());
j.assertBuildStatus(Result.FAILURE, j.waitForCompletion(b));
assertCulprits(b, "bob", "charlie");
// 4th build, unstable. culprit list should continue
......
......@@ -224,7 +224,7 @@ public class LogRotatorTest {
}
}
static class StallBuilder extends TestBuilder {
public static class StallBuilder extends TestBuilder {
private int syncBuildNumber;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册