Thiago Macieira said: > On quarta-feira, 13 de junho de 2012 17.32.43, Friedemann Kleint wrote: > > In Qt 5, this was solved by introducing the QFINDTESTDATA macro, but > > porting it to Qt 4 is a non-trivial task. > > > > https://codereview.qt-project.org/#change,28579 (Fix QLibrary test) and > > https://codereview.qt-project.org/#change,27579 (QApplication) > > illustrate what needs to be done for such cases: > > > > - Removing CONFIG -= app_bundle causes the Mac binary to be created in > > the test root folder > > > > - On Windows, cd up one level if the current working directory is > > 'debug' or 'release' in the test constructor > > Another solution we used to use is to add to the test's .pro file: > > DEFINES += SRCDIR=\\\"$$PWD/\\\" > > Then all file references should be prefixed with SRCDIR. E.g: > > QFile f(SRCDIR "./testdata"); > > Don't forget the space! It's an error to write SRCDIR"./testdata" in C++11. >
Please avoid this one in Qt 5. It makes the test not able to work when deployed to a device, unless you explicitly recreate the whole SRCDIR directory structure on the device or introduce a separate code path in the test. QFINDTESTDATA should be preferred, since it already searches the source directory. It is reasonable to fix the Qt 4.8 tests in this way, though. _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development