628
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
2 |
<!--
|
|
3 |
============================================================================
|
|
4 |
Name : test_taskrecorder.ant.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-recorder" xmlns:ac="antlib:net.sf.antcontrib" xmlns:au="antlib:org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
|
|
24 |
<description>Helium Antlib logger unittests.</description>
|
|
25 |
<property environment="env" />
|
|
26 |
|
|
27 |
<taskdef resource="com/nokia/helium/logger/ant/antlib.xml" uri="http://www.nokia.com/helium" />
|
|
28 |
|
|
29 |
<target name="setUp">
|
|
30 |
<delete dir="${test.temp.dir}" failonerror="false"/>
|
|
31 |
<mkdir dir="${test.temp.dir}" />
|
|
32 |
</target>
|
|
33 |
|
|
34 |
<target name="tearDown">
|
|
35 |
<delete dir="${test.temp.dir}" />
|
|
36 |
</target>
|
|
37 |
|
|
38 |
<target name="test-missing-output-message">
|
|
39 |
<au:expectfailure expectedMessage="The output attribute has not been defined.">
|
|
40 |
<hlm:taskRecorder logLevel="info">
|
|
41 |
<echo>This message should not be logged on the screen.</echo>
|
|
42 |
</hlm:taskRecorder>
|
|
43 |
</au:expectfailure>
|
|
44 |
</target>
|
|
45 |
|
|
46 |
<target name="test-failing-log-creation">
|
|
47 |
<au:expectfailure expectedMessage="Can't set output to">
|
|
48 |
<hlm:taskRecorder output="${test.temp.dir}/inexisting/output.log" logLevel="info">
|
|
49 |
<echo>This message should not be logged on the screen.</echo>
|
|
50 |
</hlm:taskRecorder>
|
|
51 |
</au:expectfailure>
|
|
52 |
<au:assertFileDoesntExist file="${test.temp.dir}/inexisting/output.log" />
|
|
53 |
</target>
|
|
54 |
|
|
55 |
<target name="test-simple-task-recording">
|
|
56 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
57 |
<echo>This message should not be logged on the screen.</echo>
|
|
58 |
</hlm:taskRecorder>
|
|
59 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
60 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
61 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
62 |
<echo>${output.log}</echo>
|
|
63 |
<au:assertTrue>
|
|
64 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
65 |
</au:assertTrue>
|
|
66 |
</target>
|
|
67 |
|
|
68 |
<target name="test-task-recording-under-sequential">
|
|
69 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
70 |
<sequential>
|
|
71 |
<echo>This message should not be logged on the screen.</echo>
|
|
72 |
</sequential>
|
|
73 |
</hlm:taskRecorder>
|
|
74 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
75 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
76 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
77 |
<echo>${output.log}</echo>
|
|
78 |
<au:assertTrue>
|
|
79 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
80 |
</au:assertTrue>
|
|
81 |
</target>
|
|
82 |
|
|
83 |
<target name="called-by-runtarget">
|
|
84 |
<echo>This message should not be logged on the screen.</echo>
|
|
85 |
</target>
|
|
86 |
|
|
87 |
<target name="test-simple-task-runtarget">
|
|
88 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
89 |
<ac:runtarget target="called-by-runtarget" />
|
|
90 |
</hlm:taskRecorder>
|
|
91 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
92 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
93 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
94 |
<echo>${output.log}</echo>
|
|
95 |
<au:assertTrue>
|
|
96 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
97 |
</au:assertTrue>
|
|
98 |
</target>
|
|
99 |
|
|
100 |
<target name="test-recorder-propagate-properties">
|
|
101 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
102 |
<echo>Setting task.recorder.is.wicked property.</echo>
|
|
103 |
<property name="task.recorder.is.wicked" value="that's true!!!" />
|
|
104 |
</hlm:taskRecorder>
|
|
105 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
106 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
107 |
<echo>${output.log}</echo>
|
|
108 |
<au:assertTrue message="property is not propagated">
|
|
109 |
<isset property="task.recorder.is.wicked" />
|
|
110 |
</au:assertTrue>
|
|
111 |
<au:assertTrue message="property value is incorrect">
|
|
112 |
<equals arg1="${task.recorder.is.wicked}" arg2="that's true!!!"/>
|
|
113 |
</au:assertTrue>
|
|
114 |
</target>
|
|
115 |
|
|
116 |
<macrodef name="echoMacro">
|
|
117 |
<sequential>
|
|
118 |
<echo>This message should not be logged on the screen.</echo>
|
|
119 |
</sequential>
|
|
120 |
</macrodef>
|
|
121 |
|
|
122 |
<target name="test-simple-task-macro">
|
|
123 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
124 |
<echoMacro />
|
|
125 |
</hlm:taskRecorder>
|
|
126 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
127 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
128 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
129 |
<echo>${output.log}</echo>
|
|
130 |
<au:assertTrue>
|
|
131 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
132 |
</au:assertTrue>
|
|
133 |
</target>
|
|
134 |
|
|
135 |
<macrodef name="recordMacro">
|
|
136 |
<sequential>
|
|
137 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
138 |
<echo>This message should not be logged on the screen.</echo>
|
|
139 |
</hlm:taskRecorder>
|
|
140 |
</sequential>
|
|
141 |
</macrodef>
|
|
142 |
|
|
143 |
<target name="test-record-from-a-macro">
|
|
144 |
<recordMacro />
|
|
145 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
146 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
147 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
148 |
<echo>${output.log}</echo>
|
|
149 |
<au:assertTrue>
|
|
150 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
151 |
</au:assertTrue>
|
|
152 |
</target>
|
|
153 |
|
|
154 |
<target name="test-simple-task-failure">
|
|
155 |
<au:expectfailure expectedMessage="failing inside taskRecorder" >
|
|
156 |
<hlm:taskRecorder output="${test.temp.dir}/output.log" logLevel="info">
|
|
157 |
<echo>This message should not be logged on the screen.</echo>
|
|
158 |
<fail message="failing inside taskRecorder" />
|
|
159 |
</hlm:taskRecorder>
|
|
160 |
</au:expectfailure>
|
|
161 |
<au:assertLogDoesntContain text="This message should not be logged on the screen." />
|
|
162 |
<au:assertFileExists file="${test.temp.dir}/output.log" />
|
|
163 |
<loadfile property="output.log" srcfile="${test.temp.dir}/output.log" />
|
|
164 |
<echo>${output.log}</echo>
|
|
165 |
<au:assertTrue>
|
|
166 |
<contains string="${output.log}" substring="This message should not be logged on the screen." />
|
|
167 |
</au:assertTrue>
|
|
168 |
</target>
|
|
169 |
|
|
170 |
</project>
|