diff options
Diffstat (limited to 'tests/auto/qmake/tst_qmake.cpp')
-rw-r--r-- | tests/auto/qmake/tst_qmake.cpp | 84 |
1 files changed, 64 insertions, 20 deletions
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 4840b42..70f1f3c 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -39,21 +39,13 @@ ** ****************************************************************************/ - -#include <QtTest/QtTest> - -#if !defined(QMAKE_CROSS_COMPILED) && defined(QT3_SUPPORT) - -#include <qdir.h> -#include <qprocess.h> - +#if !defined(QMAKE_CROSS_COMPILED) #include "testcompiler.h" -#include <stdlib.h> - -//TESTED_CLASS= -//TESTED_FILES=corelib/tools/qlocale.h corelib/tools/qlocale.cpp +#include <QObject> +#include <QDir> +#include <QtTest/QtTest> class tst_qmake : public QObject { @@ -63,12 +55,12 @@ public: tst_qmake(); virtual ~tst_qmake(); - public slots: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); + private slots: void simple_app(); void simple_lib(); @@ -90,6 +82,10 @@ private slots: void one_space(); void findMocs(); void findDeps(); +#ifndef Q_OS_WIN + // Test requires make + void bundle_spaces(); +#endif private: TestCompiler test_compiler; @@ -100,16 +96,16 @@ tst_qmake::tst_qmake() { QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION); #ifdef Q_CC_MSVC - test_compiler.setBaseCommands( "nmake", cmd, FALSE ); + test_compiler.setBaseCommands( "nmake", cmd ); #elif defined(Q_CC_MINGW) - test_compiler.setBaseCommands( "mingw32-make", cmd, FALSE ); + test_compiler.setBaseCommands( "mingw32-make", cmd ); #elif defined(Q_OS_WIN) && defined(Q_CC_GNU) - test_compiler.setBaseCommands( "mmmake", cmd, FALSE ); + test_compiler.setBaseCommands( "mmmake", cmd ); #else - test_compiler.setBaseCommands( "make", cmd, FALSE ); + test_compiler.setBaseCommands( "make", cmd ); #endif QDir dir; - base_path = dir.currentDirPath(); + base_path = dir.currentPath(); } tst_qmake::~tst_qmake() @@ -251,10 +247,10 @@ void tst_qmake::duplicateLibraryEntries() void tst_qmake::export_across_file_boundaries() { // This relies on features so we need to set the QMAKEFEATURES environment variable - putenv("QMAKEFEATURES=."); + test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - putenv("QMAKEFEATURES="); + test_compiler.resetEnvironment(); } void tst_qmake::include_dir() @@ -377,6 +373,54 @@ void tst_qmake::findDeps() QVERIFY( test_compiler.removeMakefile(workDir) ); } +struct TempFile + : QFile +{ + TempFile(QString filename) + : QFile(filename) + { + } + + ~TempFile() + { + if (this->exists()) + this->remove(); + } +}; + +#ifndef Q_OS_WIN +void tst_qmake::bundle_spaces() +{ + QString workDir = base_path + "/testdata/bundle-spaces"; + + // We set up alternate commands here, to make sure we're testing Mac + // Bundles and since this might be the wrong output we rely on dry-running + // make (-n). + + TestCompiler local_tc; + local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); + + QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); + + TempFile non_existing_file(workDir + "/non-existing file"); + QVERIFY( !non_existing_file.exists() ); + + // Make fails: no rule to make "non-existing file" + QVERIFY( !local_tc.make(workDir) ); + + QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); + QVERIFY( non_existing_file.exists() ); + + // Aha! + QVERIFY( local_tc.make(workDir) ); + + // Cleanup + QVERIFY( non_existing_file.remove() ); + QVERIFY( !non_existing_file.exists() ); + QVERIFY( local_tc.removeMakefile(workDir) ); +} +#endif // Q_OS_WIN + QTEST_MAIN(tst_qmake) #include "tst_qmake.moc" |