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.6 6.5 Change-Id: I99e1b314b106cda20a66e3cac9a92b463b94f5c9 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
20643d17bf
commit
0d5fe9c3d7
@ -15,6 +15,7 @@
|
||||
#include <csignal>
|
||||
#include <QtCore/QDeadlineTimer>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QProcessEnvironment>
|
||||
|
||||
#include <shellquote_shared.h>
|
||||
|
||||
@ -366,10 +367,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