forked from qt-creator/qt-creator
Process: Get rid of setTimeoutS()
Add an extra arg to runBlocking() function instead. Use std::chrono::seconds for timeout. Change-Id: I7c3c21e8f26a2ccbed157d15083d6ef0b4cd2f7e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
bool BuildableHelperLibrary::isQtChooser(const FilePath &filePath)
|
bool BuildableHelperLibrary::isQtChooser(const FilePath &filePath)
|
||||||
@@ -22,9 +24,8 @@ FilePath BuildableHelperLibrary::qtChooserToQmakePath(const FilePath &qtChooser)
|
|||||||
{
|
{
|
||||||
const QString toolDir = QLatin1String("QTTOOLDIR=\"");
|
const QString toolDir = QLatin1String("QTTOOLDIR=\"");
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(1);
|
|
||||||
proc.setCommand({qtChooser, {"-print-env"}});
|
proc.setCommand({qtChooser, {"-print-env"}});
|
||||||
proc.runBlocking();
|
proc.runBlocking(1s);
|
||||||
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
const QString output = proc.cleanedStdOut();
|
const QString output = proc.cleanedStdOut();
|
||||||
@@ -104,9 +105,8 @@ QString BuildableHelperLibrary::qtVersionForQMake(const FilePath &qmakePath)
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
Process qmake;
|
Process qmake;
|
||||||
qmake.setTimeoutS(5);
|
|
||||||
qmake.setCommand({qmakePath, {"--version"}});
|
qmake.setCommand({qmakePath, {"--version"}});
|
||||||
qmake.runBlocking();
|
qmake.runBlocking(5s);
|
||||||
if (qmake.result() != ProcessResult::FinishedWithSuccess) {
|
if (qmake.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
qWarning() << qmake.exitMessage();
|
qWarning() << qmake.exitMessage();
|
||||||
return QString();
|
return QString();
|
||||||
|
@@ -133,9 +133,8 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
|
|||||||
if (cmd.executable().isEmpty())
|
if (cmd.executable().isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(1);
|
|
||||||
proc.setCommand(cmd);
|
proc.setCommand(cmd);
|
||||||
proc.runBlocking();
|
proc.runBlocking(std::chrono::seconds(1));
|
||||||
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return QString();
|
return QString();
|
||||||
return proc.allOutput();
|
return proc.allOutput();
|
||||||
|
@@ -854,7 +854,6 @@ public:
|
|||||||
|
|
||||||
time_point<system_clock, nanoseconds> m_startTimestamp = {};
|
time_point<system_clock, nanoseconds> m_startTimestamp = {};
|
||||||
time_point<system_clock, nanoseconds> m_doneTimestamp = {};
|
time_point<system_clock, nanoseconds> m_doneTimestamp = {};
|
||||||
int m_timeoutInSeconds = 10;
|
|
||||||
bool m_timeOutMessageBoxEnabled = false;
|
bool m_timeOutMessageBoxEnabled = false;
|
||||||
|
|
||||||
Guard m_guard;
|
Guard m_guard;
|
||||||
@@ -1847,14 +1846,6 @@ void ChannelBuffer::handleRest()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::setTimeoutS(int timeoutS)
|
|
||||||
{
|
|
||||||
if (timeoutS > 0)
|
|
||||||
d->m_timeoutInSeconds = qMax(2, timeoutS);
|
|
||||||
else
|
|
||||||
d->m_timeoutInSeconds = INT_MAX / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process::setCodec(QTextCodec *c)
|
void Process::setCodec(QTextCodec *c)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(c, return);
|
QTC_ASSERT(c, return);
|
||||||
@@ -1871,7 +1862,7 @@ void Process::setWriteData(const QByteArray &writeData)
|
|||||||
d->m_setup.m_writeData = writeData;
|
d->m_setup.m_writeData = writeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::runBlocking(EventLoopMode eventLoopMode)
|
void Process::runBlocking(seconds timeout, EventLoopMode eventLoopMode)
|
||||||
{
|
{
|
||||||
QDateTime startTime;
|
QDateTime startTime;
|
||||||
static const int blockingThresholdMs = qtcEnvironmentVariableIntValue("QTC_PROCESS_THRESHOLD");
|
static const int blockingThresholdMs = qtcEnvironmentVariableIntValue("QTC_PROCESS_THRESHOLD");
|
||||||
@@ -1907,15 +1898,15 @@ void Process::runBlocking(EventLoopMode eventLoopMode)
|
|||||||
QMetaObject::invokeMethod(this, handleStart, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, handleStart, Qt::QueuedConnection);
|
||||||
|
|
||||||
std::function<void(void)> timeoutHandler = {};
|
std::function<void(void)> timeoutHandler = {};
|
||||||
if (d->m_timeoutInSeconds > 0) {
|
if (timeout > seconds::zero()) {
|
||||||
timeoutHandler = [this, &eventLoop, &timeoutHandler, &handleTimeout] {
|
timeoutHandler = [this, &eventLoop, &timeoutHandler, &handleTimeout, timeout] {
|
||||||
if (!d->m_timeOutMessageBoxEnabled || askToKill(d->m_setup.m_commandLine)) {
|
if (!d->m_timeOutMessageBoxEnabled || askToKill(d->m_setup.m_commandLine)) {
|
||||||
handleTimeout();
|
handleTimeout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTimer::singleShot(d->m_timeoutInSeconds * 1000, &eventLoop, timeoutHandler);
|
QTimer::singleShot(timeout, &eventLoop, timeoutHandler);
|
||||||
};
|
};
|
||||||
QTimer::singleShot(d->m_timeoutInSeconds * 1000, &eventLoop, timeoutHandler);
|
QTimer::singleShot(timeout, &eventLoop, timeoutHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, &Process::done, &eventLoop, [&eventLoop] { eventLoop.quit(); });
|
connect(this, &Process::done, &eventLoop, [&eventLoop] { eventLoop.quit(); });
|
||||||
@@ -1927,7 +1918,7 @@ void Process::runBlocking(EventLoopMode eventLoopMode)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
handleStart();
|
handleStart();
|
||||||
if (!waitForFinished(d->m_timeoutInSeconds * 1000))
|
if (!waitForFinished(duration_cast<milliseconds>(timeout).count()))
|
||||||
handleTimeout();
|
handleTimeout();
|
||||||
}
|
}
|
||||||
if (blockingThresholdMs > 0) {
|
if (blockingThresholdMs > 0) {
|
||||||
|
@@ -73,6 +73,7 @@ public:
|
|||||||
QProcess::ProcessError error() const;
|
QProcess::ProcessError error() const;
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
|
|
||||||
|
// TODO: Change to std::chrono::milliseconds.
|
||||||
bool waitForStarted(int msecs = 30000);
|
bool waitForStarted(int msecs = 30000);
|
||||||
bool waitForReadyRead(int msecs = 30000);
|
bool waitForReadyRead(int msecs = 30000);
|
||||||
bool waitForFinished(int msecs = 30000);
|
bool waitForFinished(int msecs = 30000);
|
||||||
@@ -144,11 +145,8 @@ public:
|
|||||||
|
|
||||||
// Starts the command and waits for finish.
|
// Starts the command and waits for finish.
|
||||||
// User input processing is enabled when EventLoopMode::On was passed.
|
// User input processing is enabled when EventLoopMode::On was passed.
|
||||||
void runBlocking(EventLoopMode eventLoopMode = EventLoopMode::Off);
|
void runBlocking(std::chrono::seconds timeout = std::chrono::seconds(10),
|
||||||
|
EventLoopMode eventLoopMode = EventLoopMode::Off);
|
||||||
/* Timeout for hanging processes (triggers after no more output
|
|
||||||
* occurs on stderr/stdout). */
|
|
||||||
void setTimeoutS(int timeoutS);
|
|
||||||
|
|
||||||
// TODO: We should specify the purpose of the codec, e.g. setCodecForStandardChannel()
|
// TODO: We should specify the purpose of the codec, e.g. setCodecForStandardChannel()
|
||||||
void setCodec(QTextCodec *c);
|
void setCodec(QTextCodec *c);
|
||||||
|
@@ -220,9 +220,8 @@ static bool is32BitUserSpace()
|
|||||||
if (HostOsInfo::isLinuxHost()) {
|
if (HostOsInfo::isLinuxHost()) {
|
||||||
if (QSysInfo::WordSize == 32) {
|
if (QSysInfo::WordSize == 32) {
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(3);
|
|
||||||
proc.setCommand({"getconf", {"LONG_BIT"}});
|
proc.setCommand({"getconf", {"LONG_BIT"}});
|
||||||
proc.runBlocking();
|
proc.runBlocking(std::chrono::seconds(3));
|
||||||
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return true;
|
return true;
|
||||||
return proc.allOutput().trimmed() == "32";
|
return proc.allOutput().trimmed() == "32";
|
||||||
@@ -312,7 +311,6 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
|
|||||||
const CommandLine command({m_config.adbToolPath(), arguments});
|
const CommandLine command({m_config.adbToolPath(), arguments});
|
||||||
qCDebug(avdManagerLog).noquote() << "Running command (isAvdBooted):" << command.toUserOutput();
|
qCDebug(avdManagerLog).noquote() << "Running command (isAvdBooted):" << command.toUserOutput();
|
||||||
Process adbProc;
|
Process adbProc;
|
||||||
adbProc.setTimeoutS(10);
|
|
||||||
adbProc.setCommand(command);
|
adbProc.setCommand(command);
|
||||||
adbProc.runBlocking();
|
adbProc.runBlocking();
|
||||||
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
|
@@ -999,9 +999,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
|||||||
"-storepass", m_keystorePasswd, "-J-Duser.language=en"};
|
"-storepass", m_keystorePasswd, "-J-Duser.language=en"};
|
||||||
|
|
||||||
Process keytoolProc;
|
Process keytoolProc;
|
||||||
keytoolProc.setTimeoutS(30);
|
|
||||||
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
||||||
keytoolProc.runBlocking(EventLoopMode::On);
|
keytoolProc.runBlocking(std::chrono::seconds(30), EventLoopMode::On);
|
||||||
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
||||||
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
||||||
else
|
else
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include "androidqtversion.h"
|
#include "androidqtversion.h"
|
||||||
#include "androidtoolchain.h"
|
#include "androidtoolchain.h"
|
||||||
#include "androidtr.h"
|
#include "androidtr.h"
|
||||||
#include "avddialog.h"
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
@@ -598,10 +597,9 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
|
|||||||
{
|
{
|
||||||
QVector<AndroidDeviceInfo> devices;
|
QVector<AndroidDeviceInfo> devices;
|
||||||
Process adbProc;
|
Process adbProc;
|
||||||
adbProc.setTimeoutS(30);
|
|
||||||
CommandLine cmd{adbToolPath(), {"devices"}};
|
CommandLine cmd{adbToolPath(), {"devices"}};
|
||||||
adbProc.setCommand(cmd);
|
adbProc.setCommand(cmd);
|
||||||
adbProc.runBlocking();
|
adbProc.runBlocking(std::chrono::seconds(30));
|
||||||
if (adbProc.result() != ProcessResult::FinishedWithSuccess) {
|
if (adbProc.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
if (error)
|
if (error)
|
||||||
*error = Tr::tr("Could not run: %1").arg(cmd.toUserOutput());
|
*error = Tr::tr("Could not run: %1").arg(cmd.toUserOutput());
|
||||||
@@ -667,7 +665,6 @@ QString AndroidConfig::getDeviceProperty(const QString &device, const QString &p
|
|||||||
cmd.addArgs({"shell", "getprop", property});
|
cmd.addArgs({"shell", "getprop", property});
|
||||||
|
|
||||||
Process adbProc;
|
Process adbProc;
|
||||||
adbProc.setTimeoutS(10);
|
|
||||||
adbProc.setCommand(cmd);
|
adbProc.setCommand(cmd);
|
||||||
adbProc.runBlocking();
|
adbProc.runBlocking();
|
||||||
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
@@ -744,7 +741,6 @@ QStringList AndroidConfig::getAbis(const QString &device)
|
|||||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||||
arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
|
arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
|
||||||
Process adbProc;
|
Process adbProc;
|
||||||
adbProc.setTimeoutS(10);
|
|
||||||
adbProc.setCommand({adbTool, arguments});
|
adbProc.setCommand({adbTool, arguments});
|
||||||
adbProc.runBlocking();
|
adbProc.runBlocking();
|
||||||
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
if (adbProc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
@@ -767,7 +763,6 @@ QStringList AndroidConfig::getAbis(const QString &device)
|
|||||||
arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i);
|
arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i);
|
||||||
|
|
||||||
Process abiProc;
|
Process abiProc;
|
||||||
abiProc.setTimeoutS(10);
|
|
||||||
abiProc.setCommand({adbTool, arguments});
|
abiProc.setCommand({adbTool, arguments});
|
||||||
abiProc.runBlocking();
|
abiProc.runBlocking();
|
||||||
if (abiProc.result() != ProcessResult::FinishedWithSuccess)
|
if (abiProc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
|
@@ -273,9 +273,8 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
|||||||
"-dname", distinguishedNames});
|
"-dname", distinguishedNames});
|
||||||
|
|
||||||
Process genKeyCertProc;
|
Process genKeyCertProc;
|
||||||
genKeyCertProc.setTimeoutS(15);
|
|
||||||
genKeyCertProc.setCommand(command);
|
genKeyCertProc.setCommand(command);
|
||||||
genKeyCertProc.runBlocking(EventLoopMode::On);
|
genKeyCertProc.runBlocking(std::chrono::seconds(15), EventLoopMode::On);
|
||||||
|
|
||||||
if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) {
|
if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
QMessageBox::critical(this, Tr::tr("Error"),
|
QMessageBox::critical(this, Tr::tr("Error"),
|
||||||
|
@@ -572,12 +572,11 @@ Tasking::GroupItem AndroidDeployQtStep::runRecipe()
|
|||||||
void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
||||||
{
|
{
|
||||||
Process buildProc;
|
Process buildProc;
|
||||||
buildProc.setTimeoutS(2 * 60);
|
|
||||||
emit addOutput(Tr::tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
emit addOutput(Tr::tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
||||||
OutputFormat::NormalMessage);
|
OutputFormat::NormalMessage);
|
||||||
|
|
||||||
buildProc.setCommand(command);
|
buildProc.setCommand(command);
|
||||||
buildProc.runBlocking(EventLoopMode::On);
|
buildProc.runBlocking(std::chrono::minutes(2), EventLoopMode::On);
|
||||||
if (buildProc.result() != ProcessResult::FinishedWithSuccess)
|
if (buildProc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
reportWarningOrError(buildProc.exitMessage(), Task::Error);
|
reportWarningOrError(buildProc.exitMessage(), Task::Error);
|
||||||
}
|
}
|
||||||
|
@@ -33,10 +33,11 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
|
using namespace Android::Internal;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
using namespace Android::Internal;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Android::AndroidManager {
|
namespace Android::AndroidManager {
|
||||||
|
|
||||||
@@ -612,9 +613,8 @@ bool checkKeystorePassword(const FilePath &keystorePath, const QString &keystore
|
|||||||
{"-list", "-keystore", keystorePath.toUserOutput(),
|
{"-list", "-keystore", keystorePath.toUserOutput(),
|
||||||
"--storepass", keystorePasswd});
|
"--storepass", keystorePasswd});
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(10);
|
|
||||||
proc.setCommand(cmd);
|
proc.setCommand(cmd);
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(10s, EventLoopMode::On);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,9 +630,8 @@ bool checkCertificatePassword(const FilePath &keystorePath, const QString &keyst
|
|||||||
arguments << certificatePasswd;
|
arguments << certificatePasswd;
|
||||||
|
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(10);
|
|
||||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(10s, EventLoopMode::On);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,9 +643,8 @@ bool checkCertificateExists(const FilePath &keystorePath, const QString &keystor
|
|||||||
"--storepass", keystorePasswd, "-alias", alias };
|
"--storepass", keystorePasswd, "-alias", alias };
|
||||||
|
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(10);
|
|
||||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(10s, EventLoopMode::On);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,11 +672,10 @@ static SdkToolResult runCommand(const CommandLine &command, const QByteArray &wr
|
|||||||
{
|
{
|
||||||
Android::SdkToolResult cmdResult;
|
Android::SdkToolResult cmdResult;
|
||||||
Process cmdProc;
|
Process cmdProc;
|
||||||
cmdProc.setTimeoutS(timeoutS);
|
|
||||||
cmdProc.setWriteData(writeData);
|
cmdProc.setWriteData(writeData);
|
||||||
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
|
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
|
||||||
cmdProc.setCommand(command);
|
cmdProc.setCommand(command);
|
||||||
cmdProc.runBlocking(EventLoopMode::On);
|
cmdProc.runBlocking(std::chrono::seconds(timeoutS), EventLoopMode::On);
|
||||||
cmdResult.m_stdOut = cmdProc.cleanedStdOut().trimmed();
|
cmdResult.m_stdOut = cmdProc.cleanedStdOut().trimmed();
|
||||||
cmdResult.m_stdErr = cmdProc.cleanedStdErr().trimmed();
|
cmdResult.m_stdErr = cmdProc.cleanedStdErr().trimmed();
|
||||||
cmdResult.m_success = cmdProc.result() == ProcessResult::FinishedWithSuccess;
|
cmdResult.m_success = cmdProc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
|
@@ -26,10 +26,11 @@ const char commonArgsKey[] = "Common Arguments:";
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
|
||||||
const int sdkManagerCmdTimeoutS = 60;
|
const int sdkManagerCmdTimeoutS = 60;
|
||||||
const int sdkManagerOperationTimeoutS = 600;
|
const int sdkManagerOperationTimeoutS = 600;
|
||||||
|
|
||||||
@@ -94,10 +95,9 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
.toUserOutput();
|
.toUserOutput();
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setEnvironment(config.toolsEnvironment());
|
proc.setEnvironment(config.toolsEnvironment());
|
||||||
proc.setTimeoutS(timeout);
|
|
||||||
proc.setTimeOutMessageBoxEnabled(true);
|
proc.setTimeOutMessageBoxEnabled(true);
|
||||||
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(seconds(timeout), EventLoopMode::On);
|
||||||
if (output)
|
if (output)
|
||||||
*output = proc.allOutput();
|
*output = proc.allOutput();
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
@@ -123,7 +123,6 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
Process proc;
|
Process proc;
|
||||||
proc.setEnvironment(config.toolsEnvironment());
|
proc.setEnvironment(config.toolsEnvironment());
|
||||||
bool assertionFound = false;
|
bool assertionFound = false;
|
||||||
proc.setTimeoutS(timeout);
|
|
||||||
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &promise](const QString &out) {
|
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &promise](const QString &out) {
|
||||||
int progressPercent = parseProgress(out, assertionFound);
|
int progressPercent = parseProgress(out, assertionFound);
|
||||||
if (assertionFound) {
|
if (assertionFound) {
|
||||||
@@ -143,7 +142,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(seconds(timeout), EventLoopMode::On);
|
||||||
if (assertionFound) {
|
if (assertionFound) {
|
||||||
output.success = false;
|
output.success = false;
|
||||||
output.stdOutput = proc.cleanedStdOut();
|
output.stdOutput = proc.cleanedStdOut();
|
||||||
|
@@ -71,7 +71,6 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
|
|
||||||
CommandLine cmd(compiler, {fakeIn.fileName()});
|
CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||||
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
||||||
@@ -123,7 +122,6 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
cpp.setCommand(cmd);
|
cpp.setCommand(cmd);
|
||||||
cpp.runBlocking();
|
cpp.runBlocking();
|
||||||
|
|
||||||
|
@@ -106,7 +106,6 @@ static Macros dumpMcsPredefinedMacros(const FilePath &compiler, const Environmen
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
cpp.setCommand({compiler, {fakeIn.fileName()}});
|
cpp.setCommand({compiler, {fakeIn.fileName()}});
|
||||||
|
|
||||||
cpp.runBlocking();
|
cpp.runBlocking();
|
||||||
@@ -183,7 +182,6 @@ static Macros dumpC166PredefinedMacros(const FilePath &compiler, const Environme
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
|
|
||||||
Macros macros;
|
Macros macros;
|
||||||
auto extractMacros = [¯os](const QString &output) {
|
auto extractMacros = [¯os](const QString &output) {
|
||||||
@@ -248,7 +246,6 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis
|
|||||||
{
|
{
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
|
|
||||||
QStringList args = extraArgs;
|
QStringList args = extraArgs;
|
||||||
args.push_back("-E");
|
args.push_back("-E");
|
||||||
|
@@ -60,7 +60,6 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Environment &
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
cpp.setCommand({compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()}});
|
cpp.setCommand({compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()}});
|
||||||
|
|
||||||
cpp.runBlocking();
|
cpp.runBlocking();
|
||||||
@@ -81,7 +80,6 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
|
|||||||
|
|
||||||
Process cpp;
|
Process cpp;
|
||||||
cpp.setEnvironment(env);
|
cpp.setEnvironment(env);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
cpp.setCommand({compiler, {compilerTargetFlag(abi), "--print-search-dirs"}});
|
cpp.setCommand({compiler, {compilerTargetFlag(abi), "--print-search-dirs"}});
|
||||||
|
|
||||||
cpp.runBlocking();
|
cpp.runBlocking();
|
||||||
|
@@ -96,9 +96,8 @@ public:
|
|||||||
void createDocumentationFile() const final
|
void createDocumentationFile() const final
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
process.setTimeoutS(2);
|
|
||||||
process.setCommand({command(), {"-h"}});
|
process.setCommand({command(), {"-h"}});
|
||||||
process.runBlocking();
|
process.runBlocking(std::chrono::seconds(2));
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -100,9 +100,8 @@ public:
|
|||||||
void createDocumentationFile() const final
|
void createDocumentationFile() const final
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
process.setTimeoutS(2);
|
|
||||||
process.setCommand({command(), {"--show-config"}});
|
process.setCommand({command(), {"--show-config"}});
|
||||||
process.runBlocking();
|
process.runBlocking(std::chrono::seconds(2));
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -1621,8 +1621,7 @@ CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDi
|
|||||||
process.setEnvironment(env);
|
process.setEnvironment(env);
|
||||||
process.setCommand({m_settings.ccBinaryPath, arguments});
|
process.setCommand({m_settings.ccBinaryPath, arguments});
|
||||||
process.setWorkingDirectory(workingDir);
|
process.setWorkingDirectory(workingDir);
|
||||||
process.setTimeoutS(m_settings.timeOutS);
|
process.runBlocking(std::chrono::seconds(m_settings.timeOutS));
|
||||||
process.runBlocking();
|
|
||||||
return CommandResult(process);
|
return CommandResult(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2284,11 +2283,10 @@ QString ClearCasePluginPrivate::runExtDiff(const FilePath &workingDir, const QSt
|
|||||||
diff.addArgs(arguments);
|
diff.addArgs(arguments);
|
||||||
|
|
||||||
Process process;
|
Process process;
|
||||||
process.setTimeoutS(timeOutS);
|
|
||||||
process.setWorkingDirectory(workingDir);
|
process.setWorkingDirectory(workingDir);
|
||||||
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
||||||
process.setCommand(diff);
|
process.setCommand(diff);
|
||||||
process.runBlocking(EventLoopMode::On);
|
process.runBlocking(std::chrono::seconds(timeOutS), EventLoopMode::On);
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
return process.allOutput();
|
return process.allOutput();
|
||||||
|
@@ -34,6 +34,8 @@ using namespace ProjectExplorer;
|
|||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(cmInputLog, "qtc.cmake.import", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(cmInputLog, "qtc.cmake.import", QtWarningMsg);
|
||||||
@@ -215,7 +217,6 @@ static CMakeConfig configurationFromPresetProbe(
|
|||||||
"\n"));
|
"\n"));
|
||||||
|
|
||||||
Process cmake;
|
Process cmake;
|
||||||
cmake.setTimeoutS(30);
|
|
||||||
cmake.setDisableUnixTerminal();
|
cmake.setDisableUnixTerminal();
|
||||||
|
|
||||||
const FilePath cmakeExecutable = FilePath::fromString(configurePreset.cmakeExecutable.value());
|
const FilePath cmakeExecutable = FilePath::fromString(configurePreset.cmakeExecutable.value());
|
||||||
@@ -290,7 +291,7 @@ static CMakeConfig configurationFromPresetProbe(
|
|||||||
qCDebug(cmInputLog) << "CMake probing for compilers: " << cmakeExecutable.toUserOutput()
|
qCDebug(cmInputLog) << "CMake probing for compilers: " << cmakeExecutable.toUserOutput()
|
||||||
<< args;
|
<< args;
|
||||||
cmake.setCommand({cmakeExecutable, args});
|
cmake.setCommand({cmakeExecutable, args});
|
||||||
cmake.runBlocking();
|
cmake.runBlocking(30s);
|
||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
const CMakeConfig config = CMakeConfig::fromFile(importPath.pathAppended(
|
const CMakeConfig config = CMakeConfig::fromFile(importPath.pathAppended(
|
||||||
@@ -395,7 +396,6 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config,
|
|||||||
)"));
|
)"));
|
||||||
|
|
||||||
Process cmake;
|
Process cmake;
|
||||||
cmake.setTimeoutS(5);
|
|
||||||
cmake.setDisableUnixTerminal();
|
cmake.setDisableUnixTerminal();
|
||||||
|
|
||||||
Environment cmakeEnv(env);
|
Environment cmakeEnv(env);
|
||||||
@@ -447,7 +447,7 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config,
|
|||||||
|
|
||||||
qCDebug(cmInputLog) << "CMake probing for qmake path: " << cmakeExecutable.toUserOutput() << args;
|
qCDebug(cmInputLog) << "CMake probing for qmake path: " << cmakeExecutable.toUserOutput() << args;
|
||||||
cmake.setCommand({cmakeExecutable, args});
|
cmake.setCommand({cmakeExecutable, args});
|
||||||
cmake.runBlocking();
|
cmake.runBlocking(5s);
|
||||||
|
|
||||||
const FilePath qmakeLocationTxt = qtcQMakeProbeDir.filePath("qmake-location.txt");
|
const FilePath qmakeLocationTxt = qtcQMakeProbeDir.filePath("qmake-location.txt");
|
||||||
const FilePath qmakeLocation = FilePath::fromUtf8(
|
const FilePath qmakeLocation = FilePath::fromUtf8(
|
||||||
|
@@ -169,13 +169,12 @@ bool CMakeTool::isValid(bool ignoreCache) const
|
|||||||
void CMakeTool::runCMake(Process &cmake, const QStringList &args, int timeoutS) const
|
void CMakeTool::runCMake(Process &cmake, const QStringList &args, int timeoutS) const
|
||||||
{
|
{
|
||||||
const FilePath executable = cmakeExecutable();
|
const FilePath executable = cmakeExecutable();
|
||||||
cmake.setTimeoutS(timeoutS);
|
|
||||||
cmake.setDisableUnixTerminal();
|
cmake.setDisableUnixTerminal();
|
||||||
Environment env = executable.deviceEnvironment();
|
Environment env = executable.deviceEnvironment();
|
||||||
env.setupEnglishOutput();
|
env.setupEnglishOutput();
|
||||||
cmake.setEnvironment(env);
|
cmake.setEnvironment(env);
|
||||||
cmake.setCommand({executable, args});
|
cmake.setCommand({executable, args});
|
||||||
cmake.runBlocking();
|
cmake.runBlocking(std::chrono::seconds(timeoutS));
|
||||||
}
|
}
|
||||||
|
|
||||||
Store CMakeTool::toMap() const
|
Store CMakeTool::toMap() const
|
||||||
|
@@ -365,9 +365,8 @@ static std::function<void(FilePath)> postCopyOperation()
|
|||||||
// On macOS, downloaded files get a quarantine flag, remove it, otherwise it is a hassle
|
// On macOS, downloaded files get a quarantine flag, remove it, otherwise it is a hassle
|
||||||
// to get it loaded as a plugin in Qt Creator.
|
// to get it loaded as a plugin in Qt Creator.
|
||||||
Process xattr;
|
Process xattr;
|
||||||
xattr.setTimeoutS(1);
|
|
||||||
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}});
|
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}});
|
||||||
xattr.runBlocking();
|
xattr.runBlocking(std::chrono::seconds(1));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -620,9 +620,8 @@ void DebuggerItemModel::autoDetectGdbOrLldbDebuggers(const FilePaths &searchPath
|
|||||||
|
|
||||||
if (searchPaths.front().osType() == OsTypeMac) {
|
if (searchPaths.front().osType() == OsTypeMac) {
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setTimeoutS(2);
|
|
||||||
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
||||||
proc.runBlocking();
|
proc.runBlocking(std::chrono::seconds(2));
|
||||||
// FIXME:
|
// FIXME:
|
||||||
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
||||||
QString lPath = proc.allOutput().trimmed();
|
QString lPath = proc.allOutput().trimmed();
|
||||||
|
@@ -215,10 +215,9 @@ static QByteArray decodeProvisioningProfile(const QString &path)
|
|||||||
QTC_ASSERT(!path.isEmpty(), return QByteArray());
|
QTC_ASSERT(!path.isEmpty(), return QByteArray());
|
||||||
|
|
||||||
Process p;
|
Process p;
|
||||||
p.setTimeoutS(3);
|
|
||||||
// path is assumed to be valid file path to .mobileprovision
|
// path is assumed to be valid file path to .mobileprovision
|
||||||
p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}});
|
p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}});
|
||||||
p.runBlocking();
|
p.runBlocking(std::chrono::seconds(3));
|
||||||
if (p.result() != ProcessResult::FinishedWithSuccess)
|
if (p.result() != ProcessResult::FinishedWithSuccess)
|
||||||
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
||||||
return p.cleanedStdOut().toLatin1();
|
return p.cleanedStdOut().toLatin1();
|
||||||
|
@@ -41,9 +41,8 @@ void XcodeProbe::addDeveloperPath(const QString &path)
|
|||||||
void XcodeProbe::detectDeveloperPaths()
|
void XcodeProbe::detectDeveloperPaths()
|
||||||
{
|
{
|
||||||
Utils::Process selectedXcode;
|
Utils::Process selectedXcode;
|
||||||
selectedXcode.setTimeoutS(5);
|
|
||||||
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
|
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
|
||||||
selectedXcode.runBlocking();
|
selectedXcode.runBlocking(std::chrono::seconds(5));
|
||||||
if (selectedXcode.result() != ProcessResult::FinishedWithSuccess)
|
if (selectedXcode.result() != ProcessResult::FinishedWithSuccess)
|
||||||
qCWarning(probeLog)
|
qCWarning(probeLog)
|
||||||
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
||||||
|
@@ -1187,7 +1187,6 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &worki
|
|||||||
Process process;
|
Process process;
|
||||||
process.setWriteData(stdInput);
|
process.setWriteData(stdInput);
|
||||||
const int timeOutS = (flags & LongTimeOut) ? settings().longTimeOutS() : settings().timeOutS();
|
const int timeOutS = (flags & LongTimeOut) ? settings().longTimeOutS() : settings().timeOutS();
|
||||||
process.setTimeoutS(timeOutS);
|
|
||||||
if (outputCodec)
|
if (outputCodec)
|
||||||
process.setCodec(outputCodec);
|
process.setCodec(outputCodec);
|
||||||
if (flags & OverrideDiffEnvironment)
|
if (flags & OverrideDiffEnvironment)
|
||||||
@@ -1208,7 +1207,8 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &worki
|
|||||||
}
|
}
|
||||||
process.setTimeOutMessageBoxEnabled(true);
|
process.setTimeOutMessageBoxEnabled(true);
|
||||||
process.setCommand({settings().p4BinaryPath(), args});
|
process.setCommand({settings().p4BinaryPath(), args});
|
||||||
process.runBlocking(flags & RunFullySynchronous ? EventLoopMode::Off : EventLoopMode::On);
|
process.runBlocking(std::chrono::seconds(timeOutS),
|
||||||
|
flags & RunFullySynchronous ? EventLoopMode::Off : EventLoopMode::On);
|
||||||
|
|
||||||
const auto result = process.result();
|
const auto result = process.result();
|
||||||
PerforceResponse response;
|
PerforceResponse response;
|
||||||
|
@@ -88,13 +88,12 @@ static bool
|
|||||||
arguments.push_back(value);
|
arguments.push_back(value);
|
||||||
}
|
}
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
process.setTimeoutS(30);
|
|
||||||
const Utils::CommandLine cmd(FilePath::fromString(binary), arguments);
|
const Utils::CommandLine cmd(FilePath::fromString(binary), arguments);
|
||||||
if (CustomWizard::verbose())
|
if (CustomWizard::verbose())
|
||||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()),
|
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()),
|
||||||
qPrintable(cmd.toUserOutput()));
|
qPrintable(cmd.toUserOutput()));
|
||||||
process.setCommand(cmd);
|
process.setCommand(cmd);
|
||||||
process.runBlocking(EventLoopMode::On);
|
process.runBlocking(std::chrono::seconds(30), EventLoopMode::On);
|
||||||
if (process.result() != Utils::ProcessResult::FinishedWithSuccess) {
|
if (process.result() != Utils::ProcessResult::FinishedWithSuccess) {
|
||||||
*errorMessage = QString("Generator script failed: %1").arg(process.exitMessage());
|
*errorMessage = QString("Generator script failed: %1").arg(process.exitMessage());
|
||||||
const QString stdErr = process.cleanedStdErr();
|
const QString stdErr = process.cleanedStdErr();
|
||||||
|
@@ -167,7 +167,6 @@ static QString runGcc(const FilePath &gcc, const QStringList &arguments, const E
|
|||||||
environment.setupEnglishOutput();
|
environment.setupEnglishOutput();
|
||||||
|
|
||||||
cpp.setEnvironment(environment);
|
cpp.setEnvironment(environment);
|
||||||
cpp.setTimeoutS(10);
|
|
||||||
cpp.setCommand({gcc, arguments});
|
cpp.setCommand({gcc, arguments});
|
||||||
cpp.runBlocking();
|
cpp.runBlocking();
|
||||||
if (cpp.result() != ProcessResult::FinishedWithSuccess || cpp.exitCode() != 0) {
|
if (cpp.result() != ProcessResult::FinishedWithSuccess || cpp.exitCode() != 0) {
|
||||||
|
@@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
#define KEY_ROOT "ProjectExplorer.MsvcToolChain."
|
#define KEY_ROOT "ProjectExplorer.MsvcToolChain."
|
||||||
static const char varsBatKeyC[] = KEY_ROOT "VarsBat";
|
static const char varsBatKeyC[] = KEY_ROOT "VarsBat";
|
||||||
static const char varsBatArgKeyC[] = KEY_ROOT "VarsBatArg";
|
static const char varsBatArgKeyC[] = KEY_ROOT "VarsBatArg";
|
||||||
@@ -256,10 +258,9 @@ static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QSt
|
|||||||
QVector<VisualStudioInstallation> installations;
|
QVector<VisualStudioInstallation> installations;
|
||||||
Process vsWhereProcess;
|
Process vsWhereProcess;
|
||||||
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
|
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
vsWhereProcess.setTimeoutS(5);
|
|
||||||
vsWhereProcess.setCommand({FilePath::fromString(vswhere),
|
vsWhereProcess.setCommand({FilePath::fromString(vswhere),
|
||||||
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}});
|
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}});
|
||||||
vsWhereProcess.runBlocking();
|
vsWhereProcess.runBlocking(5s);
|
||||||
if (vsWhereProcess.result() != ProcessResult::FinishedWithSuccess) {
|
if (vsWhereProcess.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
qWarning() << vsWhereProcess.exitMessage();
|
qWarning() << vsWhereProcess.exitMessage();
|
||||||
return installations;
|
return installations;
|
||||||
@@ -2124,7 +2125,6 @@ std::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils::E
|
|||||||
Utils::Environment runEnv = env;
|
Utils::Environment runEnv = env;
|
||||||
runEnv.unset(QLatin1String("ORIGINALPATH"));
|
runEnv.unset(QLatin1String("ORIGINALPATH"));
|
||||||
run.setEnvironment(runEnv);
|
run.setEnvironment(runEnv);
|
||||||
run.setTimeoutS(60);
|
|
||||||
Utils::FilePath cmdPath = Utils::FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC"));
|
Utils::FilePath cmdPath = Utils::FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC"));
|
||||||
if (cmdPath.isEmpty())
|
if (cmdPath.isEmpty())
|
||||||
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
||||||
@@ -2134,7 +2134,7 @@ std::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils::E
|
|||||||
<< " Env: " << runEnv.toStringList().size();
|
<< " Env: " << runEnv.toStringList().size();
|
||||||
run.setCodec(QTextCodec::codecForName("UTF-8"));
|
run.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
run.setCommand(cmd);
|
run.setCommand(cmd);
|
||||||
run.runBlocking();
|
run.runBlocking(1min);
|
||||||
|
|
||||||
if (run.result() != ProcessResult::FinishedWithSuccess) {
|
if (run.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
const QString message = !run.cleanedStdErr().isEmpty() ? run.cleanedStdErr() : run.exitMessage();
|
const QString message = !run.cleanedStdErr().isEmpty() ? run.cleanedStdErr() : run.exitMessage();
|
||||||
|
@@ -85,9 +85,8 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
|
|||||||
return {PythonLanguageServerState::AlreadyInstalled, lspPath};
|
return {PythonLanguageServerState::AlreadyInstalled, lspPath};
|
||||||
|
|
||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setTimeoutS(2);
|
|
||||||
pythonProcess.setCommand({python, {"-m", "pip", "-V"}});
|
pythonProcess.setCommand({python, {"-m", "pip", "-V"}});
|
||||||
pythonProcess.runBlocking();
|
pythonProcess.runBlocking(std::chrono::seconds(2));
|
||||||
if (pythonProcess.allOutput().startsWith("pip "))
|
if (pythonProcess.allOutput().startsWith("pip "))
|
||||||
return {PythonLanguageServerState::CanBeInstalled, lspPath};
|
return {PythonLanguageServerState::CanBeInstalled, lspPath};
|
||||||
return {PythonLanguageServerState::CanNotBeInstalled, FilePath()};
|
return {PythonLanguageServerState::CanNotBeInstalled, FilePath()};
|
||||||
|
@@ -70,9 +70,8 @@ static Interpreter createInterpreter(const FilePath &python,
|
|||||||
|
|
||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
pythonProcess.setTimeoutS(1);
|
|
||||||
pythonProcess.setCommand({python, {"--version"}});
|
pythonProcess.setCommand({python, {"--version"}});
|
||||||
pythonProcess.runBlocking();
|
pythonProcess.runBlocking(std::chrono::seconds(1));
|
||||||
if (pythonProcess.result() == ProcessResult::FinishedWithSuccess)
|
if (pythonProcess.result() == ProcessResult::FinishedWithSuccess)
|
||||||
result.name = pythonProcess.cleanedStdOut().trimmed();
|
result.name = pythonProcess.cleanedStdOut().trimmed();
|
||||||
if (result.name.isEmpty())
|
if (result.name.isEmpty())
|
||||||
|
@@ -148,9 +148,8 @@ QString pythonName(const FilePath &pythonPath)
|
|||||||
QString name = nameForPython.value(pythonPath);
|
QString name = nameForPython.value(pythonPath);
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setTimeoutS(2);
|
|
||||||
pythonProcess.setCommand({pythonPath, {"--version"}});
|
pythonProcess.setCommand({pythonPath, {"--version"}});
|
||||||
pythonProcess.runBlocking();
|
pythonProcess.runBlocking(std::chrono::seconds(2));
|
||||||
if (pythonProcess.result() != ProcessResult::FinishedWithSuccess)
|
if (pythonProcess.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
name = pythonProcess.allOutput().trimmed();
|
name = pythonProcess.allOutput().trimmed();
|
||||||
|
@@ -65,9 +65,8 @@ static FormatTask format(FormatTask task)
|
|||||||
QStringList options = task.command.options();
|
QStringList options = task.command.options();
|
||||||
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
|
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
|
||||||
Process process;
|
Process process;
|
||||||
process.setTimeoutS(5);
|
|
||||||
process.setCommand({executable, options});
|
process.setCommand({executable, options});
|
||||||
process.runBlocking();
|
process.runBlocking(std::chrono::seconds(5));
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess) {
|
if (process.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
task.error = Tr::tr("Failed to format: %1.").arg(process.exitMessage());
|
task.error = Tr::tr("Failed to format: %1.").arg(process.exitMessage());
|
||||||
return task;
|
return task;
|
||||||
|
@@ -297,6 +297,7 @@ CommandResult VcsCommand::runBlocking(const FilePath &workingDirectory,
|
|||||||
return vcsCommand.runBlockingHelper(command, timeoutS);
|
return vcsCommand.runBlockingHelper(command, timeoutS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: change timeout to std::chrono::seconds
|
||||||
CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int timeoutS)
|
CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int timeoutS)
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
@@ -305,11 +306,10 @@ CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int time
|
|||||||
|
|
||||||
const Internal::VcsCommandPrivate::Job job{command, timeoutS, d->m_defaultWorkingDirectory};
|
const Internal::VcsCommandPrivate::Job job{command, timeoutS, d->m_defaultWorkingDirectory};
|
||||||
d->setupProcess(&process, job);
|
d->setupProcess(&process, job);
|
||||||
process.setTimeoutS(timeoutS);
|
|
||||||
|
|
||||||
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
||||||
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
||||||
process.runBlocking(eventLoopMode);
|
process.runBlocking(std::chrono::seconds(timeoutS), eventLoopMode);
|
||||||
d->handleDone(&process, job);
|
d->handleDone(&process, job);
|
||||||
|
|
||||||
return CommandResult(process);
|
return CommandResult(process);
|
||||||
|
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
// This handler is inspired by the one used in qtbase/tests/auto/corelib/io/qfile/tst_qfile.cpp
|
// This handler is inspired by the one used in qtbase/tests/auto/corelib/io/qfile/tst_qfile.cpp
|
||||||
class MessageHandler {
|
class MessageHandler {
|
||||||
public:
|
public:
|
||||||
@@ -943,33 +946,32 @@ void tst_Process::exitCode()
|
|||||||
void tst_Process::runBlockingStdOut_data()
|
void tst_Process::runBlockingStdOut_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<bool>("withEndl");
|
QTest::addColumn<bool>("withEndl");
|
||||||
QTest::addColumn<int>("timeOutS");
|
QTest::addColumn<seconds>("timeout");
|
||||||
QTest::addColumn<ProcessResult>("expectedResult");
|
QTest::addColumn<ProcessResult>("expectedResult");
|
||||||
|
|
||||||
// Canceled, since the process is killed (canceled) from the callback.
|
// Canceled, since the process is killed (canceled) from the callback.
|
||||||
QTest::newRow("Short timeout with end of line") << true << 2 << ProcessResult::Canceled;
|
QTest::newRow("Short timeout with end of line") << true << 2s << ProcessResult::Canceled;
|
||||||
|
|
||||||
// Canceled, since it times out.
|
// Canceled, since it times out.
|
||||||
QTest::newRow("Short timeout without end of line") << false << 2 << ProcessResult::Canceled;
|
QTest::newRow("Short timeout without end of line") << false << 2s << ProcessResult::Canceled;
|
||||||
|
|
||||||
// FinishedWithSuccess, since it doesn't time out, it finishes process normally,
|
// FinishedWithSuccess, since it doesn't time out, it finishes process normally,
|
||||||
// calls the callback handler and tries to stop the process forcefully what is no-op
|
// calls the callback handler and tries to stop the process forcefully what is no-op
|
||||||
// at this point in time since the process is already finished.
|
// at this point in time since the process is already finished.
|
||||||
QTest::newRow("Long timeout without end of line")
|
QTest::newRow("Long timeout without end of line")
|
||||||
<< false << 20 << ProcessResult::FinishedWithSuccess;
|
<< false << 20s << ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_Process::runBlockingStdOut()
|
void tst_Process::runBlockingStdOut()
|
||||||
{
|
{
|
||||||
QFETCH(bool, withEndl);
|
QFETCH(bool, withEndl);
|
||||||
QFETCH(int, timeOutS);
|
QFETCH(seconds, timeout);
|
||||||
QFETCH(ProcessResult, expectedResult);
|
QFETCH(ProcessResult, expectedResult);
|
||||||
|
|
||||||
SubProcessConfig subConfig(ProcessTestApp::RunBlockingStdOut::envVar(), withEndl ? "true" : "false");
|
SubProcessConfig subConfig(ProcessTestApp::RunBlockingStdOut::envVar(), withEndl ? "true" : "false");
|
||||||
Process process;
|
Process process;
|
||||||
subConfig.setupSubProcess(&process);
|
subConfig.setupSubProcess(&process);
|
||||||
|
|
||||||
process.setTimeoutS(timeOutS);
|
|
||||||
bool readLastLine = false;
|
bool readLastLine = false;
|
||||||
process.setStdOutCallback([&readLastLine, &process](const QString &out) {
|
process.setStdOutCallback([&readLastLine, &process](const QString &out) {
|
||||||
if (out.startsWith(s_runBlockingStdOutSubProcessMagicWord)) {
|
if (out.startsWith(s_runBlockingStdOutSubProcessMagicWord)) {
|
||||||
@@ -977,7 +979,7 @@ void tst_Process::runBlockingStdOut()
|
|||||||
process.kill();
|
process.kill();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
process.runBlocking();
|
process.runBlocking(timeout);
|
||||||
|
|
||||||
// See also QTCREATORBUG-25667 for why it is a bad idea to use Process::runBlocking
|
// See also QTCREATORBUG-25667 for why it is a bad idea to use Process::runBlocking
|
||||||
// with interactive cli tools.
|
// with interactive cli tools.
|
||||||
@@ -993,14 +995,13 @@ void tst_Process::runBlockingSignal_data()
|
|||||||
void tst_Process::runBlockingSignal()
|
void tst_Process::runBlockingSignal()
|
||||||
{
|
{
|
||||||
QFETCH(bool, withEndl);
|
QFETCH(bool, withEndl);
|
||||||
QFETCH(int, timeOutS);
|
QFETCH(seconds, timeout);
|
||||||
QFETCH(ProcessResult, expectedResult);
|
QFETCH(ProcessResult, expectedResult);
|
||||||
|
|
||||||
SubProcessConfig subConfig(ProcessTestApp::RunBlockingStdOut::envVar(), withEndl ? "true" : "false");
|
SubProcessConfig subConfig(ProcessTestApp::RunBlockingStdOut::envVar(), withEndl ? "true" : "false");
|
||||||
Process process;
|
Process process;
|
||||||
subConfig.setupSubProcess(&process);
|
subConfig.setupSubProcess(&process);
|
||||||
|
|
||||||
process.setTimeoutS(timeOutS);
|
|
||||||
bool readLastLine = false;
|
bool readLastLine = false;
|
||||||
process.setTextChannelMode(Channel::Output, TextChannelMode::MultiLine);
|
process.setTextChannelMode(Channel::Output, TextChannelMode::MultiLine);
|
||||||
connect(&process, &Process::textOnStandardOutput,
|
connect(&process, &Process::textOnStandardOutput,
|
||||||
@@ -1010,7 +1011,7 @@ void tst_Process::runBlockingSignal()
|
|||||||
process.kill();
|
process.kill();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
process.runBlocking();
|
process.runBlocking(timeout);
|
||||||
|
|
||||||
// See also QTCREATORBUG-25667 for why it is a bad idea to use Process::runBlocking
|
// See also QTCREATORBUG-25667 for why it is a bad idea to use Process::runBlocking
|
||||||
// with interactive cli tools.
|
// with interactive cli tools.
|
||||||
@@ -1593,7 +1594,7 @@ void tst_Process::eventLoopMode()
|
|||||||
Process process;
|
Process process;
|
||||||
subConfig.setupSubProcess(&process);
|
subConfig.setupSubProcess(&process);
|
||||||
process.setProcessImpl(processImpl);
|
process.setProcessImpl(processImpl);
|
||||||
process.runBlocking(eventLoopMode);
|
process.runBlocking(10s, eventLoopMode);
|
||||||
QCOMPARE(process.result(), ProcessResult::FinishedWithSuccess);
|
QCOMPARE(process.result(), ProcessResult::FinishedWithSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1602,7 +1603,7 @@ void tst_Process::eventLoopMode()
|
|||||||
process.setCommand({FilePath::fromString(
|
process.setCommand({FilePath::fromString(
|
||||||
"there_is_a_big_chance_that_executable_with_that_name_does_not_exists"), {} });
|
"there_is_a_big_chance_that_executable_with_that_name_does_not_exists"), {} });
|
||||||
process.setProcessImpl(processImpl);
|
process.setProcessImpl(processImpl);
|
||||||
process.runBlocking(eventLoopMode);
|
process.runBlocking(10s, eventLoopMode);
|
||||||
QCOMPARE(process.result(), ProcessResult::StartFailed);
|
QCOMPARE(process.result(), ProcessResult::StartFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user