buildframework/helium/builder/python/test-macros.ant.xml
author Ross Qin <ross.qin@nokia.com>
Fri, 29 Oct 2010 10:03:48 +0800
changeset 670 46ea84d14897
parent 628 7c4a911dc066
permissions -rw-r--r--
remove migrated template meta data files (in DFS_MCL wk42)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
<?xml version="1.0"?>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
<!-- 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
Name        : build.xml 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
Part of     : Helium AntLib
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
-->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
<project name="test-macros" xmlns:ac="antlib:net.sf.antcontrib">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
    <import file="../java/common.ant.xml" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
    <dirname property="python.builder.dir" file="${ant.file.test-macros}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
    <target name="unittest" depends="pt,pt-coverage"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
    <target name="pt">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
        <pathconvert pathsep=":" property="python.path">
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    31
            <fileset dir="${python.builder.dir}/lib" includes="*.egg" excludes="jython*"/>
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    32
            <fileset dir="${lib.dir}" includes="zipsafe/*.egg" />
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    33
            <dirset dir="${lib.dir}" includes="zipnotsafe/*.egg" />
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    34
            <dirset dir="${lib.dir}/zipsafe" />
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    35
            <!--<fileset dir="${module.bin.dir}" includes="${ant.project.name}*.egg"/>-->
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    36
            <dirset dir="${basedir}" includes="lib"/>
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        </pathconvert>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
        <pathconvert pathsep=" " property="python.modules.coverage">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
            <fileset dir="${basedir}" includes="**/*.py"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        </pathconvert>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        <!---->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        <mkdir dir="${junit.result.dir}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        <ac:trycatch property="cpython.unittest.error">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
            <try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
                <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
                    <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
                    <arg line="${python.builder.dir}/lib/coverage.py -x ${python.builder.dir}/lib/nosetests-script.py --exe -v --with-xunit --xunit-file=${junit.result.dir}/python.xml"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
                    <arg line="${nose.args}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
                </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
            </try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        </ac:trycatch>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        <ac:trycatch property="jython.unittest.error">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
            <try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
                <script language="jython" setbeans="false">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
<![CDATA[
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
import sys
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
import shutil
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    59
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
for p in project.getProperty('python.path').split(':'):
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    61
    sys.path.append(p)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    62
    
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
os.chdir(project.getProperty('lib.dir'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
if os.path.exists('build'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
    shutil.rmtree('build')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
import nose
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
args = project.getProperty('nose.args')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
args2 = "--with-xunit --xunit-file=" + project.getProperty('junit.result.dir') + "/jython.xml" + args
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
testdir = os.path.join(project.getProperty('basedir'), 'lib', project.getProperty('ant.project.name'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
result = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
if ' ' in args:
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    73
    argv = ['-v', testdir + 'tests']
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    74
    result = nose.run(argv=argv)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
elif 'cpython' not in args:
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    76
    argv = ['-v', args2]
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    77
    result = nose.run(argv=argv)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
print >> sys.stderr
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
if not result:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
    raise Exception('Jython unittest failure.')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
]]>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
                </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
            </try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
        </ac:trycatch>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
        <delete includeemptydirs="true">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
            <fileset dir="${basedir}/lib" includes="*.egg-info/"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        </delete>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        <ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
            <isset property="jython.unittest.error" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
            <then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
                <fail message="${jython.unittest.error}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
            </then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        </ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
        <ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
            <isset property="cpython.unittest.error" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
            <then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
                <fail message="${cpython.unittest.error}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
            </then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        </ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
    </target>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
    <target name="pt-coverage">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        <mkdir dir="${lib.dir}/../coverage"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
        <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
            <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
            <arg line="${python.builder.dir}/lib/coverage.py -a -d ${lib.dir}/../coverage ${python.modules.coverage}"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
        </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
        <mkdir dir="${lib.dir}/../coverage/report"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
        <move file="${lib.dir}/../coverage/report/line_coverage.txt" tofile="${lib.dir}/../coverage/report/line_coverage_old.txt" overwrite="true" failonerror="false"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
        <record name="${lib.dir}/../coverage/report/line_coverage.txt" action="start"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
        <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
            <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
            <arg line="${python.builder.dir}/lib/coverage.py -r ${python.modules.coverage}"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
        </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
        <record name="${lib.dir}/../coverage/report/line_coverage.txt" action="stop"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        <script language="jython" setbeans="false">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
for line in open(project.getProperty('lib.dir') + r'/../coverage/report/line_coverage.txt'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
    if 'TOTAL' in line and ' 0%' in line:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
        raise Exception('Coverage at 0%')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
        </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
        <delete file="${basedir}/.coverage"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
    </target>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
</project>