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