Tests: Fix running dumper tests on Win

Using QtcProcess needs more setup, so use consistently
QProcess for all processes inside the dumper tests.

Change-Id: I7c09c6705c8b8d52ba7b27b054b825c4147647d3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2021-09-13 13:02:08 +02:00
parent 3efd048dfd
commit 6786d585e0

View File

@@ -28,9 +28,9 @@
#include "watchdata.h" #include "watchdata.h"
#include "watchutils.h" #include "watchutils.h"
#include <utils/commandline.h> // for Utils::ProcessArgs
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/qtcprocess.h>
#include <QtTest> #include <QtTest>
#include <math.h> #include <math.h>
@@ -97,18 +97,16 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
return false; return false;
} }
Utils::QtcProcess run; QProcess run;
// As of WinSDK 7.1, there is logic preventing the path from being set // As of WinSDK 7.1, there is logic preventing the path from being set
// correctly if "ORIGINALPATH" is already set. That can cause problems // correctly if "ORIGINALPATH" is already set. That can cause problems
// if Creator is launched within a session set up by setenv.cmd. // if Creator is launched within a session set up by setenv.cmd.
env.unset("ORIGINALPATH"); env.unset("ORIGINALPATH");
run.setEnvironment(env); run.setEnvironment(env.toStringList());
const Utils::FilePath cmdPath const QString cmdPath = QString::fromLocal8Bit(qgetenv("COMSPEC"));
= Utils::FilePath::fromString(QString::fromLocal8Bit(qgetenv("COMSPEC")));
// Windows SDK setup scripts require command line switches for environment expansion. // Windows SDK setup scripts require command line switches for environment expansion.
QString cmdArguments = " /E:ON /V:ON /c \"" + saver.filePath().toUserOutput() + '"'; QStringList cmdArguments{"/E:ON", "/V:ON", "/c", "\"" + saver.filePath().toUserOutput() + '"'};
run.setCommand(Utils::CommandLine(cmdPath, cmdArguments, Utils::CommandLine::Raw)); run.start(cmdPath, cmdArguments);
run.start();
if (!run.waitForStarted()) { if (!run.waitForStarted()) {
qWarning("%s: Unable to run '%s': %s", Q_FUNC_INFO, qPrintable(batchFile), qWarning("%s: Unable to run '%s': %s", Q_FUNC_INFO, qPrintable(batchFile),
@@ -117,7 +115,9 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
} }
if (!run.waitForFinished()) { if (!run.waitForFinished()) {
qWarning("%s: Timeout running '%s'", Q_FUNC_INFO, qPrintable(batchFile)); qWarning("%s: Timeout running '%s'", Q_FUNC_INFO, qPrintable(batchFile));
run.stopProcess(); run.terminate();
if (!run.waitForFinished())
run.kill();
return false; return false;
} }
// The SDK/MSVC scripts do not return exit codes != 0. Check on stdout. // The SDK/MSVC scripts do not return exit codes != 0. Check on stdout.