From 7c081ba94239e26f4e5c8b8c8a8c3486d1a8c76e Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Feb 2012 14:20:57 +0200 Subject: Fix qlogging test for release configuration The helper process 'app' wasn't built in release configuration. Also improved finding the helper executable to utilize QFINDTESTDATA and print out a proper errors if it could not be found or started. Note that adding ".exe" to process name in Windows is unnecessary as QProcess already does that for you, so removed the ifdeffing. Task-number: QTBUG-24330 Change-Id: Ibe75e0ecd24181ab623d0a60f17ecaf92052b0dd Reviewed-by: Friedemann Kleint --- tests/auto/corelib/global/qlogging/app/app.pro | 6 ++-- .../auto/corelib/global/qlogging/tst_qlogging.cpp | 32 +++++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'tests/auto/corelib/global') diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro index a167cc45cd..1088d08a58 100644 --- a/tests/auto/corelib/global/qlogging/app/app.pro +++ b/tests/auto/corelib/global/qlogging/app/app.pro @@ -3,7 +3,9 @@ TEMPLATE = app TARGET = app QT = core -CONFIG -= debug_and_release app_bundle -CONFIG += debug console +DESTDIR = ./ + +CONFIG -= app_bundle +CONFIG += console SOURCES += main.cpp diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 11949cf1db..aaec46fe64 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -47,6 +47,9 @@ class tst_qmessagehandler : public QObject { Q_OBJECT +public slots: + void initTestCase(); + private slots: void cleanup(); @@ -59,6 +62,9 @@ private slots: void cleanupFuncinfo(); void qMessagePattern(); + +private: + QString m_appDir; }; static QtMsgType s_type; @@ -85,6 +91,13 @@ void customMsgHandler(QtMsgType type, const char *msg) s_message = QString::fromLocal8Bit(msg); } +void tst_qmessagehandler::initTestCase() +{ + m_appDir = QFINDTESTDATA("app"); + QVERIFY2(!m_appDir.isEmpty(), qPrintable( + QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath()))); +} + void tst_qmessagehandler::cleanup() { qInstallMsgHandler(0); @@ -622,11 +635,11 @@ void tst_qmessagehandler::qMessagePattern() // %{file} is tricky because of shadow builds environment.prepend("QT_MESSAGE_PATTERN=\"%{type} %{appname} %{line} %{function} %{message}\""); process.setEnvironment(environment); -#ifdef Q_OS_WIN - process.start("app/app.exe"); -#else - process.start("app/app"); -#endif + + QString appExe = m_appDir + "/app"; + process.start(appExe); + QVERIFY2(process.waitForStarted(), qPrintable( + QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); process.waitForFinished(); QByteArray output = process.readAllStandardError(); @@ -643,11 +656,10 @@ void tst_qmessagehandler::qMessagePattern() environment = QProcess::systemEnvironment(); environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{message}\""); process.setEnvironment(environment); -#ifdef Q_OS_WIN - process.start("app/app.exe"); -#else - process.start("app/app"); -#endif + + process.start(appExe); + QVERIFY2(process.waitForStarted(), qPrintable( + QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); process.waitForFinished(); output = process.readAllStandardError(); -- cgit v1.2.3