提交 7bb61a24 编写于 作者: R Richard Mortimer

Merge fix for 'JENKINS-26777'

......@@ -94,6 +94,9 @@ Upcoming changes</a>
<li class=bug>
Ensure that the LoadStatistics return a self-consistent result.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21618">issue 21618</a>)
<li class=bug>
Build reports to be running for 45 yr and counting.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26777">issue 26777</a>)
</ul>
</div><!--=TRUNK-END=-->
<h3><a name=v1.606>What's new in 1.606</a> (2015/03/23)</h3>
......
......@@ -717,9 +717,12 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* Gets the string that says how long the build took to run.
*/
public @Nonnull String getDurationString() {
if(isBuilding())
if (hasntStartedYet()) {
return Messages.Run_NotStartedYet();
} else if (isBuilding()) {
return Messages.Run_InProgressDuration(
Util.getTimeSpanString(System.currentTimeMillis()-startTime));
}
return Util.getTimeSpanString(duration);
}
......
......@@ -225,6 +225,7 @@ Run.ArtifactsPermission.Description=\
builds. If you don\u2019t want an user to access the artifacts, you can do so by \
revoking this permission.
Run.InProgressDuration={0} and counting
Run.NotStartedYet=Not started yet
Run.ArtifactsBrowserTitle=Artifacts of {0} {1}
Run.Summary.Stable=stable
......
......@@ -24,14 +24,13 @@
package hudson.model;
import hudson.model.Run.Artifact;
import java.io.IOException;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static org.junit.Assert.*;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
......@@ -115,4 +114,18 @@ public class RunTest {
assertEquals(a.get(1).getDisplayPath(), "a/a.xml");
}
@Issue("JENKINS-26777")
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void getDurationString() throws IOException {
Run r = new Run(new StubJob(), 0) {};
assertEquals("Not started yet", r.getDurationString());
r.onStartBuilding();
String msg;
msg = r.getDurationString();
assertTrue(msg, msg.endsWith(" and counting"));
r.onEndBuilding();
msg = r.getDurationString();
assertFalse(msg, msg.endsWith(" and counting"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册