Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge fix for 'JENKINS-26777'
  • Loading branch information
oldelvet committed Mar 30, 2015
2 parents 37964df + c2c9a3e commit 7bb61a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -94,6 +94,9 @@
<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>
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/hudson/model/Run.java
Expand Up @@ -717,9 +717,12 @@ public String getDescription() {
* 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);
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/hudson/model/Messages.properties
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions core/src/test/java/hudson/model/RunTest.java
Expand Up @@ -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;
Expand Down Expand Up @@ -115,4 +114,18 @@ public void artifactListDisambiguation3() throws Exception {
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"));
}
}

0 comments on commit 7bb61a2

Please sign in to comment.