Valgrind test: Use Utils::Process instead of QProcess

Change-Id: Id7a0611fd7d36adc22993f50cce87cd30c6a336c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-08-08 20:50:00 +02:00
parent 0be0772fc9
commit bce2dde117
2 changed files with 9 additions and 13 deletions

View File

@@ -14,7 +14,6 @@
#include <projectexplorer/runcontrol.h>
#include <QFileInfo>
#include <QProcess>
#include <QTcpServer>
#include <QTest>
@@ -148,17 +147,17 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
{
QVERIFY(!m_server->hasPendingConnections());
m_process = new QProcess(m_server);
m_process.reset(new Process);
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
const QString fakeValgrind = fakeValgrindExecutable();
const QFileInfo fileInfo(fakeValgrind);
QVERIFY2(fileInfo.isExecutable(), qPrintable(fakeValgrind));
QVERIFY2(!fileInfo.isDir(), qPrintable(fakeValgrind));
m_process->start(
fakeValgrind,
QStringList({QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), "-i",
testfile}) << otherArgs);
const QStringList args = {QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()),
"-i", testfile};
m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs});
m_process->start();
QVERIFY(m_process->waitForStarted(5000));
QCOMPARE(m_process->state(), QProcess::Running);
@@ -171,10 +170,7 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
void ValgrindMemcheckParserTest::cleanup()
{
m_socket.reset();
if (m_process) {
delete m_process;
m_process = nullptr;
}
m_process.reset();
}
void ValgrindMemcheckParserTest::testHelgrindSample1()

View File

@@ -3,12 +3,12 @@
#pragma once
#include <QObject>
#include <utils/process.h>
#include <QStringList>
#include <QTcpSocket>
QT_BEGIN_NAMESPACE
class QProcess;
class QTcpServer;
QT_END_NAMESPACE
@@ -40,7 +40,7 @@ private:
void initTest(const QString &testfile, const QStringList &otherArgs = {});
QTcpServer *m_server = nullptr;
QProcess *m_process = nullptr;
std::unique_ptr<Utils::Process> m_process;
std::unique_ptr<QTcpSocket> m_socket;
};