buildframework/helium/sf/java/antlint/tests/antunit/test_antlint.ant.xml
author wbernard
Tue, 27 Apr 2010 08:33:08 +0300
changeset 587 85df38eb4012
child 588 c7c26511138f
permissions -rw-r--r--
helium_9.0-a7879c935424

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : test_antlint.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-antlint" xmlns:au="antlib:org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
    <description>Helium Antlib AntLint unittests.</description>

    <dirname property="antlint.test.dir" file="${ant.file.test-antlint}/.."/>
    
    <import file="${antlint.test.dir}/data/sample.ant.xml" />

    <property name="data.model.parsed" location="${antlint.test.dir}/data/datamodel.out"/>
    
    <!-- is called prior to the test -->
    <target name="setUp">
        <echo>-------------------------------------------------------------------------------</echo>
        <delete dir="../output" failonerror="false" />
    </target>

    <!-- is called after the test, even if that caused an error -->
    <target name="tearDown">
        <delete dir="../output" failonerror="false" />
        <echo>-------------------------------------------------------------------------------</echo>
    </target>

    
    <target name="test-antlint">
        <au:expectfailure>
            <runtarget target="antlint"/>    
            <au:assertLogContains text="W: Description not specified!" level="info"/>
            <au:assertLogContains text="W: Project name not specified!" level="info"/>
            <au:assertLogContains text="W: INVALID File Name:" level="info"/>
            <au:assertLogContains text="E: 234: Bad indentation!" level="info"/>
            <au:assertLogContains text="E: 229: Tabs should not be used!" level="info"/>
            <au:assertLogContains text="W: INVALID Project Name: Sample" level="info"/>
            <au:assertLogContains text="W: INVALID Property Name: check-property-name" level="info"/>
            <au:assertLogContains text="W: INVALID PRESETDEF/MACRODEF Name: check_PresetDef.Name" level="info"/>
            <au:assertLogContains text="W: INVALID Target Name: Check_target.Name" level="info"/>
            <au:assertLogContains text="runtarget> calls the target smile that has dependencies!" level="info"/>
            <au:assertLogContains text="antcall> is used with no param elements and calls the target hello that has no dependencies!" level="info"/>
            <au:assertLogContains text="W: Target check-script-size has a script with 1098 characters, code should be inside a python file" level="info"/>
            <au:assertLogContains text="W: Target check-use-of-if-in-targets poor use of if statement, use " level="info"/>
            <au:assertLogContains text="W: Target check-use-of-if-else-in-targets poor use of if-else-property statement, use condition task" level="info"/>
            <au:assertLogContains text="W: Target check-use-of-if-then-in-targets poor use of if-then-property statement, use condition task" level="info"/>
            <au:assertLogContains text="W: test.script.property not in data model" level="info"/>
            <au:assertLogContains text="W: Target check-prop-in-scriptcondition poor use of if-else-property statement, use condition task" level="info"/>
            <au:assertLogContains text="W: build.errors.total not in data model" level="info"/>
            <au:assertLogContains text="W: s60.getenv.path not in data model" level="info"/>
            <au:assertLogContains text="W: test.boolean1 uses 'equals' should use 'istrue' task" level="info"/>
            <au:assertLogContains text="W: test.boolean2 uses 'equals' should use 'istrue' task" level="info"/>
            <au:assertLogContains text="E: ${ found in target_check-jython-script" level="info"/>
            <au:assertLogContains text="W: ${ found in scriptcondition_check-scriptcondition" level="info"/>
            <au:assertLogContains text="W: Target check-scriptcondition poor use of if-else-property statement, use condition task" level="info"/>
            <au:assertLogContains text="W: INVALID PRESETDEF/MACRODEF Name: foo_Macro" level="info"/>
            <au:assertLogContains text="W: test.scriptdef.property not in data model" level="info"/>
            <au:assertLogContains text="E: Scriptdef check-scriptdef does not use attr2" level="info"/>
            <au:assertLogContains text="W: Scriptdef check-scriptdef-style doesn't reference attributes directly, poor style" level="info"/>
            <au:assertLogContains text="E: ${ found in check-script" level="info"/>
            <au:assertLogContains text="E: Scriptdef check-scriptdef-attributes does not have attribute target" level="info"/>
        </au:expectfailure>
    </target>
    
    <target name="antlint">
        <hlm:antlint>
            <fileset id="antlint.files" dir="${antlint.test.dir}/data">
                <include name="*.xml"/>
                <include name="*.ant.xml"/>
                <include name="*build.xml"/>
                <include name="*.antlib.xml"/>
            </fileset>
            <hlm:checker name="CheckTabCharacter" severity="error" />
            <hlm:checker name="CheckPropertyName" severity="warning">([a-z0-9[\\d\\_\\.\\@\\{\\}\\$]]*)</hlm:checker>
            <hlm:checker name="CheckTargetName" severity="warning">([a-z0-9[\\d\\-]]*)</hlm:checker>
            <hlm:checker name="CheckIndentation" severity="error"/>
            <hlm:checker name="CheckPresetDefMacroDefName" severity="warning">([a-z0-9][a-zA-Z0-9]*)</hlm:checker>       
            <hlm:checker name="CheckProjectName" severity="warning">([a-z0-9[\\d\\.\\_\\-]]*)</hlm:checker>
            <hlm:checker name="CheckDescription" severity="warning"/>
            <hlm:checker name="CheckFileName" severity="warning" >^build.xml$|ant.xml$|antlib.xml$</hlm:checker>
            <hlm:checker name="CheckRunTarget" severity="warning"/>
            <hlm:checker name="CheckAntCall" severity="warning"/>
            <hlm:checker name="CheckScriptSize" severity="warning"/>
            <hlm:checker name="CheckUseOfIfInTargets" severity="warning"/>
            <hlm:checker name="CheckJepJythonScript" severity="error" />
            <hlm:checker name="CheckPropertiesInDataModel" severity="warning"/>
            <hlm:checker name="CheckScriptCondition" severity="warning"/>
            <hlm:checker name="CheckPythonTasks" severity="warning"/>
            <hlm:checker name="CheckUseOfEqualsTask" severity="warning"/>
            <hlm:checker name="CheckScriptDefNameAttributes" severity="error"/>
            <hlm:checker name="CheckScriptDefStyle" severity="warning"/>
            <hlm:checker name="CheckScriptDef" severity="error"/>
            <hlm:checker name="CheckDuplicateNames" severity="warning"/>
        </hlm:antlint>
    </target>
</project>