diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
commit | 42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch) | |
tree | a7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /tests/auto/corelib/global/qlogging/tst_qlogging.cpp | |
parent | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff) | |
parent | 168ff3419f256fdb35b586275d293fc0cd773fe1 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'tests/auto/corelib/global/qlogging/tst_qlogging.cpp')
-rw-r--r-- | tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 3af637d13a..0f27901f94 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -34,6 +34,8 @@ #endif #include <QtTest/QTest> +#include <QtCore/QScopeGuard> + class tst_qmessagehandler : public QObject { Q_OBJECT @@ -819,7 +821,17 @@ void tst_qmessagehandler::qMessagePattern() QFETCH(QList<QByteArray>, expected); QProcess process; -#ifndef Q_OS_ANDROID + + // Add the executable's directory to path so that we can find the test helper next to it + // in a cross-platform way. We must do this because the CWD is not pointing to this directory + // in debug-and-release builds. + QByteArray path = qgetenv("PATH"); + qputenv("PATH", + path + QDir::listSeparator().toLatin1() + + QCoreApplication::applicationDirPath().toLocal8Bit()); + auto restore = qScopeGuard([&] { qputenv("PATH", path); }); + +#if !defined(Q_OS_ANDROID) const QString appExe(QLatin1String("helper")); #else const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); @@ -869,8 +881,12 @@ void tst_qmessagehandler::setMessagePattern() // QProcess process; -#ifndef Q_OS_ANDROID +#ifdef Q_OS_WIN + // On Windows the CWD is not the same directory as the helper, so we cannot use "./" + // Instead we rely on CreateProcess to find the executable. const QString appExe(QLatin1String("helper")); +#elif !defined(Q_OS_ANDROID) + const QString appExe(QLatin1String("./helper")); #else const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); #endif |