Skip to content

Commit

Permalink
[FIXED JENKINS-19186] Robustness against malformed test result XML.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Aug 13, 2013
1 parent 1e9f90a commit 4d8bfb5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
A malformed JUnit result file should mark that test suite as a failure, but not interrupt archiving of other tests.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19186">issue 19186</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/hudson/tasks/junit/TestResult.java
Expand Up @@ -288,7 +288,6 @@ public void parse(File reportFile) throws IOException {
String error = "Failed to read test report file "+reportFile.getAbsolutePath()+"\n"+writer.toString();
sr.addCase(new CaseResult(sr,"<init>",error));
add(sr);
throw new IOException2("Failed to read "+reportFile,e);
}
}
}
Expand Down
Expand Up @@ -27,11 +27,16 @@
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Project;
import hudson.model.Result;
import hudson.model.Run;
import hudson.slaves.DumbSlave;
import hudson.tasks.Builder;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TouchBuilder;
Expand Down Expand Up @@ -275,7 +280,19 @@ public void testHistoryPageOpenJunit() throws IOException, SAXException {
tableText.contains("4 ms"));
}


@Bug(19186)
public void testBrokenResultFile() throws Exception {
FreeStyleProject p = createFreeStyleProject();
p.getBuildersList().add(new TestBuilder());
p.getPublishersList().add(new JUnitResultArchiver("TEST-foo.xml", false, null));
assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
}
private static final class TestBuilder extends Builder {
@Override public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
build.getWorkspace().child("TEST-foo.xml").write("<bogus>", null);
return true;
}
}

void assertStringEmptyOrNull(String msg, String str) {
if (str==null)
Expand Down

0 comments on commit 4d8bfb5

Please sign in to comment.