summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorDavid Faure <faure+bluesystems@kde.org>2013-03-05 23:12:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-16 00:12:47 +0100
commit72367a94a750355eb748793ce8c365373a332c9c (patch)
tree99ff76e9b4c5454902957fc0ae9960bc501ca00a /tests/auto
parentae94bf2b7a6373def9239ae5f54b143e1f6ffe09 (diff)
tst_qlogging: fix test when QT_MESSAGE_PATTERN is already set
Change-Id: I608ac9920e04eb636c8d2e9cee38c6f0cd189f1f Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 6f07538c8d..04ce504189 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -68,6 +68,7 @@ private slots:
private:
QString m_appDir;
+ QStringList m_baseEnvironment;
};
static QtMsgType s_type;
@@ -99,6 +100,14 @@ 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())));
+
+ m_baseEnvironment = QProcess::systemEnvironment();
+ for (int i = 0; i < m_baseEnvironment.count(); ++i) {
+ if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) {
+ m_baseEnvironment.removeAt(i);
+ break;
+ }
+ }
}
void tst_qmessagehandler::cleanup()
@@ -638,7 +647,7 @@ void tst_qmessagehandler::qMessagePattern()
//
// test QT_MESSAGE_PATTERN
//
- QStringList environment = QProcess::systemEnvironment();
+ QStringList environment = m_baseEnvironment;
// %{file} is tricky because of shadow builds
environment.prepend("QT_MESSAGE_PATTERN=\"%{type} %{appname} %{line} %{function} %{message}\"");
process.setEnvironment(environment);
@@ -660,7 +669,7 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(output.contains("critical tst_qlogging 58 main qCritical"));
QVERIFY(output.contains("debug tst_qlogging 62 main qDebug2"));
- environment = QProcess::systemEnvironment();
+ environment = m_baseEnvironment;
environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{message}\"");
process.setEnvironment(environment);
@@ -708,7 +717,7 @@ void tst_qmessagehandler::qMessagePatternIf()
QProcess process;
const QString appExe = m_appDir + "/app";
- QStringList environment = QProcess::systemEnvironment();
+ QStringList environment = m_baseEnvironment;
environment.prepend("QT_MESSAGE_PATTERN=\"[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{message}\"");
process.setEnvironment(environment);
process.start(appExe);
@@ -732,7 +741,7 @@ void tst_qmessagehandler::qMessagePatternIf()
//
// Tests some errors
//
- environment = QProcess::systemEnvironment();
+ environment = m_baseEnvironment;
environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{endif} %{if-warning}\"");
process.setEnvironment(environment);
@@ -749,7 +758,7 @@ void tst_qmessagehandler::qMessagePatternIf()
QVERIFY(output.contains("QT_MESSAGE_PATTERN: missing %{endif}"));
- environment = QProcess::systemEnvironment();
+ environment = m_baseEnvironment;
environment.prepend("QT_MESSAGE_PATTERN=\"A %{if-debug}DEBUG%{if-warning}WARNING%{endif} %{message} \"");
process.setEnvironment(environment);