From 38fbda9d37ab1bf57d6c4c0c6be51aa44f110ff5 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 14 Mar 2014 10:37:36 +0100 Subject: [PATCH] tests: provide a simple way to extract the tests data from run If the RUN_OUTPUT_FILE environment variable is set, "run" will output to the file indicated by that snippets of XML with the results and outputs of the tests run. Together with the run-xml-to-junit.sh (and its associated run-xml-to-junit.xsl style sheet) it is possible to convert that output file to a jUnit-like XML file, which could be used in CI systems. --- run.in | 8 ++++++++ tests/run-xml-to-junit.sh | 24 ++++++++++++++++++++++ tests/run-xml-to-junit.xsl | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100755 tests/run-xml-to-junit.sh create mode 100644 tests/run-xml-to-junit.xsl 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +