Skip to content

Commit

Permalink
[FIXED JENKINS-26777] Build reports to be running for 45 yr and counting
Browse files Browse the repository at this point in the history
  • Loading branch information
oldelvet committed Mar 25, 2015
1 parent 9ac2257 commit c2c9a3e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/src/main/java/hudson/model/Run.java
Expand Up @@ -730,9 +730,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 c2c9a3e

Please sign in to comment.