public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Noa Resare <noa@resare.com>
To: mauve-discuss@sources.redhat.com
Subject: Re: [PATCH] xml output from mauve (updated)
Date: Mon, 20 Sep 2004 06:48:00 -0000	[thread overview]
Message-ID: <1095662908.25818.19.camel@c-351f72d5.01-60-6c6b701.cust.bredbandsbolaget.se> (raw)
In-Reply-To: <1095630709.1284.65.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]

On sön, 2004-09-19 at 23:51 +0200, Mark Wielaard wrote:
> Hi,
> 
> 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. 

/noa

-- 
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

[-- Attachment #2: mauve-xmlout-escape.patch --]
[-- Type: text/x-patch, Size: 2258 bytes --]

--- 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");
     Collections.sort(testResults);
     Iterator results = testResults.iterator();
     while (results.hasNext())
       {
 	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)
 	  out.write("'>\n");
@@ -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()) +
 		    "</message>\n    </exception>\n");
@@ -117,4 +119,16 @@
     str = str.replaceAll(">", "&gt;");
     return str;
   }
+
+  /**
+   * 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;
+  }
 }

      reply	other threads:[~2004-09-20  6:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-17 21:20 [PATCH] xml output from mauve Noa Resare
2004-09-18 20:47 ` [PATCH] xml output from mauve (updated) Noa Resare
2004-09-19 21:51   ` Mark Wielaard
2004-09-20  6:48     ` Noa Resare [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1095662908.25818.19.camel@c-351f72d5.01-60-6c6b701.cust.bredbandsbolaget.se \
    --to=noa@resare.com \
    --cc=mauve-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).