QObject-test: Reorganize subprocess.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 12 Dec 2011 15:28:30 +0000 (16:28 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 14 Dec 2011 06:07:09 +0000 (07:07 +0100)
On Windows, the signalbug.exe could not be launched since it is
not next to tst_qobject.exe, which is in one of the
'release', 'debug' subfolders.

Introduce a subdirectory structure similar to that of
the QProcess test and use QFINDTESTDATA to locate it.

Change-Id: Ie8f2ede8cb76f22a908cb77517a74076be11fbb7
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
tests/auto/corelib/kernel/qobject/.gitignore
tests/auto/corelib/kernel/qobject/qobject.pro
tests/auto/corelib/kernel/qobject/signalbug/signalbug.cpp [moved from tests/auto/corelib/kernel/qobject/signalbug.cpp with 100% similarity]
tests/auto/corelib/kernel/qobject/signalbug/signalbug.h [moved from tests/auto/corelib/kernel/qobject/signalbug.h with 100% similarity]
tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro [moved from tests/auto/corelib/kernel/qobject/signalbug.pro with 73% similarity]
tests/auto/corelib/kernel/qobject/tst_qobject.cpp

index ea4d6d7..7970e32 100644 (file)
@@ -1,3 +1,3 @@
 tst_qobject
-signalbug
-signalbug.exe
+signalbug/signalbug
+signalbug/signalbug.exe
index 113e14a..ee48f56 100644 (file)
@@ -1,3 +1,3 @@
 TEMPLATE = subdirs
-SUBDIRS = tst_qobject.pro signalbug.pro
+SUBDIRS = signalbug tst_qobject.pro
 CONFIG += parallel_test
@@ -1,9 +1,9 @@
 TEMPLATE = app
-TARGET = 
 DEPENDPATH += .
 INCLUDEPATH += .
 CONFIG -= app_bundle debug_and_release
-DESTDIR=.
+CONFIG += console
+DESTDIR = ./
 QT -= gui
 wince*: {
    LIBS += coredll.lib
@@ -13,5 +13,5 @@ HEADERS += signalbug.h
 SOURCES += signalbug.cpp
 
 # This app is testdata for tst_qobject
-target.path = $$[QT_INSTALL_TESTS]/tst_qobject
+target.path = $$[QT_INSTALL_TESTS]/tst_qobject/$$TARGET
 INSTALLS += target
index 8f938a7..05b9229 100644 (file)
@@ -65,6 +65,7 @@ class tst_QObject : public QObject
 {
     Q_OBJECT
 private slots:
+    void initTestCase();
     void disconnect();
     void connectByName();
     void connectSignalsToSignalsWithDefaultArguments();
@@ -236,6 +237,12 @@ public slots:
 
 int ReceiverObject::sequence = 0;
 
+void tst_QObject::initTestCase()
+{
+    const QString testDataDir = QFileInfo(QFINDTESTDATA("signalbug")).absolutePath();
+    QVERIFY2(QDir::setCurrent(testDataDir), qPrintable("Could not chdir to " + testDataDir));
+}
+
 void tst_QObject::disconnect()
 {
     SenderObject *s = new SenderObject;
@@ -2794,7 +2801,9 @@ void tst_QObject::recursiveSignalEmission()
 {
     QProcess proc;
     // signalbug helper app should always be next to this test binary
-    proc.start(QCoreApplication::applicationDirPath() + "/signalbug");
+    const QString path = QStringLiteral("signalbug/signalbug");
+    proc.start(path);
+    QVERIFY2(proc.waitForStarted(), qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, proc.errorString())));
     QVERIFY(proc.waitForFinished());
     QVERIFY(proc.exitStatus() == QProcess::NormalExit);
     QCOMPARE(proc.exitCode(), 0);