author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 18 | 2f34d5167611 |
child 37 | 758a864f9613 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QtTest/QtTest> |
|
43 |
||
44 |
#if !defined(QMAKE_CROSS_COMPILED) |
|
45 |
||
46 |
#include "testcompiler.h" |
|
47 |
||
48 |
#include <QObject> |
|
49 |
#include <QDir> |
|
50 |
||
51 |
class tst_qmake : public QObject |
|
52 |
{ |
|
53 |
Q_OBJECT |
|
54 |
||
55 |
public: |
|
56 |
tst_qmake(); |
|
57 |
virtual ~tst_qmake(); |
|
58 |
||
59 |
public slots: |
|
60 |
void initTestCase(); |
|
61 |
void cleanupTestCase(); |
|
62 |
void init(); |
|
63 |
void cleanup(); |
|
64 |
||
65 |
private slots: |
|
66 |
void simple_app(); |
|
67 |
void simple_app_shadowbuild(); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
68 |
void simple_app_shadowbuild2(); |
0 | 69 |
void simple_lib(); |
70 |
void simple_dll(); |
|
71 |
void subdirs(); |
|
72 |
void functions(); |
|
73 |
void operators(); |
|
74 |
void variables(); |
|
75 |
void func_export(); |
|
76 |
void func_variables(); |
|
77 |
void comments(); |
|
78 |
void duplicateLibraryEntries(); |
|
79 |
void export_across_file_boundaries(); |
|
80 |
void include_dir(); |
|
81 |
void install_files(); |
|
82 |
void install_depends(); |
|
83 |
void quotedfilenames(); |
|
84 |
void prompt(); |
|
85 |
void one_space(); |
|
86 |
void findMocs(); |
|
87 |
void findDeps(); |
|
88 |
#ifndef Q_OS_WIN |
|
89 |
// Test requires make |
|
90 |
void bundle_spaces(); |
|
91 |
#endif |
|
92 |
void includefunction(); |
|
93 |
||
94 |
private: |
|
95 |
TestCompiler test_compiler; |
|
96 |
QString base_path; |
|
97 |
}; |
|
98 |
||
99 |
tst_qmake::tst_qmake() |
|
100 |
{ |
|
101 |
QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION); |
|
102 |
#ifdef Q_CC_MSVC |
|
103 |
test_compiler.setBaseCommands( "nmake", cmd ); |
|
104 |
#elif defined(Q_CC_MINGW) |
|
105 |
test_compiler.setBaseCommands( "mingw32-make", cmd ); |
|
106 |
#elif defined(Q_OS_WIN) && defined(Q_CC_GNU) |
|
107 |
test_compiler.setBaseCommands( "mmmake", cmd ); |
|
108 |
#else |
|
109 |
test_compiler.setBaseCommands( "make", cmd ); |
|
110 |
#endif |
|
111 |
QDir dir; |
|
112 |
base_path = dir.currentPath(); |
|
113 |
} |
|
114 |
||
115 |
tst_qmake::~tst_qmake() |
|
116 |
{ |
|
117 |
||
118 |
} |
|
119 |
||
120 |
void tst_qmake::initTestCase() |
|
121 |
{ |
|
122 |
} |
|
123 |
||
124 |
void tst_qmake::cleanupTestCase() |
|
125 |
{ |
|
126 |
} |
|
127 |
||
128 |
void tst_qmake::init() |
|
129 |
{ |
|
130 |
test_compiler.clearCommandOutput(); |
|
131 |
} |
|
132 |
||
133 |
void tst_qmake::cleanup() |
|
134 |
{ |
|
135 |
test_compiler.clearCommandOutput(); |
|
136 |
} |
|
137 |
||
138 |
void tst_qmake::simple_app() |
|
139 |
{ |
|
140 |
QString workDir = base_path + "/testdata/simple_app"; |
|
141 |
||
142 |
QVERIFY( test_compiler.qmake( workDir, "simple_app" )); |
|
143 |
QVERIFY( test_compiler.make( workDir )); |
|
144 |
QVERIFY( test_compiler.exists( workDir, "simple_app", Exe, "1.0.0" )); |
|
145 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
146 |
QVERIFY( test_compiler.exists( workDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean |
|
147 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
148 |
QVERIFY( !test_compiler.exists( workDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean |
|
149 |
QVERIFY( test_compiler.removeMakefile( workDir ) ); |
|
150 |
} |
|
151 |
||
152 |
void tst_qmake::simple_app_shadowbuild() |
|
153 |
{ |
|
154 |
QString workDir = base_path + "/testdata/simple_app"; |
|
155 |
QString buildDir = base_path + "/testdata/simple_app_build"; |
|
156 |
||
157 |
QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir )); |
|
158 |
QVERIFY( test_compiler.make( buildDir )); |
|
159 |
QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); |
|
160 |
QVERIFY( test_compiler.makeClean( buildDir )); |
|
161 |
QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean |
|
162 |
QVERIFY( test_compiler.makeDistClean( buildDir )); |
|
163 |
QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean |
|
164 |
QVERIFY( test_compiler.removeMakefile( buildDir ) ); |
|
165 |
} |
|
166 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
167 |
void tst_qmake::simple_app_shadowbuild2() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
168 |
{ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
169 |
QString workDir = base_path + "/testdata/simple_app"; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
170 |
QString buildDir = base_path + "/testdata/simple_app/build"; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
171 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
172 |
QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir )); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
173 |
QVERIFY( test_compiler.make( buildDir )); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
174 |
QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
175 |
QVERIFY( test_compiler.makeClean( buildDir )); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
176 |
QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
177 |
QVERIFY( test_compiler.makeDistClean( buildDir )); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
178 |
QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
179 |
QVERIFY( test_compiler.removeMakefile( buildDir ) ); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
180 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
181 |
|
0 | 182 |
void tst_qmake::simple_dll() |
183 |
{ |
|
184 |
QString workDir = base_path + "/testdata/simple_dll"; |
|
185 |
||
186 |
QDir D; |
|
187 |
D.remove( workDir + "/Makefile"); |
|
188 |
QVERIFY( test_compiler.qmake( workDir, "simple_dll" )); |
|
189 |
QVERIFY( test_compiler.make( workDir )); |
|
190 |
QVERIFY( test_compiler.exists( workDir, "simple_dll", Dll, "1.0.0" )); |
|
191 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
192 |
QVERIFY( test_compiler.exists( workDir, "simple_dll", Dll, "1.0.0" )); // Should still exist after a make clean |
|
193 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
194 |
QVERIFY( !test_compiler.exists( workDir, "simple_dll", Dll, "1.0.0" )); // Should not exist after a make distclean |
|
195 |
QVERIFY( test_compiler.removeMakefile( workDir ) ); |
|
196 |
} |
|
197 |
||
198 |
void tst_qmake::simple_lib() |
|
199 |
{ |
|
200 |
QString workDir = base_path + "/testdata/simple_lib"; |
|
201 |
||
202 |
QDir D; |
|
203 |
D.remove( workDir + "/Makefile"); |
|
204 |
QVERIFY( test_compiler.qmake( workDir, "simple_lib" )); |
|
205 |
QVERIFY( test_compiler.make( workDir )); |
|
206 |
QVERIFY( test_compiler.exists( workDir, "simple_lib", Lib, "1.0.0" )); |
|
207 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
208 |
QVERIFY( test_compiler.exists( workDir, "simple_lib", Lib, "1.0.0" )); // Should still exist after a make clean |
|
209 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
210 |
QVERIFY( !test_compiler.exists( workDir, "simple_lib", Lib, "1.0.0" )); // Should not exist after a make distclean |
|
211 |
QVERIFY( test_compiler.removeMakefile( workDir ) ); |
|
212 |
} |
|
213 |
||
214 |
void tst_qmake::subdirs() |
|
215 |
{ |
|
216 |
QString workDir = base_path + "/testdata/subdirs"; |
|
217 |
||
218 |
QDir D; |
|
219 |
D.remove( workDir + "/simple_app/Makefile"); |
|
220 |
D.remove( workDir + "/simple_dll/Makefile"); |
|
221 |
QVERIFY( test_compiler.qmake( workDir, "subdirs" )); |
|
222 |
QVERIFY( test_compiler.make( workDir )); |
|
223 |
QVERIFY( test_compiler.exists( workDir + "/simple_app", "simple_app", Exe, "1.0.0" )); |
|
224 |
QVERIFY( test_compiler.exists( workDir + "/simple_dll", "simple_dll", Dll, "1.0.0" )); |
|
225 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
226 |
// Should still exist after a make clean |
|
227 |
QVERIFY( test_compiler.exists( workDir + "/simple_app", "simple_app", Exe, "1.0.0" )); |
|
228 |
QVERIFY( test_compiler.exists( workDir + "/simple_dll", "simple_dll", Dll, "1.0.0" )); |
|
229 |
// Since subdirs templates do not have a make dist clean, we should clean up ourselves |
|
230 |
// properly |
|
231 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
232 |
QVERIFY( test_compiler.removeMakefile( workDir ) ); |
|
233 |
} |
|
234 |
||
235 |
void tst_qmake::functions() |
|
236 |
{ |
|
237 |
QString workDir = base_path + "/testdata/functions"; |
|
238 |
QVERIFY( test_compiler.qmake( workDir, "functions" )); |
|
239 |
} |
|
240 |
||
241 |
void tst_qmake::operators() |
|
242 |
{ |
|
243 |
QString workDir = base_path + "/testdata/operators"; |
|
244 |
QVERIFY( test_compiler.qmake( workDir, "operators" )); |
|
245 |
} |
|
246 |
||
247 |
void tst_qmake::variables() |
|
248 |
{ |
|
249 |
QString workDir = base_path + "/testdata/variables"; |
|
250 |
QVERIFY(test_compiler.qmake( workDir, "variables" )); |
|
251 |
} |
|
252 |
||
253 |
void tst_qmake::func_export() |
|
254 |
{ |
|
255 |
QString workDir = base_path + "/testdata/func_export"; |
|
256 |
QVERIFY(test_compiler.qmake( workDir, "func_export" )); |
|
257 |
} |
|
258 |
||
259 |
void tst_qmake::func_variables() |
|
260 |
{ |
|
261 |
QString workDir = base_path + "/testdata/func_variables"; |
|
262 |
QVERIFY(test_compiler.qmake( workDir, "func_variables" )); |
|
263 |
} |
|
264 |
||
265 |
void tst_qmake::comments() |
|
266 |
{ |
|
267 |
QString workDir = base_path + "/testdata/comments"; |
|
268 |
QVERIFY(test_compiler.qmake( workDir, "comments" )); |
|
269 |
} |
|
270 |
||
271 |
void tst_qmake::duplicateLibraryEntries() |
|
272 |
{ |
|
273 |
QVERIFY(true); |
|
274 |
/* TODO: this test does not work as the problem it tests doesn't happen |
|
275 |
until after the parsing of the pro-file and thus has to be tested |
|
276 |
by parsing the Makefile. This is not doable with the current |
|
277 |
testcompiler framework and has as such been put on hold. |
|
278 |
||
279 |
QString workDir = base_path + "/testdata/duplicateLibraryEntries"; |
|
280 |
QVERIFY(test_compiler.qmake(workDir, "duplicateLibraryEntries")); */ |
|
281 |
} |
|
282 |
||
283 |
void tst_qmake::export_across_file_boundaries() |
|
284 |
{ |
|
285 |
// This relies on features so we need to set the QMAKEFEATURES environment variable |
|
286 |
test_compiler.addToEnvironment("QMAKEFEATURES=."); |
|
287 |
QString workDir = base_path + "/testdata/export_across_file_boundaries"; |
|
288 |
QVERIFY( test_compiler.qmake( workDir, "foo" )); |
|
289 |
test_compiler.resetEnvironment(); |
|
290 |
} |
|
291 |
||
292 |
void tst_qmake::include_dir() |
|
293 |
{ |
|
294 |
QString workDir = base_path + "/testdata/include_dir"; |
|
295 |
QVERIFY( test_compiler.qmake( workDir, "foo" )); |
|
296 |
QVERIFY( test_compiler.make( workDir )); |
|
297 |
QVERIFY( test_compiler.exists( workDir, "foo", Exe, "1.0.0" )); |
|
298 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
299 |
||
300 |
QString buildDir = base_path + "/testdata/include_dir_build"; |
|
301 |
QVERIFY( test_compiler.qmake( workDir, "foo", buildDir )); |
|
302 |
QVERIFY( test_compiler.make( buildDir )); |
|
303 |
QVERIFY( test_compiler.exists( buildDir, "foo", Exe, "1.0.0" )); |
|
304 |
QVERIFY( test_compiler.makeDistClean( buildDir )); |
|
305 |
} |
|
306 |
||
307 |
void tst_qmake::install_files() |
|
308 |
{ |
|
309 |
QString workDir = base_path + "/testdata/shadow_files"; |
|
310 |
QVERIFY( test_compiler.qmake( workDir, "foo" )); |
|
311 |
QVERIFY( test_compiler.make( workDir )); |
|
312 |
QVERIFY( test_compiler.exists( workDir, "foo", Exe, "1.0.0" )); |
|
313 |
QVERIFY( test_compiler.make( workDir, "install" )); |
|
314 |
QVERIFY( test_compiler.exists( workDir + "/dist", "foo", Exe, "1.0.0" )); |
|
315 |
QVERIFY( test_compiler.exists( workDir + "/dist", "test.txt", Plain, "1.0.0" )); |
|
316 |
QVERIFY( test_compiler.make( workDir, "uninstall" )); |
|
317 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
318 |
||
319 |
QString buildDir = base_path + "/testdata/shadow_files_build"; |
|
320 |
QVERIFY( test_compiler.qmake( workDir, "foo", buildDir )); |
|
321 |
QVERIFY( test_compiler.make( buildDir )); |
|
322 |
QVERIFY( test_compiler.exists( buildDir, "foo", Exe, "1.0.0" )); |
|
323 |
QVERIFY( test_compiler.make( buildDir, "install" )); |
|
324 |
QVERIFY( test_compiler.exists( workDir + "/dist", "foo", Exe, "1.0.0" )); |
|
325 |
QVERIFY( test_compiler.exists( workDir + "/dist", "test.txt", Plain, "1.0.0" )); |
|
326 |
QVERIFY( test_compiler.exists( workDir + "/dist", "foo.bar", Plain, "1.0.0" )); |
|
327 |
QVERIFY( test_compiler.make( buildDir, "uninstall" )); |
|
328 |
QVERIFY( test_compiler.makeDistClean( buildDir )); |
|
329 |
} |
|
330 |
||
331 |
void tst_qmake::install_depends() |
|
332 |
{ |
|
333 |
QString workDir = base_path + "/testdata/install_depends"; |
|
334 |
QVERIFY( test_compiler.qmake( workDir, "foo" )); |
|
335 |
QVERIFY( test_compiler.make( workDir )); |
|
336 |
QVERIFY( test_compiler.exists( workDir, "foo", Exe, "1.0.0" )); |
|
337 |
QVERIFY( test_compiler.make( workDir, "install" )); |
|
338 |
QVERIFY( test_compiler.exists( workDir + "/dist", "foo", Exe, "1.0.0" )); |
|
339 |
QVERIFY( test_compiler.exists( workDir + "/dist", "test1", Plain, "1.0.0" )); |
|
340 |
QVERIFY( test_compiler.exists( workDir + "/dist", "test2", Plain, "1.0.0" )); |
|
341 |
QVERIFY( test_compiler.make( workDir, "uninstall" )); |
|
342 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
343 |
} |
|
344 |
void tst_qmake::quotedfilenames() |
|
345 |
{ |
|
346 |
QString workDir = base_path + "/testdata/quotedfilenames"; |
|
347 |
QVERIFY( test_compiler.qmake( workDir, "quotedfilenames" )); |
|
348 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
349 |
QVERIFY( test_compiler.make( workDir )); |
|
350 |
QVERIFY( test_compiler.exists( workDir, "quotedfilenames", Exe, "1.0.0" )); |
|
351 |
} |
|
352 |
||
353 |
void tst_qmake::prompt() |
|
354 |
{ |
|
355 |
#if 0 |
|
356 |
QProcess qmake; |
|
357 |
qmake.setReadChannelMode(QProcess::MergedChannels); |
|
358 |
qmake.setWorkingDirectory(QLatin1String("testdata/prompt")); |
|
359 |
qmake.start(QLatin1String("qmake CONFIG-=debug_and_release CONFIG-=debug CONFIG+=release"), |
|
360 |
QIODevice::Text | QIODevice::ReadWrite); |
|
361 |
QVERIFY(qmake.waitForStarted(20000)); |
|
362 |
QByteArray read = qmake.readAll(); |
|
363 |
qDebug() << read; |
|
364 |
QCOMPARE(read, QByteArray("Project PROMPT: Prompteroo? ")); |
|
365 |
qmake.write("promptetiprompt\n"); |
|
366 |
QVERIFY(qmake.waitForFinished(20000)); |
|
367 |
#endif |
|
368 |
} |
|
369 |
||
370 |
void tst_qmake::one_space() |
|
371 |
{ |
|
372 |
QString workDir = base_path + "/testdata/one_space"; |
|
373 |
||
374 |
QVERIFY( test_compiler.qmake( workDir, "one_space" )); |
|
375 |
QVERIFY( test_compiler.make( workDir )); |
|
376 |
QVERIFY( test_compiler.exists( workDir, "one space", Exe, "1.0.0" )); |
|
377 |
QVERIFY( test_compiler.makeClean( workDir )); |
|
378 |
QVERIFY( test_compiler.exists( workDir, "one space", Exe, "1.0.0" )); // Should still exist after a make clean |
|
379 |
QVERIFY( test_compiler.makeDistClean( workDir )); |
|
380 |
QVERIFY( !test_compiler.exists( workDir, "one space", Exe, "1.0.0" )); // Should not exist after a make distclean |
|
381 |
QVERIFY( test_compiler.removeMakefile( workDir ) ); |
|
382 |
} |
|
383 |
||
384 |
void tst_qmake::findMocs() |
|
385 |
{ |
|
386 |
QString workDir = base_path + "/testdata/findMocs"; |
|
387 |
||
388 |
QVERIFY( test_compiler.qmake(workDir, "findMocs") ); |
|
389 |
QVERIFY( test_compiler.make(workDir) ); |
|
390 |
QVERIFY( test_compiler.exists(workDir, "findMocs", Exe, "1.0.0" ) ); |
|
391 |
QVERIFY( test_compiler.makeClean(workDir) ); |
|
392 |
QVERIFY( test_compiler.exists(workDir, "findMocs", Exe, "1.0.0" ) ); |
|
393 |
QVERIFY( test_compiler.makeDistClean(workDir ) ); |
|
394 |
QVERIFY( !test_compiler.exists(workDir, "findMocs", Exe, "1.0.0" ) ); |
|
395 |
QVERIFY( test_compiler.removeMakefile(workDir) ); |
|
396 |
} |
|
397 |
||
398 |
void tst_qmake::findDeps() |
|
399 |
{ |
|
400 |
QString workDir = base_path + "/testdata/findDeps"; |
|
401 |
||
402 |
QVERIFY( test_compiler.qmake(workDir, "findDeps") ); |
|
403 |
QVERIFY( test_compiler.make(workDir) ); |
|
404 |
QVERIFY( test_compiler.exists(workDir, "findDeps", Exe, "1.0.0" ) ); |
|
405 |
QVERIFY( test_compiler.makeClean(workDir) ); |
|
406 |
QVERIFY( test_compiler.exists(workDir, "findDeps", Exe, "1.0.0" ) ); |
|
407 |
QVERIFY( test_compiler.makeDistClean(workDir ) ); |
|
408 |
QVERIFY( !test_compiler.exists(workDir, "findDeps", Exe, "1.0.0" ) ); |
|
409 |
QVERIFY( test_compiler.removeMakefile(workDir) ); |
|
410 |
} |
|
411 |
||
412 |
struct TempFile |
|
413 |
: QFile |
|
414 |
{ |
|
415 |
TempFile(QString filename) |
|
416 |
: QFile(filename) |
|
417 |
{ |
|
418 |
} |
|
419 |
||
420 |
~TempFile() |
|
421 |
{ |
|
422 |
if (this->exists()) |
|
423 |
this->remove(); |
|
424 |
} |
|
425 |
}; |
|
426 |
||
427 |
#ifndef Q_OS_WIN |
|
428 |
void tst_qmake::bundle_spaces() |
|
429 |
{ |
|
430 |
QString workDir = base_path + "/testdata/bundle-spaces"; |
|
431 |
||
432 |
// We set up alternate commands here, to make sure we're testing Mac |
|
433 |
// Bundles and since this might be the wrong output we rely on dry-running |
|
434 |
// make (-n). |
|
435 |
||
436 |
TestCompiler local_tc; |
|
437 |
local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); |
|
438 |
||
439 |
QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); |
|
440 |
||
441 |
TempFile non_existing_file(workDir + "/non-existing file"); |
|
442 |
QVERIFY( !non_existing_file.exists() ); |
|
443 |
||
444 |
// Make fails: no rule to make "non-existing file" |
|
445 |
QVERIFY( !local_tc.make(workDir) ); |
|
446 |
||
447 |
QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); |
|
448 |
QVERIFY( non_existing_file.exists() ); |
|
449 |
||
450 |
// Aha! |
|
451 |
QVERIFY( local_tc.make(workDir) ); |
|
452 |
||
453 |
// Cleanup |
|
454 |
QVERIFY( non_existing_file.remove() ); |
|
455 |
QVERIFY( !non_existing_file.exists() ); |
|
456 |
QVERIFY( local_tc.removeMakefile(workDir) ); |
|
457 |
} |
|
458 |
#endif // Q_OS_WIN |
|
459 |
||
460 |
void tst_qmake::includefunction() |
|
461 |
{ |
|
462 |
QString workDir = base_path + "/testdata/include_function"; |
|
463 |
QString warningMsg("Unable to find file for inclusion"); |
|
464 |
QVERIFY(test_compiler.qmake( workDir, "include_existing_file")); |
|
465 |
QVERIFY(!test_compiler.commandOutput().contains(warningMsg)); |
|
466 |
||
467 |
// test include() usage on a missing file |
|
468 |
test_compiler.clearCommandOutput(); |
|
469 |
workDir = base_path + "/testdata/include_function"; |
|
470 |
QVERIFY(test_compiler.qmake( workDir, "include_missing_file" )); |
|
471 |
QVERIFY(test_compiler.commandOutput().contains(warningMsg)); |
|
472 |
||
473 |
// test include() usage on a missing file when all function parameters are used |
|
474 |
test_compiler.clearCommandOutput(); |
|
475 |
workDir = base_path + "/testdata/include_function"; |
|
476 |
QVERIFY(test_compiler.qmake( workDir, "include_missing_file2" )); |
|
477 |
QVERIFY(test_compiler.commandOutput().contains(warningMsg)); |
|
478 |
} |
|
479 |
||
480 |
QTEST_MAIN(tst_qmake) |
|
481 |
#include "tst_qmake.moc" |
|
482 |
||
483 |
#else // QMAKE_CROSS_COMPILED |
|
484 |
QTEST_NOOP_MAIN |
|
485 |
#endif |