AndroidTestRunner: don't run build command twice and print on failure

Print an error log when the build command fails that make it clear
that the build has failed and not necessarily the test.

Also, it seems according to the code, that if the build command fails
and --skip-install-root is set, the build command is run again.

Prepare the build command after parsing the args considering all the
other args and simply run the final build command in main() to simplify
things.

Change-Id: I2f5a9d26bcea78349e1ef1cec4f717c37afd0225
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
(cherry picked from commit fe672c3db87b4f0d33d13987024f7c3603b1184a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia 2024-11-14 19:19:59 +02:00 committed by Qt Cherry-pick Bot
parent e8b1644d44
commit d06cc87de4

View File

@ -175,6 +175,14 @@ static bool parseOptions()
g_options.testArgsList << arguments.at(i); g_options.testArgsList << arguments.at(i);
} }
} }
if (!g_options.skipAddInstallRoot) {
// we need to run make INSTALL_ROOT=path install to install the application file(s) first
g_options.makeCommand = "%1 INSTALL_ROOT=%2 install"_L1
.arg(g_options.makeCommand)
.arg(QDir::toNativeSeparators(g_options.buildPath));
}
for (;i < arguments.size(); ++i) for (;i < arguments.size(); ++i)
g_options.testArgsList << arguments.at(i); g_options.testArgsList << arguments.at(i);
@ -811,17 +819,10 @@ int main(int argc, char *argv[])
"to generate the apk."; "to generate the apk.";
return EXIT_ERROR; return EXIT_ERROR;
} }
if (!execCommand(g_options.makeCommand, nullptr, true)) { if (!execCommand(g_options.makeCommand, nullptr, true)) {
if (!g_options.skipAddInstallRoot) { qCritical("The build command \"%s\" failed", qPrintable(g_options.makeCommand));
// we need to run make INSTALL_ROOT=path install to install the application file(s) first return EXIT_ERROR;
if (!execCommand("%1 INSTALL_ROOT=%2 install"_L1.arg(g_options.makeCommand,
QDir::toNativeSeparators(g_options.buildPath)), nullptr)) {
return EXIT_ERROR;
}
} else {
if (!execCommand(g_options.makeCommand, nullptr))
return EXIT_ERROR;
}
} }
if (!QFile::exists(g_options.apkPath)) { if (!QFile::exists(g_options.apkPath)) {