buildframework/helium/builder/python/test-macros.ant.xml
author kelvzhu
Tue, 27 Jul 2010 13:00:43 +0800
changeset 621 96fee2635b19
parent 587 85df38eb4012
child 628 7c4a911dc066
permissions -rw-r--r--
Fixed Bug 2413 for evalid
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">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
            <fileset dir="${python.builder.dir}/lib" includes="**/*.egg" excludes="jython*"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
            <fileset dir="${lib.dir}" includes="**/*.egg"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
            <dirset dir="${lib.dir}"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
            <fileset dir="${module.bin.dir}" includes="**/${ant.project.name}*.egg"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
            <dirset dir="${basedir}/lib"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
        </pathconvert>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        <pathconvert pathsep=" " property="python.modules.coverage">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
            <fileset dir="${basedir}" includes="**/*.py"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        </pathconvert>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        <!---->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        <mkdir dir="${junit.result.dir}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        <ac:trycatch property="cpython.unittest.error">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
            <try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
                <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
                    <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
                    <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
    47
                    <arg line="${nose.args}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
                </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
            </try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        </ac:trycatch>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        <ac:trycatch property="jython.unittest.error">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
            <try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
                <script language="jython" setbeans="false">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
<![CDATA[
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
import sys
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
import shutil
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
for p in project.getProperty('python.path').split(':'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
    if 'amara' not in p:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        sys.path.append(p)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
os.chdir(project.getProperty('lib.dir'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
if os.path.exists('build'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
    shutil.rmtree('build')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
import nose
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
args = project.getProperty('nose.args')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
args2 = "--with-xunit --xunit-file=" + project.getProperty('junit.result.dir') + "/jython.xml" + args
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
testdir = os.path.join(project.getProperty('basedir'), 'lib', project.getProperty('ant.project.name'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
result = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
if ' ' in args:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    result = nose.run(argv=['-v', testdir + 'tests'])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
elif 'cpython' not in args:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
    result = nose.run(argv=['-v', args2])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
print >> sys.stderr
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
if not result:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
    raise Exception('Jython unittest failure.')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
]]>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
                </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
            </try>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
        </ac:trycatch>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
        <delete includeemptydirs="true">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
            <fileset dir="${basedir}/lib" includes="*.egg-info/"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
        </delete>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
        <ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
            <isset property="jython.unittest.error" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
            <then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
                <fail message="${jython.unittest.error}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
            </then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
        </ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
        <ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
            <isset property="cpython.unittest.error" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
            <then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
                <fail message="${cpython.unittest.error}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
            </then>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        </ac:if>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
    </target>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
    <target name="pt-coverage">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        <mkdir dir="${lib.dir}/../coverage"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
        <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
            <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
            <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
   103
        </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
        <mkdir dir="${lib.dir}/../coverage/report"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
        <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
   107
        <record name="${lib.dir}/../coverage/report/line_coverage.txt" action="start"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        <exec executable="python" failonerror="true" dir="${lib.dir}">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
            <env key="PYTHONPATH" path="${python.path}" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
            <arg line="${python.builder.dir}/lib/coverage.py -r ${python.modules.coverage}"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
        </exec>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
        <record name="${lib.dir}/../coverage/report/line_coverage.txt" action="stop"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
        <script language="jython" setbeans="false">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
for line in open(project.getProperty('lib.dir') + r'/../coverage/report/line_coverage.txt'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
    if 'TOTAL' in line and ' 0%' in line:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
        raise Exception('Coverage at 0%')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
        <delete file="${basedir}/.coverage"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
    </target>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
</project>