From fe672c3db87b4f0d33d13987024f7c3603b1184a Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Thu, 14 Nov 2024 19:19:59 +0200 Subject: [PATCH] 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 --- src/tools/androidtestrunner/main.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index a19fe58e1f5..228aa676f5b 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -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,17 +819,10 @@ 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)) { - return EXIT_ERROR; - } - } else { - if (!execCommand(g_options.makeCommand, nullptr)) - return EXIT_ERROR; - } + qCritical("The build command \"%s\" failed", qPrintable(g_options.makeCommand)); + return EXIT_ERROR; } if (!QFile::exists(g_options.apkPath)) {