Skip to content

Commit

Permalink
Restore compatiblity with junit-sql-storage (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Jul 29, 2024
1 parent 72cf99b commit 310a78b
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 156 deletions.
266 changes: 126 additions & 140 deletions src/main/java/hudson/tasks/junit/History.java

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/main/java/hudson/tasks/junit/HistoryTestResultSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import hudson.Util;
import hudson.model.Run;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.TestResult;

public class HistoryTestResultSummary {

Expand All @@ -11,21 +13,19 @@ public class HistoryTestResultSummary {
private final int skipCount;
private final int passCount;
private final String description;
private final hudson.tasks.test.TestResult resultInRun;

public HistoryTestResultSummary(Run<?, ?> run, hudson.tasks.test.TestResult resultInRun,
public HistoryTestResultSummary(Run<?, ?> run,
float duration, int failCount, int skipCount, int passCount) {
this(run, resultInRun, duration, failCount, skipCount, passCount, null);
this(run, duration, failCount, skipCount, passCount, null);

Check warning on line 19 in src/main/java/hudson/tasks/junit/HistoryTestResultSummary.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 19 is not covered by tests
}

public HistoryTestResultSummary(Run<?, ?> run, hudson.tasks.test.TestResult resultInRun, float duration, int failCount, int skipCount, int passCount, String description) {
public HistoryTestResultSummary(Run<?, ?> run, float duration, int failCount, int skipCount, int passCount, String description) {
this.run = run;
this.duration = duration;
this.failCount = failCount;
this.skipCount = skipCount;
this.passCount = passCount;
this.description = description;
this.resultInRun = resultInRun;
}

public String getDescription() {
Expand All @@ -36,6 +36,10 @@ public String getDescription() {
return run;
}

public float getDuration() {
return duration;
}

public String getDurationString() {
return Util.getTimeSpanString((long) (duration * 1000));
}
Expand Down Expand Up @@ -65,10 +69,9 @@ public String getFullDisplayName() {
}

public String getUrl() {
return resultInRun.getUrl();
}
AbstractTestResultAction<?> action = run.getAction(AbstractTestResultAction.class);

public hudson.tasks.test.TestResult getResultInRun() {
return resultInRun;
// TODO pass id to end of url

Check warning on line 74 in src/main/java/hudson/tasks/junit/HistoryTestResultSummary.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: pass id to end of url
return getRun().getUrl() + action.getUrlName() + "/";
}
}
7 changes: 4 additions & 3 deletions src/main/java/hudson/tasks/junit/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,10 +693,11 @@ public int getFailCount() {
if (impl != null) {
return impl.getFailCount();
}
if(failedTests==null)
if(failedTests==null) {
return 0;
else
return failedTests.size();
} else {
return failedTests.size();
}
}

@Exported(visibility=999)
Expand Down
9 changes: 7 additions & 2 deletions src/main/resources/hudson/tasks/junit/History/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ function onBuildIntervalChange(selectObj) {
interval = dataEl.getAttribute("data-interval")
let trendChartJsonStr = dataEl.innerHTML
trendChartJson = JSON.parse(trendChartJsonStr)
appRootUrl = dataEl.getAttribute("data-appRootUrl")
const rootUrl = document.head.dataset.rooturl
if (!rootUrl.endsWith("/")) {
appRootUrl = `${rootUrl}/`
} else {
appRootUrl = rootUrl
}
testObjectUrl = dataEl.getAttribute("data-testObjectUrl")

trendChartJsonStr = null
Expand Down Expand Up @@ -390,7 +395,7 @@ function onBuildIntervalChange(selectObj) {
renderTrendChart(trendChartId, trendChartJson, trendConfigurationDialogId,
function (buildDisplayName) {
if (trendChartJson.buildMap[buildDisplayName]) {
window.open(rootUrl + trendChartJson.buildMap[buildDisplayName].url);
window.open(appRootUrl + trendChartJson.buildMap[buildDisplayName].url);
}
});
renderDistributionChart('test-distribution-chart', trendChartJson, trendConfigurationDialogId, null);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/hudson/tasks/junit/History/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ THE SOFTWARE.
data-end="${end}"
data-count="${count}"
data-interval="${interval}"
data-appRootUrl="${app.rootUrl}"
data-testObjectUrl="${it.testObject.url}"
type="application/json"
>${historySummary.trendChartJson}</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public List<HistoryTestResultSummary> getHistorySummary(int offset) {
Job<?, ?> theJob = Jenkins.get().getItemByFullName(getJobName(), Job.class);
if (theJob != null) {
Run<?, ?> run = theJob.getBuildByNumber(buildNumber);
historyTestResultSummaries.add(new HistoryTestResultSummary(run, null, duration, failed, skipped, passed));
historyTestResultSummaries.add(new HistoryTestResultSummary(run, duration, failed, skipped, passed));
}
}
return historyTestResultSummaries;
Expand Down

0 comments on commit 310a78b

Please sign in to comment.