forked from qt-creator/qt-creator
Process: Change signature of waitForXxx() functions
Change the arg to QDeadlineTimer type. Change-Id: Id3dee0717e44130c16baf7925e5b06346a1a1ad1 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
Q_LOGGING_CATEGORY(deviceShellLog, "qtc.utils.deviceshell", QtWarningMsg)
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Utils {
|
||||
|
||||
/*
|
||||
@@ -277,7 +279,7 @@ expected_str<void> DeviceShell::installShellScript()
|
||||
m_shellProcess->writeRaw(scriptCmd);
|
||||
|
||||
while (m_shellScriptState == State::Unknown) {
|
||||
if (!m_shellProcess->waitForReadyRead(5000)) {
|
||||
if (!m_shellProcess->waitForReadyRead(5s)) {
|
||||
return make_unexpected(Tr::tr("Timeout while waiting for shell script installation."));
|
||||
}
|
||||
|
||||
@@ -305,7 +307,7 @@ void DeviceShell::closeShellProcess()
|
||||
if (m_shellProcess) {
|
||||
if (m_shellProcess->isRunning()) {
|
||||
m_shellProcess->write("exit\nexit\n");
|
||||
if (!m_shellProcess->waitForFinished(2000))
|
||||
if (!m_shellProcess->waitForFinished(2s))
|
||||
m_shellProcess->terminate();
|
||||
}
|
||||
m_shellProcess.reset();
|
||||
|
@@ -837,7 +837,7 @@ public:
|
||||
emit (q->*signalName)();
|
||||
}
|
||||
|
||||
bool waitForSignal(ProcessSignalType signalType, int msecs);
|
||||
bool waitForSignal(ProcessSignalType signalType, QDeadlineTimer timeout);
|
||||
Qt::ConnectionType connectionType() const;
|
||||
void sendControlSignal(ControlSignal controlSignal);
|
||||
|
||||
@@ -1062,11 +1062,10 @@ void GeneralProcessBlockingImpl::appendSignal(ProcessInterfaceSignal *newSignal)
|
||||
m_signals.append(newSignal);
|
||||
}
|
||||
|
||||
bool ProcessPrivate::waitForSignal(ProcessSignalType newSignal, int msecs)
|
||||
bool ProcessPrivate::waitForSignal(ProcessSignalType newSignal, QDeadlineTimer timeout)
|
||||
{
|
||||
const QDeadlineTimer timeout(msecs);
|
||||
const QDeadlineTimer currentKillTimeout(m_killTimer.remainingTime());
|
||||
const bool needsSplit = m_killTimer.isActive() ? timeout > currentKillTimeout : false;
|
||||
const bool needsSplit = m_killTimer.isActive() && timeout > currentKillTimeout;
|
||||
const QDeadlineTimer mainTimeout = needsSplit ? currentKillTimeout : timeout;
|
||||
|
||||
bool result = m_blockingInterface->waitForSignal(newSignal, mainTimeout.remainingTime());
|
||||
@@ -1441,6 +1440,7 @@ static bool askToKill(const CommandLine &command)
|
||||
// occurs on stderr/stdout as opposed to waitForFinished()). Returns false if a timeout
|
||||
// occurs. Checking of the process' exit state/code still has to be done.
|
||||
|
||||
// TODO: Is it really needed?
|
||||
bool Process::readDataFromProcess(QByteArray *stdOut, QByteArray *stdErr, int timeoutS)
|
||||
{
|
||||
enum { syncDebug = 0 };
|
||||
@@ -1455,7 +1455,7 @@ bool Process::readDataFromProcess(QByteArray *stdOut, QByteArray *stdErr, int ti
|
||||
bool finished = false;
|
||||
bool hasData = false;
|
||||
do {
|
||||
finished = waitForFinished(timeoutS > 0 ? timeoutS * 1000 : -1)
|
||||
finished = waitForFinished(timeoutS > 0 ? seconds(timeoutS) : seconds(-1))
|
||||
|| state() == QProcess::NotRunning;
|
||||
// First check 'stdout'
|
||||
const QByteArray newStdOut = readAllRawStandardOutput();
|
||||
@@ -1541,7 +1541,7 @@ qint64 Process::processId() const
|
||||
return d->m_processId;
|
||||
}
|
||||
|
||||
bool Process::waitForStarted(int msecs)
|
||||
bool Process::waitForStarted(QDeadlineTimer timeout)
|
||||
{
|
||||
QTC_ASSERT(d->m_process, return false);
|
||||
if (d->m_state == QProcess::Running)
|
||||
@@ -1549,23 +1549,23 @@ bool Process::waitForStarted(int msecs)
|
||||
if (d->m_state == QProcess::NotRunning)
|
||||
return false;
|
||||
return s_waitForStarted.measureAndRun(&ProcessPrivate::waitForSignal, d,
|
||||
ProcessSignalType::Started, msecs);
|
||||
ProcessSignalType::Started, timeout);
|
||||
}
|
||||
|
||||
bool Process::waitForReadyRead(int msecs)
|
||||
bool Process::waitForReadyRead(QDeadlineTimer timeout)
|
||||
{
|
||||
QTC_ASSERT(d->m_process, return false);
|
||||
if (d->m_state == QProcess::NotRunning)
|
||||
return false;
|
||||
return d->waitForSignal(ProcessSignalType::ReadyRead, msecs);
|
||||
return d->waitForSignal(ProcessSignalType::ReadyRead, timeout);
|
||||
}
|
||||
|
||||
bool Process::waitForFinished(int msecs)
|
||||
bool Process::waitForFinished(QDeadlineTimer timeout)
|
||||
{
|
||||
QTC_ASSERT(d->m_process, return false);
|
||||
if (d->m_state == QProcess::NotRunning)
|
||||
return false;
|
||||
return d->waitForSignal(ProcessSignalType::Done, msecs);
|
||||
return d->waitForSignal(ProcessSignalType::Done, timeout);
|
||||
}
|
||||
|
||||
QByteArray Process::readAllRawStandardOutput()
|
||||
@@ -1884,7 +1884,7 @@ void Process::runBlocking(seconds timeout, EventLoopMode eventLoopMode)
|
||||
if (state() == QProcess::NotRunning)
|
||||
return;
|
||||
stop();
|
||||
QTC_CHECK(waitForFinished(2000));
|
||||
QTC_CHECK(waitForFinished(2s));
|
||||
};
|
||||
|
||||
if (eventLoopMode == EventLoopMode::On) {
|
||||
@@ -1919,7 +1919,7 @@ void Process::runBlocking(seconds timeout, EventLoopMode eventLoopMode)
|
||||
#endif
|
||||
} else {
|
||||
handleStart();
|
||||
if (!waitForFinished(duration_cast<milliseconds>(timeout).count()))
|
||||
if (!waitForFinished(timeout))
|
||||
handleTimeout();
|
||||
}
|
||||
if (blockingThresholdMs > 0) {
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
|
||||
#include <QDeadlineTimer>
|
||||
#include <QProcess>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -73,10 +74,9 @@ public:
|
||||
QProcess::ProcessError error() const;
|
||||
QString errorString() const;
|
||||
|
||||
// TODO: Change to std::chrono::milliseconds.
|
||||
bool waitForStarted(int msecs = 30000);
|
||||
bool waitForReadyRead(int msecs = 30000);
|
||||
bool waitForFinished(int msecs = 30000);
|
||||
bool waitForStarted(QDeadlineTimer timeout = std::chrono::seconds(30));
|
||||
bool waitForReadyRead(QDeadlineTimer timeout = std::chrono::seconds(30));
|
||||
bool waitForFinished(QDeadlineTimer timeout = std::chrono::seconds(30));
|
||||
|
||||
// ProcessSetupData related
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
using namespace Utils;
|
||||
using namespace std;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Android::Internal {
|
||||
|
||||
@@ -100,7 +101,7 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
|
||||
QString errorOutput;
|
||||
QByteArray question;
|
||||
while (errorOutput.isEmpty()) {
|
||||
proc.waitForReadyRead(500);
|
||||
proc.waitForReadyRead(500ms);
|
||||
question += proc.readAllRawStandardOutput();
|
||||
if (question.endsWith(QByteArray("]:"))) {
|
||||
// truncate to last line
|
||||
@@ -271,7 +272,7 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
|
||||
qCDebug(avdManagerLog).noquote() << "Running command (startAvdAsync):" << cmd.toUserOutput();
|
||||
avdProcess->setCommand(cmd);
|
||||
avdProcess->start();
|
||||
return avdProcess->waitForStarted(-1);
|
||||
return avdProcess->waitForStarted(QDeadlineTimer::Forever);
|
||||
}
|
||||
|
||||
QString AndroidAvdManager::findAvd(const QString &avdName) const
|
||||
|
@@ -53,6 +53,8 @@
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Android::Internal {
|
||||
|
||||
static Q_LOGGING_CATEGORY(deployStepLog, "qtc.android.build.androiddeployqtstep", QtWarningMsg)
|
||||
@@ -398,7 +400,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy(QPromise<voi
|
||||
|
||||
emit addOutput(Tr::tr("Starting: \"%1\"").arg(cmd.toUserOutput()), OutputFormat::NormalMessage);
|
||||
|
||||
while (!process.waitForFinished(200)) {
|
||||
while (!process.waitForFinished(200ms)) {
|
||||
if (process.state() == QProcess::NotRunning)
|
||||
break;
|
||||
|
||||
@@ -576,7 +578,7 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
||||
OutputFormat::NormalMessage);
|
||||
|
||||
buildProc.setCommand(command);
|
||||
buildProc.runBlocking(std::chrono::minutes(2), EventLoopMode::On);
|
||||
buildProc.runBlocking(2min, EventLoopMode::On);
|
||||
if (buildProc.result() != ProcessResult::FinishedWithSuccess)
|
||||
reportWarningOrError(buildProc.exitMessage(), Task::Error);
|
||||
}
|
||||
|
@@ -656,7 +656,7 @@ Process *startAdbProcess(const QStringList &args, QString *err)
|
||||
qCDebug(androidManagerLog).noquote() << "Running command (async):" << command.toUserOutput();
|
||||
process->setCommand(command);
|
||||
process->start();
|
||||
if (process->waitForStarted(500) && process->state() == QProcess::Running)
|
||||
if (process->waitForStarted(500ms) && process->state() == QProcess::Running)
|
||||
return process.release();
|
||||
|
||||
const QString errorStr = process->readAllStandardError();
|
||||
|
@@ -517,7 +517,7 @@ void Android::Internal::AndroidRunnerWorker::asyncStartLogcat()
|
||||
<< CommandLine(adb, logcatArgs).toUserOutput();
|
||||
m_adbLogcatProcess->setCommand({adb, logcatArgs});
|
||||
m_adbLogcatProcess->start();
|
||||
if (m_adbLogcatProcess->waitForStarted(500) && m_adbLogcatProcess->state() == QProcess::Running)
|
||||
if (m_adbLogcatProcess->waitForStarted(500ms) && m_adbLogcatProcess->state() == QProcess::Running)
|
||||
m_adbLogcatProcess->setObjectName("AdbLogcatProcess");
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ void AndroidRunnerWorker::handleJdbSettled()
|
||||
qCDebug(androidRunWorkerLog) << "Handle JDB settled";
|
||||
auto waitForCommand = [this] {
|
||||
for (int i = 0; i < 120 && m_jdbProcess->state() == QProcess::Running; ++i) {
|
||||
m_jdbProcess->waitForReadyRead(500);
|
||||
m_jdbProcess->waitForReadyRead(500ms);
|
||||
const QByteArray lines = m_jdbProcess->readAllRawStandardOutput();
|
||||
const auto linesList = lines.split('\n');
|
||||
for (const auto &line : linesList) {
|
||||
@@ -787,7 +787,7 @@ void AndroidRunnerWorker::handleJdbSettled()
|
||||
m_jdbProcess->write(QString("%1\n").arg(command));
|
||||
}
|
||||
|
||||
if (!m_jdbProcess->waitForFinished(s_jdbTimeout.count())) {
|
||||
if (!m_jdbProcess->waitForFinished(s_jdbTimeout)) {
|
||||
m_jdbProcess.reset();
|
||||
} else if (m_jdbProcess->exitStatus() == QProcess::NormalExit && m_jdbProcess->exitCode() == 0) {
|
||||
qCDebug(androidRunWorkerLog) << "JDB settled";
|
||||
|
@@ -27,6 +27,7 @@ const char commonArgsKey[] = "Common Arguments:";
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std::chrono;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
@@ -528,7 +529,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
||||
licenseCommand.start();
|
||||
QTextCodec *codec = QTextCodec::codecForLocale();
|
||||
int inputCounter = 0, steps = -1;
|
||||
while (!licenseCommand.waitForFinished(200)) {
|
||||
while (!licenseCommand.waitForFinished(200ms)) {
|
||||
QString stdOut = codec->toUnicode(licenseCommand.readAllRawStandardOutput());
|
||||
bool assertionFound = false;
|
||||
if (!stdOut.isEmpty())
|
||||
@@ -556,9 +557,9 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
||||
|
||||
if (fi.isCanceled()) {
|
||||
licenseCommand.terminate();
|
||||
if (!licenseCommand.waitForFinished(300)) {
|
||||
if (!licenseCommand.waitForFinished(300ms)) {
|
||||
licenseCommand.kill();
|
||||
licenseCommand.waitForFinished(200);
|
||||
licenseCommand.waitForFinished(200ms);
|
||||
}
|
||||
}
|
||||
if (licenseCommand.state() == QProcess::NotRunning)
|
||||
|
@@ -120,7 +120,7 @@ public:
|
||||
QVersionNumber version() const
|
||||
{
|
||||
if (m_process.state() != QProcess::NotRunning)
|
||||
m_process.waitForFinished(-1);
|
||||
m_process.waitForFinished(QDeadlineTimer::Forever);
|
||||
return m_versionNumber;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool)
|
||||
Process getConf;
|
||||
getConf.setCommand({"getconf", {"ARG_MAX"}});
|
||||
getConf.start();
|
||||
getConf.waitForFinished(2000);
|
||||
getConf.waitForFinished(std::chrono::seconds(2));
|
||||
const QByteArray argMax = getConf.rawStdOut().replace("\n", "");
|
||||
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
||||
}
|
||||
|
@@ -213,7 +213,7 @@ void LldbEngine::setupEngine()
|
||||
|
||||
void LldbEngine::handleLldbStarted()
|
||||
{
|
||||
m_lldbProc.waitForReadyRead(1000);
|
||||
m_lldbProc.waitForReadyRead(std::chrono::seconds(1));
|
||||
|
||||
showStatusMessage(Tr::tr("Setting up inferior..."));
|
||||
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
#include <QJsonArray>
|
||||
@@ -23,7 +22,9 @@
|
||||
#include <QLoggingCategory>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
|
||||
namespace {
|
||||
static Q_LOGGING_CATEGORY(simulatorLog, "qtc.ios.simulator", QtWarningMsg)
|
||||
@@ -31,7 +32,7 @@ static Q_LOGGING_CATEGORY(simulatorLog, "qtc.ios.simulator", QtWarningMsg)
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
const std::chrono::seconds simulatorStartTimeout = std::chrono::seconds(60);
|
||||
const seconds simulatorStartTimeout = seconds(60);
|
||||
|
||||
// simctl Json Tags and tokens.
|
||||
const char deviceTypeTag[] = "devicetypes";
|
||||
@@ -61,7 +62,7 @@ static expected_str<void> runCommand(
|
||||
return make_unexpected(Tr::tr("Failed to start process."));
|
||||
|
||||
forever {
|
||||
if (shouldStop() || p.waitForFinished(1000))
|
||||
if (shouldStop() || p.waitForFinished(seconds(1)))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -49,11 +49,10 @@ QString McuPackageExecutableVersionDetector::parseVersion(const FilePath &packag
|
||||
break;
|
||||
}
|
||||
|
||||
const int timeout = 3000; // usually runs below 1s, but we want to be on the safe side
|
||||
Process process;
|
||||
process.setCommand({binaryPath, m_detectionArgs});
|
||||
process.start();
|
||||
if (!process.waitForFinished(timeout) || process.result() != ProcessResult::FinishedWithSuccess)
|
||||
if (!process.waitForFinished(std::chrono::seconds(3)) || process.result() != ProcessResult::FinishedWithSuccess)
|
||||
return {};
|
||||
|
||||
return matchRegExp(process.allOutput(), m_detectionRegExp);
|
||||
|
@@ -390,7 +390,7 @@ void ProcessExtraCompiler::runInThread(QPromise<FileNameToContentsHash> &promise
|
||||
return;
|
||||
|
||||
while (!promise.isCanceled()) {
|
||||
if (process.waitForFinished(200))
|
||||
if (process.waitForFinished(std::chrono::milliseconds(200)))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -1325,7 +1325,7 @@ void SimpleTargetRunnerPrivate::stop()
|
||||
switch (m_state) {
|
||||
case Run:
|
||||
m_process.stop();
|
||||
if (!m_process.waitForFinished(2000)) { // TODO: it may freeze on some devices
|
||||
if (!m_process.waitForFinished(std::chrono::seconds(2))) { // TODO: it may freeze on some devices
|
||||
q->appendMessage(Tr::tr("Remote process did not finish in time. "
|
||||
"Connectivity lost?"), ErrorMessageFormat);
|
||||
m_process.close();
|
||||
|
@@ -229,7 +229,7 @@ QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, cons
|
||||
Utils::Process qbsConfig;
|
||||
qbsConfig.setCommand({qbsConfigExe, args});
|
||||
qbsConfig.start();
|
||||
if (!qbsConfig.waitForFinished(5000)) {
|
||||
if (!qbsConfig.waitForFinished(std::chrono::seconds(5))) {
|
||||
Core::MessageManager::writeFlashing(
|
||||
Tr::tr("Failed to run qbs config: %1").arg(qbsConfig.errorString()));
|
||||
} else if (qbsConfig.exitCode() != 0) {
|
||||
|
@@ -215,7 +215,7 @@ QbsSession::~QbsSession()
|
||||
d->qbsProcess->disconnect(this);
|
||||
if (d->qbsProcess->state() == QProcess::Running) {
|
||||
sendQuitPacket();
|
||||
d->qbsProcess->waitForFinished(10000);
|
||||
d->qbsProcess->waitForFinished(std::chrono::seconds(10));
|
||||
}
|
||||
delete d->qbsProcess;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ static QString getQbsVersion(const FilePath &qbsExe)
|
||||
Process qbsProc;
|
||||
qbsProc.setCommand({qbsExe, {"--version"}});
|
||||
qbsProc.start();
|
||||
if (!qbsProc.waitForFinished(5000) || qbsProc.exitCode() != 0)
|
||||
if (!qbsProc.waitForFinished(std::chrono::seconds(5)) || qbsProc.exitCode() != 0)
|
||||
return {};
|
||||
return QString::fromLocal8Bit(qbsProc.rawStdOut()).trimmed();
|
||||
}
|
||||
|
@@ -107,7 +107,7 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const FilePath &filePath)
|
||||
|
||||
// waiting for finish
|
||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||
bool waitResult = process.waitForFinished(10000);
|
||||
bool waitResult = process.waitForFinished(std::chrono::seconds(10));
|
||||
QApplication::restoreOverrideCursor();
|
||||
if (!waitResult)
|
||||
return items;
|
||||
|
@@ -450,7 +450,7 @@ bool SshProcessInterface::runInShell(const CommandLine &command, const QByteArra
|
||||
process.setCommand(cmd);
|
||||
process.setWriteData(data);
|
||||
process.start();
|
||||
bool isFinished = process.waitForFinished(2000); // It may freeze on some devices
|
||||
bool isFinished = process.waitForFinished(std::chrono::seconds(2)); // It may freeze on some devices
|
||||
if (!isFinished) {
|
||||
Core::MessageManager::writeFlashing(tr("Can't send control signal to the %1 device. "
|
||||
"The device might have been disconnected.")
|
||||
|
@@ -51,7 +51,7 @@ static bool isSilverSearcherAvailable()
|
||||
Process silverSearcherProcess;
|
||||
silverSearcherProcess.setCommand({"ag", {"--version"}});
|
||||
silverSearcherProcess.start();
|
||||
return silverSearcherProcess.waitForFinished(1000)
|
||||
return silverSearcherProcess.waitForFinished(std::chrono::seconds(1))
|
||||
&& silverSearcherProcess.cleanedStdOut().contains("ag version");
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,8 @@
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
void formatCurrentFile(const Command &command, int startPos, int endPos)
|
||||
@@ -66,7 +68,7 @@ static FormatTask format(FormatTask task)
|
||||
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
|
||||
Process process;
|
||||
process.setCommand({executable, options});
|
||||
process.runBlocking(std::chrono::seconds(5));
|
||||
process.runBlocking(5s);
|
||||
if (process.result() != ProcessResult::FinishedWithSuccess) {
|
||||
task.error = Tr::tr("Failed to format: %1.").arg(process.exitMessage());
|
||||
return task;
|
||||
@@ -94,7 +96,7 @@ static FormatTask format(FormatTask task)
|
||||
process.setCommand({executable, options});
|
||||
process.setWriteData(task.sourceData.toUtf8());
|
||||
process.start();
|
||||
if (!process.waitForFinished(5000)) {
|
||||
if (!process.waitForFinished(5s)) {
|
||||
task.error = Tr::tr("Cannot call %1 or some other error occurred. Timeout "
|
||||
"reached while formatting file %2.")
|
||||
.arg(executable.toUserOutput(), task.filePath.displayName());
|
||||
|
@@ -192,7 +192,7 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
|
||||
m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs});
|
||||
m_process->start();
|
||||
|
||||
QVERIFY(m_process->waitForStarted(5000));
|
||||
QVERIFY(m_process->waitForStarted(std::chrono::seconds(5)));
|
||||
QCOMPARE(m_process->state(), QProcess::Running);
|
||||
QVERIFY2(m_process->error() == QProcess::UnknownError, qPrintable(m_process->errorString()));
|
||||
QVERIFY(m_server->waitForNewConnection(5000));
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static QHash<const char *, ProcessTestApp::SubProcessMain> s_subProcesses = {};
|
||||
|
||||
ProcessTestApp::ProcessTestApp() = default;
|
||||
@@ -289,12 +291,12 @@ int ProcessTestApp::RecursiveBlockingProcess::main()
|
||||
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
process.start();
|
||||
while (true) {
|
||||
if (process.waitForFinished(10))
|
||||
if (process.waitForFinished(10ms))
|
||||
return 0;
|
||||
#ifndef Q_OS_WIN
|
||||
if (s_terminate.load()) {
|
||||
process.terminate();
|
||||
process.waitForFinished(-1);
|
||||
process.waitForFinished(QDeadlineTimer::Forever);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@@ -281,17 +281,17 @@ void tst_Process::multiRead()
|
||||
QVERIFY(process.waitForStarted());
|
||||
|
||||
process.writeRaw("hi\n");
|
||||
QVERIFY(process.waitForReadyRead(1000));
|
||||
QVERIFY(process.waitForReadyRead(1s));
|
||||
buffer = readData(&process, processChannel);
|
||||
QCOMPARE(buffer, QByteArray("hi"));
|
||||
|
||||
process.writeRaw("you\n");
|
||||
QVERIFY(process.waitForReadyRead(1000));
|
||||
QVERIFY(process.waitForReadyRead(1s));
|
||||
buffer = readData(&process, processChannel);
|
||||
QCOMPARE(buffer, QByteArray("you"));
|
||||
|
||||
process.writeRaw("exit\n");
|
||||
QVERIFY(process.waitForFinished(1000));
|
||||
QVERIFY(process.waitForFinished(1s));
|
||||
}
|
||||
|
||||
void tst_Process::splitArgs_data()
|
||||
@@ -1154,15 +1154,16 @@ void tst_Process::notRunningAfterStartingNonExistingProgram()
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
const int maxWaitTimeMs = 1000;
|
||||
const seconds timeout = 1s;
|
||||
|
||||
switch (signalType) {
|
||||
case ProcessSignalType::Started: QVERIFY(!process.waitForStarted(maxWaitTimeMs)); break;
|
||||
case ProcessSignalType::ReadyRead: QVERIFY(!process.waitForReadyRead(maxWaitTimeMs)); break;
|
||||
case ProcessSignalType::Done: QVERIFY(!process.waitForFinished(maxWaitTimeMs)); break;
|
||||
case ProcessSignalType::Started: QVERIFY(!process.waitForStarted(timeout)); break;
|
||||
case ProcessSignalType::ReadyRead: QVERIFY(!process.waitForReadyRead(timeout)); break;
|
||||
case ProcessSignalType::Done: QVERIFY(!process.waitForFinished(timeout)); break;
|
||||
}
|
||||
|
||||
QVERIFY(timer.elapsed() < maxWaitTimeMs); // shouldn't wait, should finish immediately
|
||||
// shouldn't wait, should finish immediately
|
||||
QVERIFY(timer.elapsed() < duration_cast<milliseconds>(timeout).count());
|
||||
QCOMPARE(process.state(), QProcess::NotRunning);
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(process.error(), QProcess::FailedToStart);
|
||||
@@ -1284,7 +1285,7 @@ void tst_Process::destroyBlockingProcess()
|
||||
process.start();
|
||||
QVERIFY(process.waitForStarted());
|
||||
QVERIFY(process.isRunning());
|
||||
QVERIFY(!process.waitForFinished(1000));
|
||||
QVERIFY(!process.waitForFinished(1s));
|
||||
}
|
||||
|
||||
void tst_Process::flushFinishedWhileWaitingForReadyRead_data()
|
||||
@@ -1314,7 +1315,7 @@ void tst_Process::flushFinishedWhileWaitingForReadyRead()
|
||||
QDeadlineTimer timer(1000);
|
||||
QByteArray reply;
|
||||
while (process.state() == QProcess::Running) {
|
||||
process.waitForReadyRead(500);
|
||||
process.waitForReadyRead(500ms);
|
||||
if (processChannel == QProcess::StandardOutput)
|
||||
reply += process.readAllRawStandardOutput();
|
||||
else
|
||||
@@ -1335,7 +1336,7 @@ void tst_Process::crash()
|
||||
subConfig.setupSubProcess(&process);
|
||||
|
||||
process.start();
|
||||
QVERIFY(process.waitForStarted(1000));
|
||||
QVERIFY(process.waitForStarted(1s));
|
||||
QVERIFY(process.isRunning());
|
||||
|
||||
QEventLoop loop;
|
||||
@@ -1353,11 +1354,11 @@ void tst_Process::crashAfterOneSecond()
|
||||
subConfig.setupSubProcess(&process);
|
||||
|
||||
process.start();
|
||||
QVERIFY(process.waitForStarted(1000));
|
||||
QVERIFY(process.waitForStarted(1s));
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
QVERIFY(process.waitForFinished(30000));
|
||||
QVERIFY(timer.elapsed() < 30000);
|
||||
QVERIFY(process.waitForFinished(30s));
|
||||
QVERIFY(timer.elapsed() < 30000); // in milliseconds
|
||||
QCOMPARE(process.state(), QProcess::NotRunning);
|
||||
QCOMPARE(process.error(), QProcess::Crashed);
|
||||
}
|
||||
@@ -1370,7 +1371,7 @@ void tst_Process::recursiveCrashingProcess()
|
||||
Process process;
|
||||
subConfig.setupSubProcess(&process);
|
||||
process.start();
|
||||
QVERIFY(process.waitForStarted(1000));
|
||||
QVERIFY(process.waitForStarted(1s));
|
||||
QVERIFY(process.waitForFinished());
|
||||
QCOMPARE(process.state(), QProcess::NotRunning);
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
@@ -1544,7 +1545,7 @@ void tst_Process::tarPipe()
|
||||
|
||||
if (targetProcess.isRunning()) {
|
||||
targetProcess.closeWriteChannel();
|
||||
QVERIFY(targetProcess.waitForFinished(2000));
|
||||
QVERIFY(targetProcess.waitForFinished(2s));
|
||||
}
|
||||
|
||||
QCOMPARE(targetProcess.exitCode(), 0);
|
||||
|
Reference in New Issue
Block a user