class tst_qmessagehandler : public QObject
{
Q_OBJECT
+public slots:
+ void initTestCase();
+
private slots:
void cleanup();
void cleanupFuncinfo();
void qMessagePattern();
+
+private:
+ QString m_appDir;
};
static QtMsgType s_type;
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);
// %{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();
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();