diff --git a/run.in b/run.in
index 55942c642..a508c3871 100755
--- a/run.in
+++ b/run.in
@@ -260,5 +260,13 @@ else
cat $tmpout
echo "$b/run: command failed with exit code $fail"
fi
+if [ -n "$RUN_OUTPUT_FILE" ]; then
+ testname=`echo "$1" | sed -e 's,^./,,g'`
+ echo "" >> $RUN_OUTPUT_FILE
+ echo "> $RUN_OUTPUT_FILE
+ cat $tmpout >> $RUN_OUTPUT_FILE
+ echo "]]>" >> $RUN_OUTPUT_FILE
+ echo "" >> $RUN_OUTPUT_FILE
+fi
rm -f $tmpout
exit $fail
diff --git a/tests/run-xml-to-junit.sh b/tests/run-xml-to-junit.sh
new file mode 100755
index 000000000..b6f11fea9
--- /dev/null
+++ b/tests/run-xml-to-junit.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+ echo "$0: output-of-run destination-xml"
+ exit 1
+fi
+
+set -e
+
+infile=$1
+outfile=$2
+owndir=`dirname $0`
+ownname=`basename $0`
+tmpfile=`mktemp --tmpdir $ownname.XXXXXXXXXX`
+
+(
+ echo '';
+ echo '';
+ cat $infile;
+ echo ''
+) > $tmpfile
+
+xsltproc --encoding UTF-8 $owndir/run-xml-to-junit.xsl $tmpfile > $outfile
+unlink $tmpfile
diff --git a/tests/run-xml-to-junit.xsl b/tests/run-xml-to-junit.xsl
new file mode 100644
index 000000000..b0d56f37c
--- /dev/null
+++ b/tests/run-xml-to-junit.xsl
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+