53 </copy> |
52 </copy> |
54 </target> |
53 </target> |
55 |
54 |
56 <!-- Do Python tests. --> |
55 <!-- Do Python tests. --> |
57 <target name="do-py-unittest" depends="setup-py-unittest"> |
56 <target name="do-py-unittest" depends="setup-py-unittest"> |
58 <property name="nose.args" value="nokiatest test"/> |
57 <property name="nose.args" value="cpythontest nokiacpythontest nokiatest test"/> |
59 <exec executable="python" failonerror="true"> |
58 <exec executable="python" failonerror="true"> |
60 <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/> |
59 <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/> |
61 </exec> |
60 </exec> |
|
61 <script language="jython" setbeans="false"> |
|
62 import sys |
|
63 import os |
|
64 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/nose-0.11.1-py2.6.egg')) |
|
65 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/mocker-0.10.1-py2.5.egg')) |
|
66 import nose |
|
67 args = project.getProperty('nose.args') |
|
68 if args == 'cpythontest nokiacpythontest nokiatest test': |
|
69 nose.run(argv=['-v', os.path.join(os.environ['HELIUM_HOME'], 'tools/common/python/lib/test'), 'nokiatest']) |
|
70 elif args.startswith('nokiatest.') or args.startswith('test.'): |
|
71 nose.run(argv=['-v', args]) |
|
72 print >> sys.stderr |
|
73 </script> |
62 </target> |
74 </target> |
63 |
75 |
64 <!-- Shortcut for Python unit tests. --> |
76 <!-- Shortcut for Python unit tests. --> |
65 <target name="pt" depends="do-py-unittest"/> |
77 <target name="pt" depends="do-py-unittest"/> |
66 |
78 |
67 |
79 |
68 <!-- Create Python code coverage statistics. --> |
80 <!-- Create Python code coverage statistics. --> |
69 <target name="py-unittest-coverage"> |
81 <target name="py-unittest-coverage"> |
70 <mkdir dir="${helium.dir}/build/coverage"/> |
82 <mkdir dir="${helium.build.dir}/coverage"/> |
71 <pathconvert pathsep=" " property="python.modules.coverage"> |
83 <pathconvert pathsep=" " property="python.modules.coverage"> |
72 <fileset refid="python.files"/> |
84 <fileset refid="python.files"/> |
73 </pathconvert> |
85 </pathconvert> |
74 <exec executable="python" failonerror="true"> |
86 <exec executable="python" failonerror="true"> |
75 <arg line="${python.tools}/coverage.py -a -d ${helium.dir}/build/coverage ${python.modules.coverage}"/> |
87 <arg line="${python.tools}/coverage.py -a -d ${helium.build.dir}/coverage ${python.modules.coverage}"/> |
76 </exec> |
88 </exec> |
77 |
89 |
78 <!-- backup the old line coverage report and create the new one --> |
90 <!-- backup the old line coverage report and create the new one --> |
79 <mkdir dir="${helium.dir}/build/coverage/report"/> |
91 <mkdir dir="${helium.build.dir}/coverage/report"/> |
80 <if> |
92 <if> |
81 <available file="${helium.dir}/build/coverage/report/line_coverage.txt"/> |
93 <available file="${helium.build.dir}/coverage/report/line_coverage.txt"/> |
82 <then> |
94 <then> |
83 <copy file="${helium.dir}/build/coverage/report/line_coverage.txt" tofile="${helium.dir}/build/coverage/report/line_coverage_old.txt" overwrite="true"/> |
95 <copy file="${helium.build.dir}/coverage/report/line_coverage.txt" tofile="${helium.build.dir}/coverage/report/line_coverage_old.txt" overwrite="true"/> |
84 </then> |
96 </then> |
85 </if> |
97 </if> |
86 <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="start"/> |
98 <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="start"/> |
87 <exec executable="python" failonerror="true"> |
99 <exec executable="python" failonerror="true"> |
88 <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/> |
100 <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/> |
89 </exec> |
101 </exec> |
90 <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="stop"/> |
102 <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="stop"/> |
91 <replace file="${helium.dir}/build/coverage/report/line_coverage.txt"> |
103 <replace file="${helium.build.dir}/coverage/report/line_coverage.txt"> |
92 <replacetoken><![CDATA[[exec]]]></replacetoken> |
104 <replacetoken><![CDATA[[exec]]]></replacetoken> |
93 <replacevalue><![CDATA[]]></replacevalue> |
105 <replacevalue><![CDATA[]]></replacevalue> |
94 </replace> |
106 </replace> |
95 <hlm:python> |
107 <hlm:python> |
96 for line in open(r'${helium.dir}/build/coverage/report/line_coverage.txt'): |
108 for line in open(r'${helium.build.dir}/coverage/report/line_coverage.txt'): |
97 if 'TOTAL' in line and '0%' in line: |
109 if 'TOTAL' in line and ' 0%' in line: |
98 raise Exception('Coverage at 0%') |
110 raise Exception('Coverage at 0%') |
99 </hlm:python> |
111 </hlm:python> |
100 <delete file="${helium.dir}/.coverage"/> |
112 <delete file="${helium.dir}/.coverage"/> |
101 </target> |
113 </target> |
102 |
114 |