I got my head around this stuff and realized that the solution is far simpler 
than I thought before.  No changes to the cmake codebase are needed.  I will 
continue this thread during the next days...


Am Donnerstag 22 Mai 2008 16:29:51 schrieb Maik Beckmann:
> Hello again,
>
> Doing it via xsl transformations will lead to a nice separation into the
> following two tasks:
>
>   1. Teach CMake/CTest about xslt processors
> A bunch of .cmake files in the Modules dir for the common xslt processors
> out there (xsltproc, xalan...) will show cmake how to use each of them.
>
>   2. Write xsl files for the ctest-{update/configure/build/test/...}.xml to
>     fooUnit.xml or BarControl.xml formats
> This task can itself naturally divided into subtasks:
>     2a. Ant-Junit xml
>     2b. Bitten xml
>     ...
> I've started creating ctest-xml pseudo specs by read the ctest code.  These
> can be used by the xsl authors to write towards their target format.  I'll
> upload them here
>  - http://www.cmake.org/Wiki/CTest:OpenTasks
> as soon as their state is good enough.
>
> Best,
>  -- Maik


Just a little progress report.  


The work flow I have in mind is as follows.  CTest performs it's duties as 
usual, which results in a bunch of XML files at at 
${CMAKE_BINARY_DIR}/Testing/${SOME_DATE}/.  
If the users requests the to junit-an-xml transformation ctest scans this dir 
and writes a simple XML file which lists these files
{{{
<Files>
  <file>Update.xml</file>
  <file>Configure.xml</file>
  <file>Test.xml</file>
   ...
</Files>
}}}
Lets call it index.xml for now.  The XSLT processor actually runs on this 
index.xml and XSL pulls in every file listed in it
{{{
<xsl:template match="/">
        <testsuites>
                <xsl:for-each select="/Files">
                        <xsl:for-each select="document(File/text())">
                                <xsl:apply-templates select="Site"/>
                        </xsl:for-each> 
                </xsl:for-each>
        </testsuites>
</xsl:template>
}}}

This way all the code doing the real work in ctest doesn't  even know about 
any to foobar-XML transformation.  The interface between the ctest output and 
foobar-XML is defined by an single XSL file.  Pretty straight forward, isn't 
it? :)

I learned xsl to some extend and coded the attached to_junit.xsl.  Its not 
finished but might show you a spirit of what I have in mind.

I coded an example project which I will use to tinker around.  It is attached 
as well.


The next step I'll do is to take a look at ctest and how the XSLT processor 
run can be triggered by it nicely.  A  test during configuration time to make 
sure "${CMAKE_XSLT_PROCESSOR} or "${CTEST_XSLT_PROCESSOR}" is working at all 
would be nice as well.  This item might be of interest for the boost-cmake 
people, since boostbook is XSL as well.



Best Regards,
 -- Maik


<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output indent="yes" method="xml" encoding="UTF8"/>

<xsl:template match="/">
	<testsuites>
		<xsl:for-each select="/Files">
			<xsl:for-each select="document(File/text())">
				<xsl:apply-templates select="Site"/>
			</xsl:for-each>	
		</xsl:for-each>
	</testsuites>
</xsl:template>

<xsl:template match="Site">
	<xsl:apply-templates select="node()"/>
</xsl:template>

<xsl:template name="TestsuiteProperties">
	<xsl:param name="AttrList" select="UNDEFINED"/>
	<properties>
		<xsl:for-each select="$AttrList">
			<xsl:if test="name() != 'Hostname'">
				<property name="{name()}" value="{.}"/>	
			</xsl:if>
		</xsl:for-each>
	</properties>
</xsl:template>


<xsl:template match="Testing">
	<testsuite
			errors="{count([EMAIL PROTECTED]'notrun'])}" 
			failures="{count([EMAIL PROTECTED]'failed'])}"
			hostname="{../@Hostname}"
			name="Testing" 
			tests="{count(TestList/Test)}" 
			time="{ElapsedMinutes * 60}" 
			timestamp="{StartDateTime}"> 

		<xsl:call-template name="TestsuiteProperties">
			<xsl:with-param name="AttrList" select="../@*"/>
		</xsl:call-template>

		<xsl:apply-templates select="Test"/>

	</testsuite>
</xsl:template>

<xsl:template match="Testing/Test">		
	<testcase	classname="{Name}" name="{Name}" time="{Results/[EMAIL PROTECTED]'Execution Time']/Value}">
		
		<xsl:if test="@Status = 'failed'">
			<failures message="TODO: add short message to ctest outputs"  type="TODO: add failure-type forwaring from ctest">
				<xsl:value-of select="Results/Measurement/Value"/>
			</failures>
		</xsl:if>	
		
		<xsl:if test="@Status = 'notrun'">
			<errors	message="TODO: add short message to ctest outputs" type="TODO: add failure-type forwaring from ctest">
				<xsl:value-of select="Results/Measurement/Value"/>
			</errors>
		</xsl:if>
			
	</testcase>
</xsl:template>


<xsl:template match="Build">
	<testsuite
			errors="{count(Error)}" 
			failures="{count(Warning)}" 
			hostname="{../@Hostname}"
			name="Build" 
			tests="1" 
			time="{ElapsedMinutes * 60}" 
			timestamp="{StartDateTime}"> 

		<xsl:call-template name="TestsuiteProperties">
			<xsl:with-param name="AttrList" select="../@*"/>
		</xsl:call-template>

		<xsl:apply-templates select="Error|Warning"/>

	</testsuite>
</xsl:template>

<xsl:template match="Error|Warning">
	<testcase	classname="{SourceFile}" name="{SourceLineNumber}" time="Unknown">

		<xsl:if test="name(current()) = 'Warning'">
			<failures message="TODO: add short message to ctest outputs"  type="TODO: add failure-type forwaring from ctest">
				<xsl:value-of select="Text"/>
			</failures>
		</xsl:if>	
		
		<xsl:if test="name(current()) = 'Error'">
			<errors	message="TODO: add short message to ctest outputs" type="TODO: add failure-type forwaring from ctest">
				<xsl:value-of select="Text"/>
			</errors>
		</xsl:if>
			
	</testcase>	
</xsl:template>




</xsl:stylesheet>


Attachment: ctest-test.tar.gz
Description: application/tgz

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to