This is the mail archive of the
mailing list for the Mauve project.
Re: [PATCH] xml output from mauve (updated)
On sÃn, 2004-09-19 at 23:51 +0200, Mark Wielaard wrote:
> On Sat, 2004-09-18 at 22:47, Noa Resare wrote:
> > On fre, 2004-09-17 at 23:20 +0200, Noa Resare wrote:
> > > So, I did some afternoon hacking and came up with this patch to mauve
> > > that outputs the results from a mauve run into an xml file for easy
> > > parsing. I haven't written anything that does anything with the output
> > > yet but I thought I could share this with you anyway.
> > This updated patch handles mauve output containing & < and > properly.
> > It also adds Makefile.am to the changelog entry.
> > ps. a test result diff program (that looks for regressions) in very
> > rough form is available from http://resare.com/noa/testdiff
> Very nice!
> Maybe this should be written as a new XMLTestHarness class?
> Although I don't really see a problem with just tagging it on the
> SimpleTestHarness. Opinions anybody?
Maybe that would be better. However, I don't think the current solution
is horribly ugly and I'd rather use that time trying to contribute to
fixing jvm bugs. I'm open to suggestions though :)
> Are you sure the XML escaping is always correct?
> Maybe it doesn't really matter in this case, but you might want to look
> whether GNU Kawa (http://www.gnu.org/software/kawa/) has something
> appropriate in the gnu.xml package.
I'm think escaping is correct except for the case when any of the
properties used to identify a jvm in the output header or a class name
contains a single quote ('). The attached patch fixes this and applies
on top of my previous patch.
And the lions ate the christians and the christians burned the witches,
and even I am out of explanations -- Ola Salo
gpg fingerprint: F3C4 AC90 B885 FE15 344B 4D05 220B 7662 A190 6F09
--- mauve/gnu/testlet/TestReport.java.vanilla 2004-09-20 08:20:22.653300790 +0200
+++ mauve/gnu/testlet/TestReport.java 2004-09-20 08:43:54.765740326 +0200
@@ -68,18 +68,19 @@
Writer out = new OutputStreamWriter(new FileOutputStream(f), ENCODING);
out.write("<?xml version='1.0' encoding='" + ENCODING + "'?>\n");
out.write("<testreport version='0.1'>\n <jvm name='" +
- systemProperties.get("java.vm.vendor") + "'\n version='" +
- systemProperties.get("java.vm.version") + "' \n" +
- " os='" + systemProperties.get("os.name") + " " +
- systemProperties.get("os.version") + " " +
- systemProperties.get("os.arch") + "' />\n");
+ escAttrib(systemProperties.get("java.vm.vendor")) +
+ "'\n version='" +
+ escAttrib(systemProperties.get("java.vm.version")) + "' \n" +
+ " os='" + escAttrib(systemProperties.get("os.name")) + " " +
+ escAttrib(systemProperties.get("os.version")) + " " +
+ escAttrib(systemProperties.get("os.arch")) + "' />\n");
Iterator results = testResults.iterator();
TestResult tr = (TestResult) results.next();
String failures = tr.getFailMessags();
- out.write(" <testresult testlet='" + tr.getTestletName() +
+ out.write(" <testresult testlet='" + escAttrib(tr.getTestletName()) +
"' passcount='" + tr.getPassCount());
if (failures.length > 0 || tr.getException() != null)
@@ -92,7 +93,8 @@
if (tr.getException() != null)
Throwable t = tr.getException();
- out.write(" <exception class='" + t.getClass().getName() +
+ out.write(" <exception class='" +
+ escAttrib(t.getClass().getName()) +
"'>\n <reason>" + esc(tr.getExceptionMessage()) +
"</reason>\n <message>" + esc(t.getMessage()) +
@@ -117,4 +119,16 @@
str = str.replaceAll(">", ">");
+ * Escapes single quotes in string by prepending a backslash.
+ private String escAttrib(Object obj)
+ if (obj == null)
+ return null;
+ String str = (String)obj;
+ str = str.replaceAll("'", "\\'");
+ return str;