buildframework/helium/sf/java/quality/tests/antunit/test_cmt.ant.xml
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : test_cmt.ant.xml 
Part of     : Helium AntLib

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
<project name="test-cmt" xmlns:au="antlib:org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
    <description>Helium antlib Quality CMT related tests.</description>

    <taskdef name="fmpp" classname="fmpp.tools.AntTask" onerror="report"/>

    <taskdef resource="com/nokia/helium/quality/ant/antlib.xml" uri="http://www.nokia.com/helium" />
    <property name="cmt.output.dir" location="${test.temp.dir}/output"/>
    <property name="test.data.src" value="./../data/helloworldcons"/>
    <property name="temp.diamonds.header.xml" location="${cmt.output.dir}/cmt/diamonds_header.xml" />
    <property name="temp.diamonds.footer.xml" location="${cmt.output.dir}/cmt/diamonds_footer.xml" />
    
    <basename property="componentbase" file="${test.data.src}"/>
    <property name="diamonds.build.output.dir" location="${cmt.output.dir}/cmt" />
    
    <!-- is called prior to the test -->
    <target name="setUp">
        <delete dir="${cmt.output.dir}/cmt" failonerror="false" />
        <mkdir dir="${cmt.output.dir}/cmt" />
        <echo file="${temp.diamonds.header.xml}"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<diamonds-build>
    <schema>23</schema>
]]></echo>
        <echo file="${temp.diamonds.footer.xml}"><![CDATA[</diamonds-build>
]]></echo>
    </target>

    <!-- is called after the test, even if that caused an error -->
    <target name="tearDown">
        <delete dir="${cmt.output.dir}/cmt" failonerror="false" />
        <delete file="${temp.diamonds.header.xml}" failonerror="false" />
        <delete file="${temp.diamonds.footer.xml}" failonerror="false" />
    </target>
    <condition property="do.cmt.test">
        <os family="windows" />
    </condition>


    <!--
     **************************************************************
     ** test CMT for windows
     **************************************************************
    -->

    <target name="test-cmt-with-all-reqd-params-set" if="do.cmt.test">
        <hlm:cmt output="${cmt.output.dir}\logs\cmt_test.txt">
            <fileset id="input" dir="${test.data.src}">
                <include name="**/*.h"/>
                <include name="**/*.cpp"/>
            </fileset>
        </hlm:cmt>
        <au:assertLogContains text="run command: cmt"/>
        <au:assertFileExists file="${cmt.output.dir}\logs\cmt_test.txt"/>
    </target>
    
    <target name="test-cmt-with-html-output-dir" if="do.cmt.test">
        <hlm:cmt output="${cmt.output.dir}\logs\cmt_test.txt" htmlOutputDir="${cmt.output.dir}\logs\cmthtmlFolder">
            <fileset id="input" dir="${test.data.src}">
                <include name="**/*.h"/>
                <include name="**/*.cpp"/>
            </fileset>
        </hlm:cmt>
        <au:assertLogContains text="run command: cmt"/>
        <au:assertFileExists file="${cmt.output.dir}\logs\cmt_test.txt"/>
        <au:assertLogContains text="run command: cmt2html.bat"/>
        <au:assertFileExists file="${cmt.output.dir}\logs\cmthtmlFolder\CMTHTML\index.html"/>
    </target>
    
    <!--
     **************************************************************
     ** test noargs
     **************************************************************
    -->
    <target name="test-norargs-set" if="do.cmt.test">
        <au:expectfailure expectedMessage="Nested Element 'fileset' missing for task 'cmt'.">
            <hlm:cmt/>
        </au:expectfailure>
    </target>
    
    <!--
     **************************************************************
     ** test Only fileset set
     **************************************************************
    -->
    <target name="test-only-fileset-set" if="do.cmt.test">
        <au:expectfailure expectedMessage="Parameter 'output' missing for task 'cmt'.">
            <hlm:cmt>
                <fileset id="input" dir="${test.data.src}">
                    <include name="**/*.h"/>
                    <include name="**/*.cpp"/>
                </fileset>
            </hlm:cmt>
        </au:expectfailure>
    </target>

    <!--
     **************************************************************
     ** test CMT for linux
     **************************************************************
    -->
    <target name="test-cmt-linux" unless="do.cmt.test">
        <au:expectfailure expectedMessage="CMT supported only on windows platforms">
            <hlm:cmt/>
        </au:expectfailure>
    </target>

    <!--
     ** test CMT convert to diamonds (input file has all the wanted data on 2 lines only)
    -->
    <target name="test-cmt-cnvt-dia-valid-2lines" if="do.cmt.test">
        <property name="cmt.id" value="1" />
        <property name="cmt.test.data.src" location="${test.data.src}/index_${cmt.id}.html" />
        <property name="output.file.name" location="${diamonds.build.output.dir}/cmt_summary_${cmt.id}.xml"/>

        <hlm:cmtsummarytask diamondsHeaderFileName="${temp.diamonds.header.xml}" diamondsFooterFileName="${temp.diamonds.footer.xml}"
            outputFile="${output.file.name}"
            inputFile="${cmt.test.data.src}" />
        <au:assertFileExists file="${output.file.name}" />
        <au:assertFilesMatch expected="${output.file.name}" 
                actual="${test.data.src}/../cmt_summary_${cmt.id}.xml" />

    </target>

    <!--
     ** test CMT convert to diamonds (input file has all the wanted data on 4 lines)
    -->
    <target name="test-cmt-cnvt-dia-valid-split" if="do.cmt.test">
        <property name="cmt.id" value="2" />
        <property name="cmt.test.data.src" location="${test.data.src}/index_${cmt.id}.html" />
        <property name="output.file.name" location="${diamonds.build.output.dir}/cmt_summary_${cmt.id}.xml"/>

        <hlm:cmtsummarytask diamondsHeaderFileName="${temp.diamonds.header.xml}" diamondsFooterFileName="${temp.diamonds.footer.xml}"
            outputFile="${output.file.name}"
            inputFile="${cmt.test.data.src}" />
        <au:assertFileExists file="${output.file.name}" />
        <au:assertFilesMatch expected="${output.file.name}" 
                actual="${test.data.src}/../cmt_summary_${cmt.id}.xml" />

    </target>

    <!--
     ** test CMT convert to diamonds input file has no CMT summary data
    -->
    <target name="test-cmt-cnvt-dia-invalid-no-summary" if="do.cmt.test">
        <property name="cmt.id" value="3" />
        <property name="cmt.test.data.src" location="${test.data.src}/index_${cmt.id}.html" />
        <property name="output.file.name" location="${diamonds.build.output.dir}/cmt_summary_${cmt.id}.xml"/>

        <hlm:cmtsummarytask diamondsHeaderFileName="${temp.diamonds.header.xml}" diamondsFooterFileName="${temp.diamonds.footer.xml}"
            outputFile="${output.file.name}"
            inputFile="${cmt.test.data.src}" />
        <au:assertFileExists file="${output.file.name}" />
        <au:assertFilesMatch expected="${output.file.name}" 
                actual="${test.data.src}/../cmt_summary_${cmt.id}.xml" />

    </target>

    <!--
     ** test CMT convert to diamonds input file none existant
    -->
    <target name="test-cmt-cnvt-dia-invalid-no-file" if="do.cmt.test">
        <property name="cmt.id" value="4" />
        <property name="cmt.test.data.src" location="${test.data.src}/index_${cmt.id}.html" />
        <property name="output.file.name" location="${diamonds.build.output.dir}/cmt_summary_${cmt.id}.xml"/>

        <hlm:cmtsummarytask diamondsHeaderFileName="${temp.diamonds.header.xml}" diamondsFooterFileName="${temp.diamonds.footer.xml}"
            outputFile="${output.file.name}"
            inputFile="${cmt.test.data.src}" />
        <au:assertFileDoesntExist file="${output.file.name}" />

    </target>

    <!--
     ** test CMT convert to diamonds input file has spaces after number text in CMT summary data
    -->
    <target name="test-cmt-cnvt-dia-invalid-space-after-numtext-no-summary" if="do.cmt.test">
        <property name="cmt.id" value="5" />
        <property name="cmt.test.data.src" location="${test.data.src}/index_${cmt.id}.html" />
        <property name="output.file.name" location="${diamonds.build.output.dir}/cmt_summary_${cmt.id}.xml"/>

        <hlm:cmtsummarytask diamondsHeaderFileName="${temp.diamonds.header.xml}" diamondsFooterFileName="${temp.diamonds.footer.xml}"
            outputFile="${output.file.name}"
            inputFile="${cmt.test.data.src}" />
        <au:assertFileExists file="${output.file.name}" />
        <au:assertFilesMatch expected="${output.file.name}" 
                actual="${test.data.src}/../cmt_summary_${cmt.id}.xml" />

    </target>

</project>