Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED JENKINS-29383] Fix handling of special chars in aggregated matrix reports #21

Merged
merged 1 commit into from Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Expand Up @@ -48,5 +48,15 @@
</exclusion>
</exclusions>
</dependency>
<!--
Override beta version declared by jenkins-test-harness.
TODO: Reomve once depending on 1.600 or newer: f987f9ce89952c79e045f6125c08bfd7c6b9aa99
-->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
8 changes: 4 additions & 4 deletions src/main/resources/lib/hudson/test/failed-test.jelly
Expand Up @@ -82,12 +82,12 @@ THE SOFTWARE.
</style>
</st:once>
<j:set var="id" value="${h.jsStringEscape(url)}"/>
<j:set var="open" value="javascript:showFailureSummary('test-${id}','${url}/summary')"/>
<j:set var="close" value="javascript:hideFailureSummary('test-${id}')"/>
<a id="test-${id}-showlink" href="${open}" title="${%Show details}">
<j:set var="open" value="showFailureSummary('test-${id}','${url}/summary')"/>
<j:set var="close" value="hideFailureSummary('test-${id}')"/>
<a id="test-${id}-showlink" href="#" onclick="${open}" title="${%Show details}">
<l:icon class="icon-document-add icon-sm"/>
</a>
<a id="test-${id}-hidelink" href="${close}" title="${%Hide details}" style="display:none">
<a id="test-${id}-hidelink" href="#" onclick="${close}" title="${%Hide details}" style="display:none">
<l:icon class="icon-document-delete icon-sm"/>
</a>
<st:nbsp/>
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/hudson/tasks/junit/JUnitResultArchiverTest.java
Expand Up @@ -24,6 +24,10 @@
package hudson.tasks.junit;

import hudson.FilePath;
import hudson.matrix.AxisList;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.slaves.DumbSlave;
Expand All @@ -34,8 +38,10 @@
import org.jvnet.hudson.test.TouchBuilder;
import org.jvnet.hudson.test.recipes.LocalData;

import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
Expand All @@ -46,18 +52,24 @@
import hudson.model.TaskListener;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.jvnet.hudson.test.RandomlyFails;
import org.jvnet.hudson.test.SingleFileSCM;
import org.jvnet.hudson.test.TestExtension;
import org.kohsuke.stapler.DataBoundConstructor;

Expand Down Expand Up @@ -275,4 +287,27 @@ public String getName() {
}
}

@Test public void specialCharsInRelativePath() throws Exception {
final String ID_PREFIX = "test-../a=%3C%7C%23)/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/";
final String EXPECTED = "org.twia.dao.DAOException: [S2001] Hibernate encountered an error updating Claim [null]";

MatrixProject p = j.createMatrixProject();
p.setAxes(new AxisList(new TextAxis("a", "<|#)")));
p.setScm(new SingleFileSCM("report.xml", getClass().getResource("junit-report-20090516.xml")));
p.getPublishersList().add(new JUnitResultArchiver("report.xml"));

MatrixBuild b = p.scheduleBuild2(0).get();
j.assertBuildStatus(Result.UNSTABLE, b);

WebClient wc = j.createWebClient();
HtmlPage page = wc.getPage(b, "testReport");

assertThat(page.asText(), not(containsString(EXPECTED)));

((HtmlAnchor) page.getElementById(ID_PREFIX + "-showlink")).click();
assertThat(page.asText(), containsString(EXPECTED));

((HtmlAnchor) page.getElementById(ID_PREFIX + "-hidelink")).click();
assertThat(page.asText(), not(containsString(EXPECTED)));
}
}