提交 59a1f10d 编写于 作者: C Christoph Kutzinski

Avoid IllegalArgumentException in getBuildStatusSummary() if run is still building

上级 822de8e9
......@@ -96,7 +96,7 @@ public enum ResultTrend {
/**
* Returns the result trend of a build.
*
* @param build the current build
* @param build the build
* @return the result trend
*/
public static ResultTrend getResultTrend(AbstractBuild<?, ?> build) {
......@@ -106,7 +106,7 @@ public enum ResultTrend {
/**
* Returns the result trend of a run.
*
* @param run the current run
* @param run the run
* @return the result trend
*
* @since 1.441
......
......@@ -1626,6 +1626,10 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* (especially in comparison with the previous build.)
*/
public Summary getBuildStatusSummary() {
if (isBuilding()) {
return new Summary(false, Messages.Run_Summary_Unknown());
}
ResultTrend trend = ResultTrend.getResultTrend(this);
switch (trend) {
......
......@@ -36,6 +36,15 @@ public class BuildStatusSummaryTest {
when(this.build.getBuildStatusSummary()).thenCallRealMethod();
}
@Test
public void testStatusUnknownIfRunIsStillBuilding() {
when(this.build.getResult()).thenReturn(null);
when(this.build.isBuilding()).thenReturn(true);
Summary summary = this.build.getBuildStatusSummary();
assertEquals(Messages.Run_Summary_Unknown(), summary.message);
}
@Test
public void testSuccess() {
when(this.build.getResult()).thenReturn(Result.SUCCESS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册