提交 2ff3cabb 编写于 作者: K Kohsuke Kawaguchi

Parsing can happen in the forked Maven process. Support remoting.

上级 5da00d03
......@@ -102,7 +102,7 @@ public final class SuiteResult implements Serializable {
* This method returns a collection, as a single XML may have multiple <testsuite>
* elements wrapped into the top-level <testsuites>.
*/
static List<SuiteResult> parse(File xmlReport, boolean keepLongStdio) throws DocumentException, IOException {
static List<SuiteResult> parse(File xmlReport, boolean keepLongStdio) throws DocumentException, IOException, InterruptedException {
List<SuiteResult> r = new ArrayList<SuiteResult>();
// parse into DOM
......
......@@ -199,6 +199,8 @@ public final class TestResult extends MetaTabulatedResult {
try {
for (SuiteResult suiteResult : SuiteResult.parse(reportFile, keepLongStdio))
add(suiteResult);
} catch (InterruptedException e) {
throw new IOException2("Failed to read "+reportFile,e);
} catch (RuntimeException e) {
throw new IOException2("Failed to read "+reportFile,e);
} catch (DocumentException e) {
......
......@@ -26,8 +26,16 @@ package hudson.util.io;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Hudson;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import org.dom4j.io.SAXReader;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* Configures XML parsers to be used for various XML parsing activities inside Jenkins.
*
......@@ -45,7 +53,7 @@ import org.dom4j.io.SAXReader;
* @author Kohsuke Kawaguchi
* @since 1.416
*/
public abstract class ParserConfigurator implements ExtensionPoint {
public abstract class ParserConfigurator implements ExtensionPoint, Serializable {
/**
* Configures the given {@link SAXReader}
*
......@@ -62,8 +70,20 @@ public abstract class ParserConfigurator implements ExtensionPoint {
return Hudson.getInstance().getExtensionList(ParserConfigurator.class);
}
public static void applyConfiguration(SAXReader reader, Object context) {
for (ParserConfigurator pc : all())
public static void applyConfiguration(SAXReader reader, Object context) throws IOException, InterruptedException {
Collection<ParserConfigurator> all = Collections.emptyList();
if (Hudson.getInstance()==null) {
Channel ch = Channel.current();
if (ch!=null)
all = ch.call(new Callable<Collection<ParserConfigurator>, IOException>() {
public Collection<ParserConfigurator> call() throws IOException {
return new ArrayList<ParserConfigurator>(all());
}
});
} else
all = all();
for (ParserConfigurator pc : all)
pc.configure(reader,context);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册