diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-09-28 13:41:15 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-30 07:02:24 +0200 |
commit | 3f10b20e56c0f5a3768becf8a9e21b5d00a66bc1 (patch) | |
tree | 9cacee6fdb7be5b66cb1642b03486d93d8e3c41d /tests | |
parent | 5267c575d60b9f1f0415e8affbd38c28c4cd3873 (diff) |
Fix autotests that no longer find executables on Windows.
The tests are now run from the 'debug',
'release' subdirectories on Windows by 'make check'.
Go up one directory so that the relative paths are correct.
Non-network tests.
Change-Id: I8d0f806ff6708c3111a39c861ed46b21881acc7b
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/q3process/tst/tst.pro | 2 | ||||
-rw-r--r-- | tests/auto/q3process/tst_q3process.cpp | 15 | ||||
-rw-r--r-- | tests/auto/qclipboard/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/qclipboard/tst_qclipboard.cpp | 35 | ||||
-rw-r--r-- | tests/auto/qlocale/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/qlocale/tst_qlocale.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 36 | ||||
-rw-r--r-- | tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp | 20 | ||||
-rw-r--r-- | tests/auto/quuid/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/quuid/tst_quuid.cpp | 42 | ||||
-rw-r--r-- | tests/auto/selftests/test/test.pro | 3 | ||||
-rw-r--r-- | tests/auto/selftests/tst_selftests.cpp | 26 |
13 files changed, 155 insertions, 57 deletions
diff --git a/tests/auto/q3process/tst/tst.pro b/tests/auto/q3process/tst/tst.pro index 35052aa5da..7cd899cff7 100644 --- a/tests/auto/q3process/tst/tst.pro +++ b/tests/auto/q3process/tst/tst.pro @@ -13,5 +13,3 @@ win32 { QT += qt3support requires(contains(QT_CONFIG,qt3support)) - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/q3process/tst_q3process.cpp b/tests/auto/q3process/tst_q3process.cpp index f2e5325716..91b9375b1f 100644 --- a/tests/auto/q3process/tst_q3process.cpp +++ b/tests/auto/q3process/tst_q3process.cpp @@ -44,6 +44,7 @@ #include <q3process.h> #include <qregexp.h> +#include <qdir.h> #include <qdebug.h> QT_FORWARD_DECLARE_CLASS(Q3Process) @@ -57,10 +58,9 @@ class tst_Q3Process : public QObject public: tst_Q3Process(); - virtual ~tst_Q3Process(); - public slots: + void initTestCase(); void init(); void cleanup(); private slots: @@ -93,8 +93,17 @@ tst_Q3Process::tst_Q3Process() { } -tst_Q3Process::~tst_Q3Process() +void tst_Q3Process::initTestCase() { +#ifdef Q_OS_WIN + // cd up to be able to locate the binary of the sub-process. + QDir workingDirectory = QDir::current(); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif } void tst_Q3Process::init() diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro index c15162c0f5..2e8f6dbe8d 100644 --- a/tests/auto/qclipboard/test/test.pro +++ b/tests/auto/qclipboard/test/test.pro @@ -30,5 +30,3 @@ wince*|symbian: { DEPLOYMENT += copier paster rsc reg_resource } - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp index 79213ea8b2..e6b3aa6cd7 100644 --- a/tests/auto/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/qclipboard/tst_qclipboard.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <QtCore/QDebug> +#include <QtCore/QDir> #include <QtGui/QApplication> #include <QtGui/QClipboard> #ifdef Q_WS_MAC @@ -63,7 +64,7 @@ class tst_QClipboard : public QObject { Q_OBJECT private slots: - + void initTestCase(); void copy_exit_paste(); void capabiliyFunctions(); void modes(); @@ -78,8 +79,36 @@ private slots: private: bool nativeClipboardWorking(); + + QString m_copier; + QString m_paster; }; +void tst_QClipboard::initTestCase() +{ + QDir workingDirectory = QDir::current(); + QString copier = QLatin1String("copier/copier"); + QString paster = QLatin1String("paster/paster"); + // Windows: cd up to be able to locate the binary of the sub-process. +#ifdef Q_OS_WIN + const QString suffix = QLatin1String(".exe"); + copier.append(suffix); + paster.append(suffix); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif + m_copier = workingDirectory.absoluteFilePath(copier); + m_paster = workingDirectory.absoluteFilePath(paster); + QVERIFY2(QFileInfo(m_copier).exists(), + qPrintable(QString::fromLatin1("Copier executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_copier)))); + QVERIFY2(QFileInfo(m_paster).exists(), + qPrintable(QString::fromLatin1("Paster executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_paster)))); +} bool tst_QClipboard::nativeClipboardWorking() { @@ -215,12 +244,12 @@ void tst_QClipboard::copy_exit_paste() if (!nativeClipboardWorking()) QSKIP("Native clipboard not working in this setup", SkipAll); const QStringList stringArgument = QStringList() << "Test string."; - QCOMPARE(QProcess::execute("copier/copier", stringArgument), 0); + QCOMPARE(QProcess::execute(m_copier, stringArgument), 0); #ifdef Q_WS_MAC // The Pasteboard needs a moment to breathe (at least on older Macs). QTest::qWait(100); #endif - QCOMPARE(QProcess::execute("paster/paster", stringArgument), 0); + QCOMPARE(QProcess::execute(m_paster, stringArgument), 0); #endif } diff --git a/tests/auto/qlocale/test/test.pro b/tests/auto/qlocale/test/test.pro index b5023d7fbc..174eade3d2 100644 --- a/tests/auto/qlocale/test/test.pro +++ b/tests/auto/qlocale/test/test.pro @@ -35,5 +35,3 @@ symbian:contains(S60_VERSION,3.2) { } symbian: INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE # Needed for e32svr.h in S^3 envs - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 0ffca9e585..ae465091fb 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <math.h> #include <qglobal.h> +#include <qdir.h> #include <qtextcodec.h> #include <qdatetime.h> #include <float.h> @@ -88,6 +89,7 @@ public: tst_QLocale(); private slots: + void initTestCase(); void windowsDefaultLocale(); void macDefaultLocale(); @@ -148,6 +150,7 @@ private slots: private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; + QString m_sysLocaleApp; }; tst_QLocale::tst_QLocale() @@ -155,6 +158,25 @@ tst_QLocale::tst_QLocale() qRegisterMetaType<QLocale::FormatType>("QLocale::FormatType"); } +void tst_QLocale::initTestCase() +{ + QDir workingDirectory = QDir::current(); + QString sysLocaleApp = QLatin1String("syslocaleapp/syslocaleapp"); + // Windows: cd up to be able to locate the binary of the sub-process. +#ifdef Q_OS_WIN + sysLocaleApp.append(QLatin1String(".exe")); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif + m_sysLocaleApp = workingDirectory.absoluteFilePath(sysLocaleApp); + QVERIFY2(QFileInfo(m_sysLocaleApp).exists(), + qPrintable(QString::fromLatin1("SysLocalApp executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_sysLocaleApp)))); +} + void tst_QLocale::ctor() { #ifdef Q_OS_WINCE @@ -383,7 +405,8 @@ void tst_QLocale::emptyCtor() /* because of caching of the system locale. */ \ QProcess process; \ process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \ - process.start("syslocaleapp/syslocaleapp"); \ + process.start(m_sysLocaleApp); \ + QVERIFY(process.waitForStarted()); \ process.waitForReadyRead(); \ QString ret = QString(process.readAll()); \ process.waitForFinished(); \ diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro index 58b36efe4b..b7e0786f5f 100644 --- a/tests/auto/qlocalsocket/test/test.pro +++ b/tests/auto/qlocalsocket/test/test.pro @@ -47,5 +47,3 @@ wince*|symbian { requires(contains(QT_CONFIG,script)) } - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index c6ac8547e5..0d23186b68 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -45,6 +45,7 @@ #include <qtextstream.h> #include <QtNetwork/qlocalsocket.h> #include <QtNetwork/qlocalserver.h> +#include <QtCore/QDir> #include "../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -64,11 +65,8 @@ class tst_QLocalSocket : public QObject { Q_OBJECT -public: - tst_QLocalSocket(); - virtual ~tst_QLocalSocket(); - public Q_SLOTS: + void initTestCase(); void init(); void cleanup(); @@ -122,20 +120,28 @@ private slots: private: void unlink(QString serverName); #endif + +private: + QString m_lackey; }; -tst_QLocalSocket::tst_QLocalSocket() +void tst_QLocalSocket::initTestCase() { - if (!QFile::exists("lackey/lackey" + QDir workingDirectory = QDir::current(); + QString lackey = QLatin1String("lackey/lackey"); + // Windows: cd up to be able to locate the binary of the sub-process. #ifdef Q_OS_WIN - ".exe" + lackey.append(QLatin1String(".exe")); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } #endif - )) - qWarning() << "lackey executable doesn't exists!"; -} - -tst_QLocalSocket::~tst_QLocalSocket() -{ + m_lackey = workingDirectory.absoluteFilePath(lackey); + QVERIFY2(QFileInfo(m_lackey).exists(), + qPrintable(QString::fromLatin1("Lackey executable '%1' does not exist!") + .arg(QDir::toNativeSeparators(m_lackey)))); } void tst_QLocalSocket::init() @@ -806,7 +812,7 @@ void tst_QLocalSocket::processConnection() serverArguments << "-qws"; #endif QList<QProcess*> consumers; - producer.start("lackey/lackey", serverArguments); + producer.start(m_lackey, serverArguments); QVERIFY(producer.waitForStarted(-1)); QTest::qWait(2000); for (int i = 0; i < processes; ++i) { @@ -817,7 +823,7 @@ void tst_QLocalSocket::processConnection() QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); consumers.append(p); - p->start("lackey/lackey", arguments); + p->start(m_lackey, arguments); } while (!consumers.isEmpty()) { diff --git a/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp b/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp index 99acf92f7a..ab427b402e 100644 --- a/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp +++ b/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp @@ -51,21 +51,23 @@ class tst_QScriptExtensionPlugin : public QObject { Q_OBJECT -public: - tst_QScriptExtensionPlugin(); - virtual ~tst_QScriptExtensionPlugin(); - private slots: + void initTestCase(); void importSimplePlugin(); void importStaticPlugin(); }; -tst_QScriptExtensionPlugin::tst_QScriptExtensionPlugin() -{ -} - -tst_QScriptExtensionPlugin::~tst_QScriptExtensionPlugin() +void tst_QScriptExtensionPlugin::initTestCase() { +#ifdef Q_OS_WIN + // cd up to be able to locate the plugins. + QDir workingDirectory = QDir::current(); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif } void tst_QScriptExtensionPlugin::importSimplePlugin() diff --git a/tests/auto/quuid/test/test.pro b/tests/auto/quuid/test/test.pro index 271b88f13b..06ae3bd362 100644 --- a/tests/auto/quuid/test/test.pro +++ b/tests/auto/quuid/test/test.pro @@ -27,5 +27,3 @@ symbian { DEPLOYMENT += binDep } - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 55b75a9504..4190ea6310 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -60,6 +60,7 @@ public: tst_QUuid(); private slots: + void initTestCase(); void fromChar(); void toString(); void fromString(); @@ -97,6 +98,19 @@ tst_QUuid::tst_QUuid() uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); } +void tst_QUuid::initTestCase() +{ +#ifdef Q_OS_WIN + // cd up to be able to locate the binary of the sub-process. + QDir workingDirectory = QDir::current(); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif +} + void tst_QUuid::fromChar() { QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); @@ -294,29 +308,33 @@ void tst_QUuid::threadUniqueness() qDeleteAll(threads); } +static inline QByteArray msgCannotStartProcess(const QString &binary, const QString &why) +{ + return QString::fromLatin1("Cannot start '%1' from '%2': %3") + .arg(QDir::toNativeSeparators(binary), + QDir::toNativeSeparators(QDir::currentPath()), + why).toLocal8Bit(); +} + void tst_QUuid::processUniqueness() { QProcess process; - QString processOneOutput; - QString processTwoOutput; - // Start it once #ifdef Q_OS_MAC - process.start("testProcessUniqueness/testProcessUniqueness.app"); + const QString binary = "testProcessUniqueness/testProcessUniqueness.app"; #else - process.start("testProcessUniqueness/testProcessUniqueness"); + const QString binary = "testProcessUniqueness/testProcessUniqueness"; #endif + process.start(binary); + QVERIFY2(process.waitForStarted(), msgCannotStartProcess(binary, process.errorString()).constData()); QVERIFY(process.waitForFinished()); - processOneOutput = process.readAllStandardOutput(); + const QByteArray processOneOutput = process.readAllStandardOutput(); // Start it twice -#ifdef Q_OS_MAC - process.start("testProcessUniqueness/testProcessUniqueness.app"); -#else - process.start("testProcessUniqueness/testProcessUniqueness"); -#endif + process.start(binary); + QVERIFY2(process.waitForStarted(), msgCannotStartProcess(binary, process.errorString()).constData()); QVERIFY(process.waitForFinished()); - processTwoOutput = process.readAllStandardOutput(); + const QByteArray processTwoOutput = process.readAllStandardOutput(); // They should be *different*! QVERIFY(processOneOutput != processTwoOutput); diff --git a/tests/auto/selftests/test/test.pro b/tests/auto/selftests/test/test.pro index facb26a86d..d57cbf4162 100644 --- a/tests/auto/selftests/test/test.pro +++ b/tests/auto/selftests/test/test.pro @@ -12,6 +12,3 @@ win32 { } RESOURCES += ../selftests.qrc - - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index e0c56b34a2..8bb48c24d9 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -49,6 +49,7 @@ class tst_Selftests: public QObject { Q_OBJECT private slots: + void initTestCase(); void runSubTest_data(); void runSubTest(); void cleanupTestCase(); @@ -181,6 +182,19 @@ static QList<Logger> allLoggers() ; } +void tst_Selftests::initTestCase() +{ +#ifdef Q_OS_WIN + // cd up to be able to locate the binaries of the sub-processes. + QDir workingDirectory = QDir::current(); + if (workingDirectory.absolutePath().endsWith(QLatin1String("/debug"), Qt::CaseInsensitive) + || workingDirectory.absolutePath().endsWith(QLatin1String("/release"), Qt::CaseInsensitive)) { + QVERIFY(workingDirectory.cdUp()); + QVERIFY(QDir::setCurrent(workingDirectory.absolutePath())); + } +#endif +} + void tst_Selftests::runSubTest_data() { QTest::addColumn<QString>("subdir"); @@ -323,6 +337,14 @@ void tst_Selftests::runSubTest_data() } } +static inline QByteArray msgCannotStartProcess(const QString &binary, const QString &why) +{ + return QString::fromLatin1("Cannot start '%1' from '%2': %3") + .arg(QDir::toNativeSeparators(binary), + QDir::toNativeSeparators(QDir::currentPath()), + why).toLocal8Bit(); +} + void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, QStringList const& arguments ) { // For the plain text logger, we'll read straight from standard output. @@ -338,7 +360,9 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, Q QProcess proc; proc.setEnvironment(QStringList("")); - proc.start(subdir + "/" + subdir, QStringList() << arguments << extraArguments); + const QString binary = subdir + QLatin1Char('/') + subdir; + proc.start(binary, QStringList() << arguments << extraArguments); + QVERIFY2(proc.waitForStarted(), msgCannotStartProcess(binary, proc.errorString())); QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); QByteArray out; |