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.

Pick-to: 6.8
Change-Id: I2f5a9d26bcea78349e1ef1cec4f717c37afd0225
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
This commit is contained in:
Assam Boudjelthia 2024-11-14 19:19:59 +02:00
parent 6d4a717152
commit fe672c3db8

View File

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