BUMP3R ID3 Tag Layout

Download BUMP3R ID3 Tag Layout as PDF document.

This document describes the ID3 layout of the Back-Up files created by metaHandler GmbH’s application BUMP3R. This application allows the creation of MP-3 files containing metadata that can be used to restore most of the information from the original Audio-CD the backup was created from.
Because the discs are stored in one continuous stream and storing of additional information like artwork is supported this format is ideal for backup and distribution of AudioCDs.

If you have questions or suggestions regarding BUMP3R files please leave a comment.

Posted in BUMP3R | Tagged , , , , , , | Leave a comment

CppUnit to JUnit Unit Test Output XSLT for CruiseControl

I know, some solutions for this problem have been published already but I was not able to get them to work. Mainly because these solutions were aimed at DashBoard while I still prefer the classic CruiseControl interface.

So I was looking for a more generic solution which works with both CruiseControl and DashBoard.

Luckily, Ant can perform XSL transformations so I was able to use one of the published XSLT files only to find out that it does not work as expected.

So I had to create my own xsl-file.
And, here it is:

<?xml version="1.0" encoding="Windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="utf-8" indent="yes"/>

    <xsl:param name="suitename"/>

    <xsl:template match="TestRun">
        <testsuite name="{$suitename}"
            tests="{normalize-space(Statistics/Tests)}"
            failures="{normalize-space(Statistics/Failures)}"
            errors="{normalize-space(Statistics/Errors)}">
            <xsl:apply-templates/>
        </testsuite>
    </xsl:template>

    <xsl:template match="FailedTests">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="SuccessfulTests">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="Test">
        <testcase name="{normalize-space(Name)}" />
    </xsl:template>

    <xsl:template match="FailedTest">
        <testcase name="{normalize-space(Name)}" >
          <failure message="{normalize-space(FailureType)}">
            <xsl:text> File: </xsl:text><xsl:value-of select="normalize-space(Location/File)"/>
            <xsl:text> Line: </xsl:text><xsl:value-of select="normalize-space(Location/Line)"/>
            <xsl:text> : </xsl:text><xsl:value-of select="normalize-space(Message)"/>
          </failure>
        </testcase>
    </xsl:template>

    <xsl:template match="Statistics">
    </xsl:template>

</xsl:stylesheet>

 
The modifications in my ant build file require that the build does not fail immediately after the Unit Tests have been executed but only after the result has been converted to JUnit output.

Here’s the code to do this:


  <target name="unittest">
    <echo message="executing Unittests"/>
    <exec executable="${path2bin}/UnitTests.exe" resultproperty="unittest.result" timeout="3600000" >
      <arg value="${basedir}/UnitTestOutput/TestRunRaw.xml"/>
    </exec>
    <xslt in="${basedir}/UnitTestOutput/TestRunRaw.xml"
          out="${basedir}/UnitTestOutput/TestRun.xml"
          style="${basedir}/UnitTestOutput/cpp2junit.xsl" />
    <fail message="Some UnitTests failed...">
      <condition>
        <not>
          <equals arg1="${unittest.result}" arg2="0" trim="true" />
        </not>
      </condition>
    </fail>
  </target>

Please note that my UnitTests expect the name of the result XML file as a parameter.

I hope you find this usefull.

———————————————————————————————-
Edit:
On the cruisecontrol site there is an xslt file which does exactly the same. I could not find it in the first place because it’s not in the released source tar but in cvs only.
I just made a small modification to it to make it handle namespaces better.
Give it a try:


<?xml version="1.0" encoding="utf-8"?>
<!--

CruiseControl, a Continuous Integration Toolkit
Copyright (c) 2001, ThoughtWorks, Inc.
200 E. Randolph, 25th Floor
Chicago, IL 60601 USA
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template name="substring-before-last">
  <xsl:param name="input" />
  <xsl:param name="substr" />
  <xsl:if test="contains($input, $substr)">
   <xsl:variable name="temp" select="substring-after($input, $substr)" />
   <xsl:value-of select="substring-before($input, $substr)" />
   <xsl:if test="contains($temp, $substr)">
    <xsl:value-of select="$substr" />
    <xsl:call-template name="substring-before-last">
     <xsl:with-param name="input" select="$temp" />
     <xsl:with-param name="substr" select="$substr" />
    </xsl:call-template>
   </xsl:if>
  </xsl:if>
 </xsl:template>
 <xsl:template match="/">
  <testsuite>
   <xsl:attribute name="errors">
    <xsl:value-of select="TestRun/Statistics/Errors"/>
   </xsl:attribute>
   <xsl:attribute name="failures">
    <xsl:value-of select="TestRun/Statistics/Failures"/>
   </xsl:attribute>
   <xsl:attribute name="tests">
    <xsl:value-of select="TestRun/Statistics/Tests"/>
   </xsl:attribute>
   <xsl:attribute name="name">CppUnit</xsl:attribute>
   <xsl:apply-templates/>
  </testsuite>
 </xsl:template>
 <xsl:template match="/TestRun/SuccessfulTests/Test">
  <testcase>
   <xsl:variable name="Class">
    <xsl:call-template name="substring-before-last">
     <xsl:with-param name="input" select="Name" />
     <xsl:with-param name="substr" select="'::'" />
    </xsl:call-template>
   </xsl:variable>
   <xsl:attribute name="name"><xsl:value-of select="substring-after(Name, concat($Class, '::'))"/></xsl:attribute>
                        <xsl:attribute name="classname" ><xsl:value-of select="$Class"/></xsl:attribute>
                </testcase>
 </xsl:template>
 <xsl:template match="/TestRun/FailedTests/FailedTest">
  <testcase>
   <xsl:variable name="Class">
    <xsl:call-template name="substring-before-last">
     <xsl:with-param name="input" select="Name" />
     <xsl:with-param name="substr" select="'::'" />
    </xsl:call-template>
   </xsl:variable>
                        <xsl:attribute name="name"><xsl:value-of select="substring-after(Name, concat($Class, '::'))"/></xsl:attribute>
                        <xsl:attribute name="classname" ><xsl:value-of select="$Class"/></xsl:attribute>
                        <failure message="{normalize-space(FailureType)}">
                            <xsl:text>File: </xsl:text><xsl:value-of select="normalize-space(Location/File)"/>
                            <xsl:text> Line: </xsl:text><xsl:value-of select="normalize-space(Location/Line)"/>
                            <xsl:text> : </xsl:text><xsl:value-of select="normalize-space(Message)"/>
                    </failure>
  </testcase>
 </xsl:template>
  <!-- skip all text -->
 <xsl:template match="text()|@*"/>
</xsl:stylesheet>

Ohh, and do not forget to add the following lines to your cruisecontrol config.xml file:


    <log>
      <merge dir="${unittestdir}\TestRun.xml" />
    </log>
Posted in ant and CruiseControl | Tagged , , , , , , | Leave a comment

Auto-Increment C/C++ version numbers with ant

Here’s a description of how I manage an automatic update of the build-version number during my contiguous integration builds with ant build scripts.
During the build process the current version number is available in four different proerties and can be used to generate additional files conatining the build number.

First, in the global properties you check for the existance of the file “version.h”:


<available file="version.h" property="hasVersionFile" />
<tempfile property="temp.file" />

Additionally, this fragement creates a filename for a temporary file used throuhout the remainder of my build.xml file.

Next, you create a project that creates the version file if it does not exist.
(optionally, you can immediately add it to you SCM, here SubVersion)



<target name="createver" unless="hasVersionFile" >
    <echo file="version.h" append="false">
/*****************************************************
 * version.h
 * generated by ant
 *****************************************************/

#ifndef _ANT_VERSION_H_
#define _ANT_VERSION_H_

#define VER_MAJOR 1
#define VER_MINOR 0
#define VER_BUILD 1
#define VER_PATCH 0

#endif //  _ANT_VERSION_H
    </echo>
    <fixcrlf file="version.h"/>
    <svn>
      <add file="version.h" />
    </svn>
  </target>

In all my build files I use a “init” project that sets some common properties and reads the current version.h file.



<target name="init">
    <tstamp/>
    <antcall target="createver" />
    <!-- load version numer properties -->
    <!-- Load exisiting or previously created version.h file -->
    <loadfile property="version.build.str" srcFile="version.h" >
      <filterchain>
        <tokenfilter>
          <containsregex pattern="^\043define[ \t]+VER_[A-Z]+[ \t]+[0-9]+.*" />
        </tokenfilter>
      </filterchain>
    </loadfile>

    <echo file="${temp.file}" append="false" message="${version.build.str}" />
    <replaceregexp file="${temp.file}" match="^\043define[ \t]+(VER_[A-Z]+)[ \t]+([0-9]+).*"
replace="oldver.\1=\2" byline="true" />     <loadproperties srcFile="${temp.file}" />     <delete file="${temp.file}" />     <echo message="${line.separator}" />     <echo message="Main Version number is : ${oldver.VER_MAJOR}.${oldver.VER_MINOR}.${oldver.VER_BUILD}.${oldver.VER_PATCH}${line.separator}" />   </target>

Finally, the target that gets called if the build on the build system was successfull. Only in this case the version number is increased automatically and the changed “version.h” file is updated in the SCM:



<!-- increment version number in version.h, creates the file if it does not exist -->
  <target name="incver" depends="init">
    <echo file="${temp.file}" append="false" message="${version.build.str}" />
    <replaceregexp file="${temp.file}" match="^\043define[ \t]+(VER_[A-Z]+)[ \t]+([0-9]+).*" 
replace="version.\1=\2" byline="true" />     <propertyfile file="${temp.file}">        <entry key="version.VER_BUILD" type="int" operation="+" value="1" />     </propertyfile>     <loadproperties srcFile="${temp.file}" />     <delete file="${temp.file}" />     <echo message="Next version number is : ${version.VER_MAJOR}.${version.VER_MINOR}.${version.VER_BUILD}.${version.VER_PATCH}${line.separator}" />     <echo message="${line.separator}" />     <!-- Rewrite exisiting or previously created version.h file -->     <replaceregexp file="version.h" match="^(\043define[ \t]+VER_BUILD[ \t]+)[0-9]+(.*)"
replace="\1${version.VER_BUILD}\2" byline="true" />     <fixcrlf file="version.h"/>     <svn username="${svnuser}" password="${svnpass}">       <commit file="version.h" message="Updated Build number to ${version.VER_BUILD}" />     </svn>   </target>
Posted in ant and CruiseControl | Tagged , , , , , | Leave a comment