AndroidTestRunner: pass testlib env vars to the test app
Check if the common testlib environment variables are set on the host and pass them to the test app. This include any env variable starting with "QTEST_". Fixes: QTBUG-106478 Task-number: QTBUG-106479 Pick-to: 6.5 Change-Id: I99e1b314b106cda20a66e3cac9a92b463b94f5c9 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 0d5fe9c3d7a1af873e800453306b1a5116812966) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
85bc252224
commit
751d80f126
@ -13,6 +13,7 @@
|
||||
#include <functional>
|
||||
#include <QtCore/QDeadlineTimer>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QProcessEnvironment>
|
||||
|
||||
#include <shellquote_shared.h>
|
||||
|
||||
@ -364,10 +365,25 @@ static bool parseTestArgs()
|
||||
|
||||
g_options.testArgs += unhandledArgs.join(u' ');
|
||||
|
||||
g_options.testArgs = QStringLiteral("shell am start -e applicationArguments \"%1\" -n %2/%3")
|
||||
.arg(shellQuote(g_options.testArgs.trimmed()))
|
||||
.arg(g_options.package)
|
||||
.arg(g_options.activity);
|
||||
// Pass over any testlib env vars if set
|
||||
QString testEnvVars;
|
||||
const QStringList envVarsList = QProcessEnvironment::systemEnvironment().toStringList();
|
||||
for (const QString &var : envVarsList) {
|
||||
if (var.startsWith("QTEST_"_L1))
|
||||
testEnvVars += "%1 "_L1.arg(var);
|
||||
}
|
||||
|
||||
if (!testEnvVars.isEmpty()) {
|
||||
testEnvVars = QString::fromUtf8(testEnvVars.trimmed().toUtf8().toBase64());
|
||||
testEnvVars = "-e extraenvvars \"%4\""_L1.arg(testEnvVars);
|
||||
}
|
||||
|
||||
g_options.testArgs = "shell am start -n %1/%2 -e applicationArguments \"%3\" %4"_L1
|
||||
.arg(g_options.package)
|
||||
.arg(g_options.activity)
|
||||
.arg(shellQuote(g_options.testArgs.trimmed()))
|
||||
.arg(testEnvVars)
|
||||
.trimmed();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user