Utils: Move and rename result testing macros from expected.h to result.h

Change-Id: I65d682054d4774b8937ecce9728a9d2f2e75cc2a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2025-04-14 09:29:10 +02:00
parent 4d643d45f3
commit a51a334941
57 changed files with 166 additions and 179 deletions

View File

@@ -1583,7 +1583,7 @@ QString DockManager::readAttribute(const FilePath &filePath, QStringView key)
bool DockManager::writeAttribute(const FilePath &filePath, QStringView key, const QString &value) bool DockManager::writeAttribute(const FilePath &filePath, QStringView key, const QString &value)
{ {
const Result<QByteArray> content = filePath.fileContents(); const Result<QByteArray> content = filePath.fileContents();
QTC_ASSERT_EXPECTED(content, return false); QTC_ASSERT_RESULT(content, return false);
QDomDocument doc; QDomDocument doc;
QString error_msg; QString error_msg;

View File

@@ -1441,7 +1441,7 @@ static QList<PluginSpec *> createCppPluginsFromArchive(const FilePath &path)
if (path.isFile()) { if (path.isFile()) {
if (QLibrary::isLibrary(path.toFSPathString())) { if (QLibrary::isLibrary(path.toFSPathString())) {
Result<std::unique_ptr<PluginSpec>> spec = readCppPluginSpec(path); Result<std::unique_ptr<PluginSpec>> spec = readCppPluginSpec(path);
QTC_CHECK_EXPECTED(spec); QTC_CHECK_RESULT(spec);
if (spec) if (spec)
results.push_back(spec->release()); results.push_back(spec->release());
} }

View File

@@ -7,7 +7,6 @@
#include "iplugin.h" #include "iplugin.h"
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <QHash> #include <QHash>

View File

@@ -144,7 +144,7 @@ bool FileAccess::isExecutableFile(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ExecutableFile); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ExecutableFile);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking executable file:" << e.what(); qCWarning(faLog) << "Error checking executable file:" << e.what();
@@ -156,7 +156,7 @@ bool FileAccess::isReadableFile(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ReadableFile); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ReadableFile);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking readable file:" << e.what(); qCWarning(faLog) << "Error checking readable file:" << e.what();
@@ -169,7 +169,7 @@ bool FileAccess::isWritableFile(const FilePath &filePath) const
try { try {
Result<QFuture<bool>> f = m_client->is(filePath.nativePath(), Result<QFuture<bool>> f = m_client->is(filePath.nativePath(),
CmdBridge::Client::Is::WritableFile); CmdBridge::Client::Is::WritableFile);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking writable file:" << e.what(); qCWarning(faLog) << "Error checking writable file:" << e.what();
@@ -181,7 +181,7 @@ bool FileAccess::isReadableDirectory(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ReadableDir); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::ReadableDir);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking readable directory:" << e.what(); qCWarning(faLog) << "Error checking readable directory:" << e.what();
@@ -193,7 +193,7 @@ bool FileAccess::isWritableDirectory(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::WritableDir); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::WritableDir);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking writable directory:" << e.what(); qCWarning(faLog) << "Error checking writable directory:" << e.what();
@@ -205,7 +205,7 @@ bool FileAccess::isFile(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::File); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::File);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking file:" << e.what(); qCWarning(faLog) << "Error checking file:" << e.what();
@@ -217,7 +217,7 @@ bool FileAccess::isDirectory(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Dir); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Dir);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking directory:" << e.what(); qCWarning(faLog) << "Error checking directory:" << e.what();
@@ -229,7 +229,7 @@ bool FileAccess::isSymLink(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Symlink); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Symlink);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking symlink:" << e.what(); qCWarning(faLog) << "Error checking symlink:" << e.what();
@@ -241,7 +241,7 @@ bool FileAccess::exists(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Exists); auto f = m_client->is(filePath.nativePath(), CmdBridge::Client::Is::Exists);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking existence:" << e.what(); qCWarning(faLog) << "Error checking existence:" << e.what();
@@ -253,7 +253,7 @@ bool FileAccess::hasHardLinks(const FilePath &filePath) const
{ {
try { try {
auto f = m_client->stat(filePath.nativePath()); auto f = m_client->stat(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
return f->result().numHardLinks > 1; return f->result().numHardLinks > 1;
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error checking hard links:" << e.what(); qCWarning(faLog) << "Error checking hard links:" << e.what();
@@ -349,7 +349,7 @@ qint64 FileAccess::bytesAvailable(const FilePath &filePath) const
{ {
try { try {
Result<QFuture<quint64>> f = m_client->freeSpace(filePath.nativePath()); Result<QFuture<quint64>> f = m_client->freeSpace(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return -1); QTC_ASSERT_RESULT(f, return -1);
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error getting free space:" << e.what(); qCWarning(faLog) << "Error getting free space:" << e.what();
@@ -361,7 +361,7 @@ QByteArray FileAccess::fileId(const FilePath &filePath) const
{ {
try { try {
Result<QFuture<QString>> f = m_client->fileId(filePath.nativePath()); Result<QFuture<QString>> f = m_client->fileId(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
return f->result().toUtf8(); return f->result().toUtf8();
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error getting file ID:" << e.what(); qCWarning(faLog) << "Error getting file ID:" << e.what();
@@ -388,7 +388,7 @@ FilePathInfo FileAccess::filePathInfo(const FilePath &filePath) const
try { try {
Result<QFuture<Client::Stat>> f = m_client->stat(filePath.nativePath()); Result<QFuture<Client::Stat>> f = m_client->stat(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
Client::Stat stat = f->result(); Client::Stat stat = f->result();
return {stat.size, return {stat.size,
fileInfoFlagsfromStatMode(stat.mode) | FilePathInfo::FileFlags(stat.usermode), fileInfoFlagsfromStatMode(stat.mode) | FilePathInfo::FileFlags(stat.usermode),
@@ -403,7 +403,7 @@ FilePath FileAccess::symLinkTarget(const FilePath &filePath) const
{ {
try { try {
Result<QFuture<QString>> f = m_client->readlink(filePath.nativePath()); Result<QFuture<QString>> f = m_client->readlink(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
return filePath.parentDir().resolvePath(filePath.withNewPath(f->result()).path()); return filePath.parentDir().resolvePath(filePath.withNewPath(f->result()).path());
} catch (const std::exception &e) { } catch (const std::exception &e) {
qCWarning(faLog) << "Error getting symlink target:" << e.what(); qCWarning(faLog) << "Error getting symlink target:" << e.what();
@@ -425,7 +425,7 @@ bool FileAccess::setPermissions(const FilePath &filePath, QFile::Permissions per
{ {
try { try {
Result<QFuture<void>> f = m_client->setPermissions(filePath.nativePath(), perms); Result<QFuture<void>> f = m_client->setPermissions(filePath.nativePath(), perms);
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
f->waitForFinished(); f->waitForFinished();
return true; return true;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -447,7 +447,7 @@ Result<QByteArray> FileAccess::fileContents(const FilePath &filePath,
Result<QFuture<QByteArray>> f = m_client->readFile(filePath.nativePath(), Result<QFuture<QByteArray>> f = m_client->readFile(filePath.nativePath(),
limit, limit,
offset); offset);
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
f->waitForFinished(); f->waitForFinished();
QByteArray data; QByteArray data;
for (const QByteArray &result : *f) { for (const QByteArray &result : *f) {
@@ -465,7 +465,7 @@ Result<qint64> FileAccess::writeFileContents(const FilePath &filePath,
{ {
try { try {
Result<QFuture<qint64>> f = m_client->writeFile(filePath.nativePath(), data); Result<QFuture<qint64>> f = m_client->writeFile(filePath.nativePath(), data);
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
return f->result(); return f->result();
} catch (const std::exception &e) { } catch (const std::exception &e) {
return make_unexpected( return make_unexpected(
@@ -499,7 +499,7 @@ Result<> FileAccess::removeRecursively(const Utils::FilePath &filePath) const
{ {
try { try {
auto f = m_client->removeRecursively(filePath.nativePath()); auto f = m_client->removeRecursively(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return ResultError(ResultAssert)); QTC_ASSERT_RESULT(f, return ResultError(ResultAssert));
f->waitForFinished(); f->waitForFinished();
return ResultOk; return ResultOk;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -512,7 +512,7 @@ bool FileAccess::ensureExistingFile(const Utils::FilePath &filePath) const
{ {
try { try {
auto f = m_client->ensureExistingFile(filePath.nativePath()); auto f = m_client->ensureExistingFile(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
f->waitForFinished(); f->waitForFinished();
return true; return true;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -525,7 +525,7 @@ bool FileAccess::createDirectory(const Utils::FilePath &filePath) const
{ {
try { try {
auto f = m_client->createDir(filePath.nativePath()); auto f = m_client->createDir(filePath.nativePath());
QTC_ASSERT_EXPECTED(f, return false); QTC_ASSERT_RESULT(f, return false);
f->waitForFinished(); f->waitForFinished();
return true; return true;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -538,7 +538,7 @@ Result<> FileAccess::copyFile(const FilePath &filePath, const FilePath &target)
{ {
try { try {
auto f = m_client->copyFile(filePath.nativePath(), target.nativePath()); auto f = m_client->copyFile(filePath.nativePath(), target.nativePath());
QTC_ASSERT_EXPECTED(f, return ResultOk); QTC_ASSERT_RESULT(f, return ResultOk);
f->waitForFinished(); f->waitForFinished();
return ResultOk; return ResultOk;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -574,7 +574,7 @@ Result<> FileAccess::signalProcess(int pid, ControlSignal signal) const
{ {
try { try {
auto f = m_client->signalProcess(pid, signal); auto f = m_client->signalProcess(pid, signal);
QTC_ASSERT_EXPECTED(f, return ResultOk); QTC_ASSERT_RESULT(f, return ResultOk);
f->waitForFinished(); f->waitForFinished();
return ResultOk; return ResultOk;
} catch (const std::exception &e) { } catch (const std::exception &e) {
@@ -599,7 +599,7 @@ Result<FilePath> FileAccess::createTempFile(const FilePath &filePath)
} }
Utils::Result<QFuture<Utils::FilePath>> f = m_client->createTempFile(path); Utils::Result<QFuture<Utils::FilePath>> f = m_client->createTempFile(path);
QTC_ASSERT_EXPECTED(f, return {}); QTC_ASSERT_RESULT(f, return {});
f->waitForFinished(); f->waitForFinished();
Result<FilePath> result = f->result(); Result<FilePath> result = f->result();
@@ -617,7 +617,7 @@ void FileAccess::iterateDirectory(const FilePath &filePath,
const FileFilter &filter) const const FileFilter &filter) const
{ {
auto result = m_client->find(filePath.nativePath(), filter); auto result = m_client->find(filePath.nativePath(), filter);
QTC_ASSERT_EXPECTED(result, return); QTC_ASSERT_RESULT(result, return);
int idx = 0; int idx = 0;

View File

@@ -373,7 +373,7 @@ Result<> Client::start(bool deleteOnExit)
packetData.clear(); packetData.clear();
state = 0; state = 0;
auto result = d->readPacket(reader); auto result = d->readPacket(reader);
QTC_CHECK_EXPECTED(result); QTC_CHECK_RESULT(result);
} }
} }
}; };

View File

@@ -5,7 +5,6 @@
#include "cmdbridgeglobal.h" #include "cmdbridgeglobal.h"
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/osspecificaspects.h> #include <utils/osspecificaspects.h>
#include <utils/processinterface.h> #include <utils/processinterface.h>

View File

@@ -3,8 +3,6 @@
#pragma once #pragma once
#include "qtcassert.h"
#include "../3rdparty/tl_expected/include/tl/expected.hpp" #include "../3rdparty/tl_expected/include/tl/expected.hpp"
namespace Utils { namespace Utils {
@@ -12,30 +10,3 @@ namespace Utils {
using namespace tl; using namespace tl;
} // namespace Utils } // namespace Utils
//! If 'expected' has an error the error will be printed and the 'action' will be executed.
#define QTC_ASSERT_EXPECTED(expected, action) \
if (Q_LIKELY(expected)) { \
} else { \
::Utils::writeAssertLocation(QString("%1:%2: %3") \
.arg(__FILE__) \
.arg(__LINE__) \
.arg(expected.error()) \
.toUtf8() \
.data()); \
action; \
} \
do { \
} while (0)
#define QTC_CHECK_EXPECTED(expected) \
if (Q_LIKELY(expected)) { \
} else { \
::Utils::writeAssertLocation( \
QString("%1:%2: %3").arg(__FILE__).arg(__LINE__).arg(expected.error()).toUtf8().data()); \
} \
do { \
} while (0)
#define QVERIFY_EXPECTED(expected) \
QVERIFY2(expected, expected ? #expected : static_cast<const char*>(expected.error().toUtf8()))

View File

@@ -1340,7 +1340,7 @@ DeviceFileAccess *FilePath::fileAccess() const
{ {
static DeviceFileAccess dummy; static DeviceFileAccess dummy;
const Result<DeviceFileAccess *> access = getFileAccess(*this); const Result<DeviceFileAccess *> access = getFileAccess(*this);
QTC_ASSERT_EXPECTED(access, return &dummy); QTC_ASSERT_RESULT(access, return &dummy);
return *access; return *access;
} }
@@ -1900,7 +1900,7 @@ FilePaths FilePath::searchAllInPath(const FilePaths &additionalDirs,
Environment FilePath::deviceEnvironment() const Environment FilePath::deviceEnvironment() const
{ {
Result<Environment> env = deviceEnvironmentWithError(); Result<Environment> env = deviceEnvironmentWithError();
QTC_ASSERT_EXPECTED(env, return {}); QTC_ASSERT_RESULT(env, return {});
return *env; return *env;
} }
@@ -2081,7 +2081,7 @@ Result<> FilePath::renameFile(const FilePath &target) const
// If we fail to remove the source file, we remove the target file to return to the // If we fail to remove the source file, we remove the target file to return to the
// original state. // original state.
Result<> rmResult = target.removeFile(); Result<> rmResult = target.removeFile();
QTC_CHECK_EXPECTED(rmResult); QTC_CHECK_RESULT(rmResult);
return ResultError( return ResultError(
Tr::tr("Failed to move %1 to %2. Removing the source file failed: %3") Tr::tr("Failed to move %1 to %2. Removing the source file failed: %3")
.arg(toUserOutput()) .arg(toUserOutput())

View File

@@ -144,10 +144,10 @@ bool FSEngineImpl::open(QIODeviceBase::OpenMode openMode, std::optional<QFile::P
if (read || append) { if (read || append) {
const Result<QByteArray> readResult = m_filePath.fileContents(); const Result<QByteArray> readResult = m_filePath.fileContents();
QTC_ASSERT_EXPECTED(readResult, return false); QTC_ASSERT_RESULT(readResult, return false);
const Result<qint64> writeResult = m_tempStorage->write(*readResult); const Result<qint64> writeResult = m_tempStorage->write(*readResult);
QTC_ASSERT_EXPECTED(writeResult, return false); QTC_ASSERT_RESULT(writeResult, return false);
if (!append) if (!append)
m_tempStorage->seek(0); m_tempStorage->seek(0);

View File

@@ -6,6 +6,7 @@
#include "utils_global.h" #include "utils_global.h"
#include "expected.h" #include "expected.h"
#include "qtcassert.h"
#include <QString> #include <QString>
@@ -39,3 +40,31 @@ private:
.arg(#cond).arg(__FILE__).arg(__LINE__))) .arg(#cond).arg(__FILE__).arg(__LINE__)))
} // namespace Utils } // namespace Utils
//! If \a result has an error the error will be printed and the \a action will be executed.
#define QTC_ASSERT_RESULT(result, action) \
if (Q_LIKELY(result)) { \
} else { \
::Utils::writeAssertLocation(QString("%1:%2: %3") \
.arg(__FILE__) \
.arg(__LINE__) \
.arg(result.error()) \
.toUtf8() \
.data()); \
action; \
} \
do { \
} while (0)
#define QTC_CHECK_RESULT(result) \
if (Q_LIKELY(result)) { \
} else { \
::Utils::writeAssertLocation( \
QString("%1:%2: %3").arg(__FILE__).arg(__LINE__).arg(result.error()).toUtf8().data()); \
} \
do { \
} while (0)
#define QVERIFY_RESULT(result) \
QVERIFY2(result, result ? #result : static_cast<const char*>(result.error().toUtf8()))

View File

@@ -893,7 +893,7 @@ static bool copyFileIfNewer(const FilePath &sourceFilePath, const FilePath &dest
if (!destinationFilePath.parentDir().ensureWritableDir()) if (!destinationFilePath.parentDir().ensureWritableDir())
return false; return false;
Result<> result = sourceFilePath.copyFile(destinationFilePath); Result<> result = sourceFilePath.copyFile(destinationFilePath);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
return true; return true;
} }

View File

@@ -33,11 +33,10 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <utils/guard.h> #include <utils/guard.h>
#include <utils/infolabel.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <utils/infolabel.h>
#include <utils/expected.h>
#include <QComboBox> #include <QComboBox>
#include <QLabel> #include <QLabel>

View File

@@ -17,9 +17,8 @@
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectmanager.h> #include <projectexplorer/projectmanager.h>
#include <utils/qtcassert.h>
#include <utils/expected.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QLoggingCategory> #include <QLoggingCategory>

View File

@@ -52,7 +52,7 @@ public:
const FilePath path = FilePath::fromUserInput(QString::fromStdString(Name.str())); const FilePath path = FilePath::fromUserInput(QString::fromStdString(Name.str()));
const Result<QByteArray> contents = path.fileContents(FileSize, 0); const Result<QByteArray> contents = path.fileContents(FileSize, 0);
QTC_ASSERT_EXPECTED(contents, return std::error_code()); QTC_ASSERT_RESULT(contents, return std::error_code());
return MemoryBuffer::getMemBufferCopy(contents->data(), Name); return MemoryBuffer::getMemBufferCopy(contents->data(), Name);
} }

View File

@@ -332,7 +332,7 @@ void FileApiReader::makeBackupConfiguration(bool store)
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments) void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
{ {
const FilePath buildDir = m_parameters.buildDirectory; const FilePath buildDir = m_parameters.buildDirectory;
QTC_ASSERT_EXPECTED(buildDir.ensureWritableDir(), return); QTC_ASSERT_RESULT(buildDir.ensureWritableDir(), return);
QByteArray contents; QByteArray contents;
QStringList unknownOptions; QStringList unknownOptions;
@@ -344,7 +344,7 @@ void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &conf
.toUtf8()); .toUtf8());
const FilePath settingsFile = buildDir / "qtcsettings.cmake"; const FilePath settingsFile = buildDir / "qtcsettings.cmake";
QTC_ASSERT_EXPECTED(settingsFile.writeFileContents(contents), return); QTC_ASSERT_RESULT(settingsFile.writeFileContents(contents), return);
} }
void FileApiReader::setupCMakeFileApi() void FileApiReader::setupCMakeFileApi()

View File

@@ -448,7 +448,7 @@ bool JsonSettingsDocument::isModified() const
bool JsonSettingsDocument::setContents(const QByteArray &contents) bool JsonSettingsDocument::setContents(const QByteArray &contents)
{ {
auto result = storeFromJson(contents); auto result = storeFromJson(contents);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
m_ceSettings.fromMap(*result); m_ceSettings.fromMap(*result);
@@ -602,7 +602,7 @@ CompilerWidget::CompilerWidget(const std::shared_ptr<SourceSettings> &sourceSett
this, this,
&CompilerWidget::hoveredLineChanged); &CompilerWidget::hoveredLineChanged);
QTC_ASSERT_EXPECTED(m_asmEditor->configureGenericHighlighter("Intel x86 (NASM)"), QTC_ASSERT_RESULT(m_asmEditor->configureGenericHighlighter("Intel x86 (NASM)"),
m_asmEditor->configureGenericHighlighter( m_asmEditor->configureGenericHighlighter(
Utils::mimeTypeForName("text/x-asm"))); Utils::mimeTypeForName("text/x-asm")));
m_asmEditor->setReadOnly(true); m_asmEditor->setReadOnly(true);

View File

@@ -149,7 +149,7 @@ public:
if (!res) { if (!res) {
if (!path.exists()) if (!path.exists())
return false; // Too much noise if we complain about non-existing files here. return false; // Too much noise if we complain about non-existing files here.
QTC_ASSERT_EXPECTED(res, return false); QTC_ASSERT_RESULT(res, return false);
} }
connect(res->get(), &FilePathWatcher::pathChanged, this, [this, path] { connect(res->get(), &FilePathWatcher::pathChanged, this, [this, path] {

View File

@@ -598,7 +598,7 @@ bool ExternalToolRunner::resolve()
} }
const Result<QString> args = expander->expandProcessArgs(m_tool->arguments()); const Result<QString> args = expander->expandProcessArgs(m_tool->arguments());
QTC_ASSERT_EXPECTED(args, return false); QTC_ASSERT_RESULT(args, return false);
m_resolvedArguments = *args; m_resolvedArguments = *args;
m_resolvedInput = expander->expand(m_tool->input()); m_resolvedInput = expander->expand(m_tool->input());

View File

@@ -361,7 +361,7 @@ bool SessionManager::deleteSession(const QString &session)
if (!sessionFile.exists()) if (!sessionFile.exists())
return false; return false;
Result<> result = sessionFile.removeFile(); Result<> result = sessionFile.removeFile();
QTC_CHECK_EXPECTED(result); QTC_CHECK_RESULT(result);
return bool(result); return bool(result);
} }

View File

@@ -6,7 +6,6 @@
#include "cppeditor_global.h" #include "cppeditor_global.h"
#include "projectinfo.h" #include "projectinfo.h"
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <QPromise> #include <QPromise>

View File

@@ -150,7 +150,7 @@ bool CppToolsJsExtension::hasQObjectParent(const QString &klassName) const
std::optional<QByteArray> source = workingCopy.source(item->filePath()); std::optional<QByteArray> source = workingCopy.source(item->filePath());
if (!source) { if (!source) {
const Utils::Result<QByteArray> contents = item->filePath().fileContents(); const Utils::Result<QByteArray> contents = item->filePath().fileContents();
QTC_ASSERT_EXPECTED(contents, return false); QTC_ASSERT_RESULT(contents, return false);
source = *contents; source = *contents;
} }
const auto doc = snapshot.preprocessedDocument(*source, item->filePath()); const auto doc = snapshot.preprocessedDocument(*source, item->filePath());

View File

@@ -3,9 +3,9 @@
#pragma once #pragma once
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/guard.h> #include <utils/guard.h>
#include <utils/result.h>
#include <QFuture> #include <QFuture>
#include <QMutex> #include <QMutex>

View File

@@ -44,7 +44,6 @@
#include <utils/devicefileaccess.h> #include <utils/devicefileaccess.h>
#include <utils/deviceshell.h> #include <utils/deviceshell.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/expected.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/infolabel.h> #include <utils/infolabel.h>
@@ -928,7 +927,7 @@ Result<FilePath> DockerDevicePrivate::getCmdBridgePath() const
QStringList DockerDevicePrivate::createMountArgs() const QStringList DockerDevicePrivate::createMountArgs() const
{ {
const Utils::Result<Utils::FilePath> cmdBridgePath = getCmdBridgePath(); const Utils::Result<Utils::FilePath> cmdBridgePath = getCmdBridgePath();
QTC_CHECK_EXPECTED(cmdBridgePath); QTC_CHECK_RESULT(cmdBridgePath);
QStringList cmds; QStringList cmds;
QList<MountPair> mounts; QList<MountPair> mounts;

View File

@@ -62,7 +62,7 @@ public:
auto result = ::Lua::void_safe_call( auto result = ::Lua::void_safe_call(
callback, ::Lua::toTable(callback.lua_state(), msg.toJsonObject())); callback, ::Lua::toTable(callback.lua_state(), msg.toJsonObject()));
QTC_CHECK_EXPECTED(result); QTC_CHECK_RESULT(result);
}}; }};
} }
}; };
@@ -357,7 +357,7 @@ public:
return; return;
if (unexpected && m_startFailedCallback) { if (unexpected && m_startFailedCallback) {
QTC_CHECK_EXPECTED(::Lua::void_safe_call(*m_startFailedCallback)); QTC_CHECK_RESULT(::Lua::void_safe_call(*m_startFailedCallback));
} }
} }
@@ -589,7 +589,7 @@ public:
return {}; return {};
}; };
QTC_CHECK_EXPECTED(callback(dest)); QTC_CHECK_RESULT(callback(dest));
return callback; return callback;
} }
return {}; return {};

View File

@@ -71,7 +71,7 @@ void setupActionModule()
else if (key == "onTrigger") else if (key == "onTrigger")
b.addOnTriggered([f = v.as<sol::main_function>()]() { b.addOnTriggered([f = v.as<sol::main_function>()]() {
auto res = void_safe_call(f); auto res = void_safe_call(f);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
else if (key == "text") else if (key == "text")
b.setText(v.as<QString>()); b.setText(v.as<QString>());

View File

@@ -41,7 +41,7 @@ static void processChildren(T *item, const sol::table &children)
} else if (child.is<sol::function>()) { } else if (child.is<sol::function>()) {
const sol::function f = child.get<sol::function>(); const sol::function f = child.get<sol::function>();
auto res = void_safe_call(f, item); auto res = void_safe_call(f, item);
QTC_ASSERT_EXPECTED(res, continue); QTC_ASSERT_RESULT(res, continue);
} else if (child.is<Span>()) { } else if (child.is<Span>()) {
const Span &span = child.get<Span>(); const Span &span = child.get<Span>();
item->addItem(span); item->addItem(span);
@@ -315,7 +315,7 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
guard, guard,
[f = *onTextChanged](const QString &text) { [f = *onTextChanged](const QString &text) {
auto res = void_safe_call(f, text); auto res = void_safe_call(f, text);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
} }
} }
@@ -327,7 +327,7 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
guard, guard,
[f = *onClicked]() { [f = *onClicked]() {
auto res = void_safe_call(f); auto res = void_safe_call(f);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
} }
} }

View File

@@ -19,7 +19,7 @@ void setupHookModule()
guard, guard,
[func](Core::IDocument *document) { [func](Core::IDocument *document) {
Result<> res = void_safe_call(func, document); Result<> res = void_safe_call(func, document);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -30,7 +30,7 @@ void setupHookModule()
guard, guard,
[func](Core::IDocument *document) { [func](Core::IDocument *document) {
Result<> res = void_safe_call(func, document); Result<> res = void_safe_call(func, document);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
} }

View File

@@ -43,13 +43,13 @@ void setupLocalSocketModule()
QObject::connect(socket, &QLocalSocket::connected, socket, [socket, cb] { QObject::connect(socket, &QLocalSocket::connected, socket, [socket, cb] {
qDebug() << "CONNECTED"; qDebug() << "CONNECTED";
auto res = void_safe_call(cb, true); auto res = void_safe_call(cb, true);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
QObject::disconnect(socket, &QLocalSocket::errorOccurred, socket, nullptr); QObject::disconnect(socket, &QLocalSocket::errorOccurred, socket, nullptr);
}, Qt::SingleShotConnection); }, Qt::SingleShotConnection);
QObject::connect(socket, &QLocalSocket::errorOccurred, socket, [socket, cb] { QObject::connect(socket, &QLocalSocket::errorOccurred, socket, [socket, cb] {
qDebug() << "CONNECT ERROR"; qDebug() << "CONNECT ERROR";
auto res = void_safe_call(cb, false, socket->errorString()); auto res = void_safe_call(cb, false, socket->errorString());
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
QObject::disconnect(socket, &QLocalSocket::connected, socket, nullptr); QObject::disconnect(socket, &QLocalSocket::connected, socket, nullptr);
}, Qt::SingleShotConnection); }, Qt::SingleShotConnection);
@@ -79,7 +79,7 @@ void setupLocalSocketModule()
QObject::connect(socket, &QLocalSocket::readyRead, socket, [socket, cb] { QObject::connect(socket, &QLocalSocket::readyRead, socket, [socket, cb] {
auto res = void_safe_call(cb, socket->readAll().toStdString()); auto res = void_safe_call(cb, socket->readAll().toStdString());
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}, Qt::SingleShotConnection); }, Qt::SingleShotConnection);
}; };

View File

@@ -151,7 +151,7 @@ void setupProjectModule()
guard, guard,
[func](Project *project) { [func](Project *project) {
Result<> res = void_safe_call(func, project); Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -163,7 +163,7 @@ void setupProjectModule()
guard, guard,
[func](Project *project) { [func](Project *project) {
Result<> res = void_safe_call(func, project); Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -175,7 +175,7 @@ void setupProjectModule()
guard, guard,
[func](Project *project) { [func](Project *project) {
Result<> res = void_safe_call(func, project); Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -187,7 +187,7 @@ void setupProjectModule()
guard, guard,
[func](Project *project) { [func](Project *project) {
Result<> res = void_safe_call(func, project); Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -199,7 +199,7 @@ void setupProjectModule()
guard, guard,
[func]() { [func]() {
Result<> res = void_safe_call(func); Result<> res = void_safe_call(func);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -212,7 +212,7 @@ void setupProjectModule()
[func](ProjectExplorer::Project *pro) { [func](ProjectExplorer::Project *pro) {
const bool isBuilding = BuildManager::isBuilding(pro); const bool isBuilding = BuildManager::isBuilding(pro);
Result<> res = void_safe_call(func, pro, isBuilding); Result<> res = void_safe_call(func, pro, isBuilding);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
} }
); );
}); });

View File

@@ -70,7 +70,7 @@ std::unique_ptr<LuaAspectContainer> aspectContainerCreate(const sol::main_table
container->setLayouter( container->setLayouter(
[func = v.as<sol::main_function>()]() -> Layouting::Layout { [func = v.as<sol::main_function>()]() -> Layouting::Layout {
auto res = safe_call<Layouting::Layout>(func); auto res = safe_call<Layouting::Layout>(func);
QTC_ASSERT_EXPECTED(res, return {}); QTC_ASSERT_RESULT(res, return {});
return *res; return *res;
}); });
} else if (key == "onApplied") { } else if (key == "onApplied") {
@@ -151,7 +151,7 @@ void typedAspectCreate(StringAspect *aspect, const std::string &key, const sol::
[func = value.as<sol::main_function>()](const QString &oldValue, const QString &newValue) [func = value.as<sol::main_function>()](const QString &oldValue, const QString &newValue)
-> std::optional<QString> { -> std::optional<QString> {
auto res = safe_call<std::optional<QString>>(func, oldValue, newValue); auto res = safe_call<std::optional<QString>>(func, oldValue, newValue);
QTC_ASSERT_EXPECTED(res, return std::nullopt); QTC_ASSERT_RESULT(res, return std::nullopt);
return *res; return *res;
}); });
else if (key == "showToolTipOnLabel") else if (key == "showToolTipOnLabel")
@@ -159,7 +159,7 @@ void typedAspectCreate(StringAspect *aspect, const std::string &key, const sol::
else if (key == "displayFilter") else if (key == "displayFilter")
aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &value) { aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &value) {
auto res = safe_call<QString>(func, value); auto res = safe_call<QString>(func, value);
QTC_ASSERT_EXPECTED(res, return value); QTC_ASSERT_RESULT(res, return value);
return *res; return *res;
}); });
else if (key == "placeHolderText") else if (key == "placeHolderText")
@@ -205,7 +205,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol
else if (key == "openTerminalHandler") else if (key == "openTerminalHandler")
aspect->setOpenTerminalHandler([func = value.as<sol::main_function>()]() { aspect->setOpenTerminalHandler([func = value.as<sol::main_function>()]() {
auto res = void_safe_call(func); auto res = void_safe_call(func);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
else if (key == "expectedKind") else if (key == "expectedKind")
aspect->setExpectedKind((PathChooser::Kind) value.as<int>()); aspect->setExpectedKind((PathChooser::Kind) value.as<int>());
@@ -218,7 +218,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol
[func = value.as<sol::main_function>()](const QString &oldValue, const QString &newValue) [func = value.as<sol::main_function>()](const QString &oldValue, const QString &newValue)
-> std::optional<QString> { -> std::optional<QString> {
auto res = safe_call<std::optional<QString>>(func, oldValue, newValue); auto res = safe_call<std::optional<QString>>(func, oldValue, newValue);
QTC_ASSERT_EXPECTED(res, return std::nullopt); QTC_ASSERT_RESULT(res, return std::nullopt);
return *res; return *res;
}); });
else if (key == "showToolTipOnLabel") else if (key == "showToolTipOnLabel")
@@ -234,7 +234,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol
else if (key == "displayFilter") else if (key == "displayFilter")
aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &path) { aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &path) {
auto res = safe_call<QString>(func, path); auto res = safe_call<QString>(func, path);
QTC_ASSERT_EXPECTED(res, return path); QTC_ASSERT_RESULT(res, return path);
return *res; return *res;
}); });
else if (key == "placeHolderText") else if (key == "placeHolderText")
@@ -376,10 +376,10 @@ void setupSettingsModule()
aspect->requestValue([callback](const Result<QString> &secret) { aspect->requestValue([callback](const Result<QString> &secret) {
if (secret) { if (secret) {
auto res = void_safe_call(callback, true, secret.value()); auto res = void_safe_call(callback, true, secret.value());
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
} else { } else {
auto res = void_safe_call(callback, false, secret.error()); auto res = void_safe_call(callback, false, secret.error());
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
} }
}); });
}, },
@@ -598,20 +598,20 @@ void setupSettingsModule()
[func = value.as<sol::main_function>()]() [func = value.as<sol::main_function>()]()
-> std::shared_ptr<BaseAspect> { -> std::shared_ptr<BaseAspect> {
auto res = safe_call<std::shared_ptr<BaseAspect>>(func); auto res = safe_call<std::shared_ptr<BaseAspect>>(func);
QTC_ASSERT_EXPECTED(res, return nullptr); QTC_ASSERT_RESULT(res, return nullptr);
return *res; return *res;
}); });
} else if (key == "onItemAdded") { } else if (key == "onItemAdded") {
aspect->setItemAddedCallback([func = value.as<sol::main_function>()]( aspect->setItemAddedCallback([func = value.as<sol::main_function>()](
std::shared_ptr<BaseAspect> item) { std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(func, item); auto res = void_safe_call(func, item);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
} else if (key == "onItemRemoved") { } else if (key == "onItemRemoved") {
aspect->setItemRemovedCallback([func = value.as<sol::main_function>()]( aspect->setItemRemovedCallback([func = value.as<sol::main_function>()](
std::shared_ptr<BaseAspect> item) { std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(func, item); auto res = void_safe_call(func, item);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
} else { } else {
baseAspectCreate(aspect, key, value); baseAspectCreate(aspect, key, value);
@@ -624,14 +624,14 @@ void setupSettingsModule()
[](AspectList *a, const sol::function &clbk) { [](AspectList *a, const sol::function &clbk) {
a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item) { a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(clbk, item); auto res = void_safe_call(clbk, item);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}, },
"enumerate", "enumerate",
[](AspectList *a, const sol::function &clbk) { [](AspectList *a, const sol::function &clbk) {
a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item, int idx) { a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item, int idx) {
auto res = void_safe_call(clbk, item, idx); auto res = void_safe_call(clbk, item, idx);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}, },
sol::base_classes, sol::base_classes,

View File

@@ -25,7 +25,7 @@ struct FPTR<Ret (Obj::*)(Args...)>
{ {
return [func](Args... args) { return [func](Args... args) {
Result<> res = void_safe_call(func, args...); Result<> res = void_safe_call(func, args...);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}; };
} }
}; };

View File

@@ -106,7 +106,7 @@ void setRefactorMarker(
marker.icon = icon.icon(); marker.icon = icon.icon();
marker.callback = [callback](TextEditorWidget *) { marker.callback = [callback](TextEditorWidget *) {
Result<> res = Lua::void_safe_call(callback); Result<> res = Lua::void_safe_call(callback);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}; };
marker.type = id; marker.type = id;
@@ -408,7 +408,7 @@ void setupTextEditorModule()
[guard](EmbeddedWidgetInterface *widget, sol::main_function func) { [guard](EmbeddedWidgetInterface *widget, sol::main_function func) {
QObject::connect(widget, &EmbeddedWidgetInterface::shouldClose, guard, [func]() { QObject::connect(widget, &EmbeddedWidgetInterface::shouldClose, guard, [func]() {
Result<> res = void_safe_call(func); Result<> res = void_safe_call(func);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -603,7 +603,7 @@ void setupTextEditorModule()
guard, guard,
[func](BaseTextEditor *editor) { [func](BaseTextEditor *editor) {
Result<> res = void_safe_call(func, editor); Result<> res = void_safe_call(func, editor);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -614,7 +614,7 @@ void setupTextEditorModule()
guard, guard,
[func](TextEditorPtr editor) { [func](TextEditorPtr editor) {
Result<> res = void_safe_call(func, editor); Result<> res = void_safe_call(func, editor);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -626,7 +626,7 @@ void setupTextEditorModule()
[func](TextDocument *document, int position, int charsRemoved, int charsAdded) { [func](TextDocument *document, int position, int charsRemoved, int charsAdded) {
Result<> res Result<> res
= void_safe_call(func, document, position, charsRemoved, charsAdded); = void_safe_call(func, document, position, charsRemoved, charsAdded);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
@@ -637,7 +637,7 @@ void setupTextEditorModule()
guard, guard,
[func](BaseTextEditor *editor, const MultiTextCursor &cursor) { [func](BaseTextEditor *editor, const MultiTextCursor &cursor) {
Result<> res = void_safe_call(func, editor, cursor); Result<> res = void_safe_call(func, editor, cursor);
QTC_CHECK_EXPECTED(res); QTC_CHECK_RESULT(res);
}); });
}); });
} }

View File

@@ -141,7 +141,7 @@ void prepareLuaState(
} }
}; };
const Result<FilePath> tmpDir = HostOsInfo::root().tmpDir(); const Result<FilePath> tmpDir = HostOsInfo::root().tmpDir();
QTC_ASSERT_EXPECTED(tmpDir, return); QTC_ASSERT_RESULT(tmpDir, return);
QString id = name; QString id = name;
static const QRegularExpression regexp("[^a-zA-Z0-9_]"); static const QRegularExpression regexp("[^a-zA-Z0-9_]");
id = id.replace(regexp, "_").toLower(); id = id.replace(regexp, "_").toLower();

View File

@@ -8,7 +8,6 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginspec.h> #include <extensionsystem/pluginspec.h>
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/lua.h> #include <utils/lua.h>

View File

@@ -327,7 +327,7 @@ public:
if (path.isFile()) { if (path.isFile()) {
if (path.suffix() == "lua") { if (path.suffix() == "lua") {
Utils::Result<PluginSpec *> spec = loadPlugin(path); Utils::Result<PluginSpec *> spec = loadPlugin(path);
QTC_CHECK_EXPECTED(spec); QTC_CHECK_RESULT(spec);
if (spec) if (spec)
return {*spec}; return {*spec};
} }
@@ -340,7 +340,7 @@ public:
const auto specFilePath = dir / (dir.fileName() + ".lua"); const auto specFilePath = dir / (dir.fileName() + ".lua");
if (specFilePath.exists()) { if (specFilePath.exists()) {
Utils::Result<PluginSpec *> spec = loadPlugin(specFilePath); Utils::Result<PluginSpec *> spec = loadPlugin(specFilePath);
QTC_CHECK_EXPECTED(spec); QTC_CHECK_RESULT(spec);
if (spec) if (spec)
plugins.push_back(*spec); plugins.push_back(*spec);
} }

View File

@@ -12,7 +12,6 @@
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/appinfo.h> #include <utils/appinfo.h>
#include <utils/expected.h>
#include <QJsonDocument> #include <QJsonDocument>
#include <QLoggingCategory> #include <QLoggingCategory>

View File

@@ -8,7 +8,6 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginspec.h> #include <extensionsystem/pluginspec.h>
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <QString> #include <QString>

View File

@@ -329,7 +329,7 @@ FileTransferInterface *IDevice::createFileTransferInterface(
Environment IDevice::systemEnvironment() const Environment IDevice::systemEnvironment() const
{ {
Result<Environment> env = systemEnvironmentWithError(); Result<Environment> env = systemEnvironmentWithError();
QTC_ASSERT_EXPECTED(env, return {}); QTC_ASSERT_RESULT(env, return {});
return *env; return *env;
} }

View File

@@ -9,7 +9,6 @@
#include <solutions/tasking/tasktree.h> #include <solutions/tasking/tasktree.h>
#include <utils/aspects.h> #include <utils/aspects.h>
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/id.h> #include <utils/id.h>

View File

@@ -14,8 +14,8 @@
#include <solutions/tasking/tasktreerunner.h> #include <solutions/tasking/tasktreerunner.h>
#include <utils/async.h> #include <utils/async.h>
#include <utils/expected.h>
#include <utils/guard.h> #include <utils/guard.h>
#include <utils/result.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <QDateTime> #include <QDateTime>
@@ -89,7 +89,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const FilePath &source,
d->compileTime = lastModified; d->compileTime = lastModified;
const Result<QByteArray> contents = target.fileContents(); const Result<QByteArray> contents = target.fileContents();
QTC_ASSERT_EXPECTED(contents, return); QTC_ASSERT_RESULT(contents, return);
setContent(target, *contents); setContent(target, *contents);
} }
@@ -212,7 +212,7 @@ void ExtraCompiler::onTargetsBuilt(Project *project)
return; return;
const Result<QByteArray> contents = target.fileContents(); const Result<QByteArray> contents = target.fileContents();
QTC_ASSERT_EXPECTED(contents, return); QTC_ASSERT_RESULT(contents, return);
d->compileTime = generateTime; d->compileTime = generateTime;
setContent(target, *contents); setContent(target, *contents);

View File

@@ -214,7 +214,7 @@ static HeaderPaths gccHeaderPaths(const FilePath &gcc,
const Environment &env) const Environment &env)
{ {
Result<QString> result = runGcc(gcc, arguments, env); Result<QString> result = runGcc(gcc, arguments, env);
QTC_ASSERT_EXPECTED(result, return {}); QTC_ASSERT_RESULT(result, return {});
HeaderPaths builtInHeaderPaths; HeaderPaths builtInHeaderPaths;
QByteArray line; QByteArray line;
@@ -311,7 +311,7 @@ static GccToolchain::DetectedAbisResult guessGccAbi(const FilePath &path,
arguments << "-dumpmachine"; arguments << "-dumpmachine";
Result<QString> result = runGcc(path, arguments, env); Result<QString> result = runGcc(path, arguments, env);
QTC_ASSERT_EXPECTED(result, return {}); QTC_ASSERT_RESULT(result, return {});
QString machine = result->section('\n', 0, 0, QString::SectionSkipEmpty); QString machine = result->section('\n', 0, 0, QString::SectionSkipEmpty);
if (machine.isEmpty()) { if (machine.isEmpty()) {
@@ -330,7 +330,7 @@ static QString gccVersion(const FilePath &path,
QStringList arguments = extraArgs; QStringList arguments = extraArgs;
arguments << "-dumpversion"; arguments << "-dumpversion";
Result<QString> result = runGcc(path, arguments, env); Result<QString> result = runGcc(path, arguments, env);
QTC_ASSERT_EXPECTED(result, return {}); QTC_ASSERT_RESULT(result, return {});
return *result; return *result;
} }
@@ -341,7 +341,7 @@ static FilePath gccInstallDir(const FilePath &compiler,
QStringList arguments = extraArgs; QStringList arguments = extraArgs;
arguments << "-print-search-dirs"; arguments << "-print-search-dirs";
Result<QString> result = runGcc(compiler, arguments, env); Result<QString> result = runGcc(compiler, arguments, env);
QTC_ASSERT_EXPECTED(result, return {}); QTC_ASSERT_RESULT(result, return {});
// Expected output looks like this: // Expected output looks like this:
// install: /usr/lib/gcc/x86_64-linux-gnu/7/ // install: /usr/lib/gcc/x86_64-linux-gnu/7/
@@ -622,7 +622,7 @@ Toolchain::MacroInspectionRunner GccToolchain::createMacroInspectionRunner() con
const Result<Macros> macroResult const Result<Macros> macroResult
= gccPredefinedMacros(findLocalCompiler(compilerCommand, env), arguments, env); = gccPredefinedMacros(findLocalCompiler(compilerCommand, env), arguments, env);
QTC_CHECK_EXPECTED(macroResult); QTC_CHECK_RESULT(macroResult);
const auto macros = macroResult.value_or(Macros{}); const auto macros = macroResult.value_or(Macros{});
@@ -2006,7 +2006,7 @@ void GccToolchainConfigWidget::handleCompilerCommandChange(Id language)
const FilePath localCompilerPath = findLocalCompiler(path, env); const FilePath localCompilerPath = findLocalCompiler(path, env);
Result<ProjectExplorer::Macros> macros Result<ProjectExplorer::Macros> macros
= gccPredefinedMacros(localCompilerPath, args, env); = gccPredefinedMacros(localCompilerPath, args, env);
QTC_CHECK_EXPECTED(macros); QTC_CHECK_RESULT(macros);
m_macros = macros.value_or(ProjectExplorer::Macros{}); m_macros = macros.value_or(ProjectExplorer::Macros{});
abiList = guessGccAbi(localCompilerPath, env, m_macros, abiList = guessGccAbi(localCompilerPath, env, m_macros,
splitString(m_platformCodeGenFlagsLineEdit->text())).supportedAbis; splitString(m_platformCodeGenFlagsLineEdit->text())).supportedAbis;

View File

@@ -327,7 +327,7 @@ QString ArgumentsAspect::arguments() const
m_currentlyExpanding = true; m_currentlyExpanding = true;
const Result<QString> expanded = macroExpander()->expandProcessArgs(m_arguments); const Result<QString> expanded = macroExpander()->expandProcessArgs(m_arguments);
QTC_ASSERT_EXPECTED(expanded, return m_arguments); QTC_ASSERT_RESULT(expanded, return m_arguments);
m_currentlyExpanding = false; m_currentlyExpanding = false;
return *expanded; return *expanded;

View File

@@ -195,7 +195,7 @@ void BundleHelper::importBundleToProject()
for (const QString &file : std::as_const(allFiles)) { for (const QString &file : std::as_const(allFiles)) {
Utils::FilePath filePath = bundlePath.pathAppended(file); Utils::FilePath filePath = bundlePath.pathAppended(file);
filePath.parentDir().ensureWritableDir(); filePath.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(filePath.writeFileContents(zipReader.fileData(file)),); QTC_ASSERT_RESULT(filePath.writeFileContents(zipReader.fileData(file)),);
} }
QString typePrefix = compUtils.userBundleType(bundleId); QString typePrefix = compUtils.userBundleType(bundleId);
@@ -323,7 +323,7 @@ QJsonObject BundleHelper::exportNode(const ModelNode &node, const QPixmap &iconP
auto qmlFilePath = tempPath.pathAppended(qml); auto qmlFilePath = tempPath.pathAppended(qml);
auto result = qmlFilePath.writeFileContents(qmlString.toUtf8()); auto result = qmlFilePath.writeFileContents(qmlString.toUtf8());
QTC_ASSERT_EXPECTED(result, return {}); QTC_ASSERT_RESULT(result, return {});
m_zipWriter->addFile(qmlFilePath.fileName(), qmlString.toUtf8()); m_zipWriter->addFile(qmlFilePath.fileName(), qmlString.toUtf8());
// add item's dependency assets to the bundle zip and target path (for icon generation) // add item's dependency assets to the bundle zip and target path (for icon generation)

View File

@@ -619,7 +619,7 @@ void ContentLibraryView::addLibAssets(const QStringList &paths)
// save asset // save asset
auto result = sourcePath.copyFile(targetPath); auto result = sourcePath.copyFile(targetPath);
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
targetPathsToAdd.append(targetPath); targetPathsToAdd.append(targetPath);
} }
@@ -675,7 +675,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node)
targetPath.parentDir().ensureWritableDir(); targetPath.parentDir().ensureWritableDir();
auto result = targetPath.writeFileContents(assetContent); auto result = targetPath.writeFileContents(assetContent);
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
if (assetAbsPath.fileName() != compFileName) // skip component file (only collect dependencies) if (assetAbsPath.fileName() != compFileName) // skip component file (only collect dependencies)
filesList.append(asset.relativePath); filesList.append(asset.relativePath);
@@ -695,7 +695,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node)
auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
m_widget->userModel()->addItem(m_bundleId, compBaseName, compFileName, iconSavePath.toUrl(), m_widget->userModel()->addItem(m_bundleId, compBaseName, compFileName, iconSavePath.toUrl(),
filesList); filesList);
@@ -760,7 +760,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
depAssetsRelativePaths.append(assetPath.relativePath); depAssetsRelativePaths.append(assetPath.relativePath);
auto result = bundlePath.pathAppended(qml).writeFileContents(qmlString.toUtf8()); auto result = bundlePath.pathAppended(qml).writeFileContents(qmlString.toUtf8());
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
// get icon path // get icon path
QString iconPathTemplate = QLatin1String("icons/%1.png"); QString iconPathTemplate = QLatin1String("icons/%1.png");
@@ -784,7 +784,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
// copy item's assets to target folder // copy item's assets to target folder
for (const AssetPath &assetPath : depAssetsList) { for (const AssetPath &assetPath : depAssetsList) {
@@ -793,7 +793,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
assetPathTarget.parentDir().ensureWritableDir(); assetPathTarget.parentDir().ensureWritableDir();
auto result = assetPathSource.copyFile(assetPathTarget); auto result = assetPathSource.copyFile(assetPathTarget);
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
} }
Utils::FilePath iconSavePath = bundlePath.pathAppended(iconPath); Utils::FilePath iconSavePath = bundlePath.pathAppended(iconPath);
@@ -925,7 +925,7 @@ void ContentLibraryView::importBundleToContentLib()
for (const QString &file : std::as_const(files)) { for (const QString &file : std::as_const(files)) {
Utils::FilePath filePath = bundlePath.pathAppended(file); Utils::FilePath filePath = bundlePath.pathAppended(file);
filePath.parentDir().ensureWritableDir(); filePath.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(filePath.writeFileContents(zipReader.fileData(file)),); QTC_ASSERT_RESULT(filePath.writeFileContents(zipReader.fileData(file)),);
} }
m_widget->userModel()->addItem(bundleId, name, qml, iconUrl, files); m_widget->userModel()->addItem(bundleId, name, qml, iconUrl, files);
@@ -939,7 +939,7 @@ void ContentLibraryView::importBundleToContentLib()
auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,); QTC_ASSERT_RESULT(result,);
} }
ModelNode ContentLibraryView::getBundleMaterialDefaultInstance(const TypeName &type) ModelNode ContentLibraryView::getBundleMaterialDefaultInstance(const TypeName &type)

View File

@@ -19,7 +19,6 @@
#include <utils3d.h> #include <utils3d.h>
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>

View File

@@ -8,9 +8,8 @@
#include <nodemetainfo.h> #include <nodemetainfo.h>
#include <sourcepathstorage/sourcepathcache.h> #include <sourcepathstorage/sourcepathcache.h>
#include <utils/expected.h>
#include <utils/ranges.h> #include <utils/ranges.h>
#include <utils/result.h>
#include <algorithm> #include <algorithm>
#include <array> #include <array>

View File

@@ -233,7 +233,7 @@ bool McuModuleProjectItem::saveQmlProjectFile() const
} }
} }
QTC_ASSERT_EXPECTED(path.writeFileContents(jsonToQmlproject()), return false); QTC_ASSERT_RESULT(path.writeFileContents(jsonToQmlproject()), return false);
return true; return true;
} }

View File

@@ -6,8 +6,9 @@
#include "qtsupport_global.h" #include "qtsupport_global.h"
#include <coreplugin/welcomepagehelper.h> #include <coreplugin/welcomepagehelper.h>
#include <utils/expected.h>
#include <utils/filepath.h> #include <utils/filepath.h>
#include <utils/result.h>
namespace QtSupport::Internal { namespace QtSupport::Internal {

View File

@@ -145,7 +145,7 @@ bool ScriptHelper::writeScriptFile(const Utils::FilePath &outScriptFile,
data.append(line).append('\n'); data.append(line).append('\n');
const Utils::Result<qint64> result = outScriptFile.writeFileContents(data); const Utils::Result<qint64> result = outScriptFile.writeFileContents(data);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
return true; return true;
} }

View File

@@ -186,7 +186,7 @@ void SquishTestTreeItemDelegate::setEditorData(QWidget *editor, const QModelInde
static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePath &destination) static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePath &destination)
{ {
Utils::Result<> result = destination.ensureWritableDir(); Utils::Result<> result = destination.ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
const bool scripted = suiteConf.objectMapStyle() == "script"; const bool scripted = suiteConf.objectMapStyle() == "script";
const QString extension = suiteConf.scriptExtension(); const QString extension = suiteConf.scriptExtension();
@@ -197,7 +197,7 @@ static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePat
const Utils::FilePath testFile = destination.pathAppended("test" + extension); const Utils::FilePath testFile = destination.pathAppended("test" + extension);
QTC_ASSERT(!testFile.exists(), return false); QTC_ASSERT(!testFile.exists(), return false);
result = test.copyFile(testFile); result = test.copyFile(testFile);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
if (scripted) if (scripted)
return suiteConf.ensureObjectMapExists(); return suiteConf.ensureObjectMapExists();

View File

@@ -112,7 +112,7 @@ static bool writeSuiteConfContent(const Utils::FilePath &file, const QMap<QStrin
outData.append(it.key().toUtf8()).append('=').append(it.value().toUtf8()).append('\n'); outData.append(it.key().toUtf8()).append('=').append(it.value().toUtf8()).append('\n');
} }
const Utils::Result<qint64> result = file.writeFileContents(outData); const Utils::Result<qint64> result = file.writeFileContents(outData);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
return true; return true;
} }
@@ -324,9 +324,9 @@ bool SuiteConf::ensureObjectMapExists() const
const Utils::FilePath objectMap = scripts.pathAppended("objectmap_template" + extension); const Utils::FilePath objectMap = scripts.pathAppended("objectmap_template" + extension);
Utils::Result<> result = destinationObjectMap.parentDir().ensureWritableDir(); Utils::Result<> result = destinationObjectMap.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
result = objectMap.copyFile(destinationObjectMap); result = objectMap.copyFile(destinationObjectMap);
QTC_ASSERT_EXPECTED(result, return false); QTC_ASSERT_RESULT(result, return false);
return true; return true;
} }

View File

@@ -173,7 +173,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput( const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.bash.rcFile.fileName())); m_tempDir.filePath(filesToCopy.bash.rcFile.fileName()));
const Result<> copyResult = rcPath.copyFile(tmpRc); const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return); QTC_ASSERT_RESULT(copyResult, return);
if (cmd.arguments() == "-l") if (cmd.arguments() == "-l")
env.set("VSCODE_SHELL_LOGIN", "1"); env.set("VSCODE_SHELL_LOGIN", "1");
@@ -183,7 +183,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
for (const FileToCopy &file : std::as_const(filesToCopy.zsh.files)) { for (const FileToCopy &file : std::as_const(filesToCopy.zsh.files)) {
const Result<> copyResult = file.source.copyFile( const Result<> copyResult = file.source.copyFile(
FilePath::fromUserInput(m_tempDir.filePath(file.destName))); FilePath::fromUserInput(m_tempDir.filePath(file.destName)));
QTC_ASSERT_EXPECTED(copyResult, return); QTC_ASSERT_RESULT(copyResult, return);
} }
const Utils::FilePath originalZdotDir = FilePath::fromUserInput( const Utils::FilePath originalZdotDir = FilePath::fromUserInput(
@@ -197,7 +197,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput( const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.pwsh.script.fileName())); m_tempDir.filePath(filesToCopy.pwsh.script.fileName()));
const Result<> copyResult = rcPath.copyFile(tmpRc); const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return); QTC_ASSERT_RESULT(copyResult, return);
cmd.addArgs(QString("-noexit -command try { . '%1' } catch {Write-Host \"Shell " cmd.addArgs(QString("-noexit -command try { . '%1' } catch {Write-Host \"Shell "
"integration error:\" $_}") "integration error:\" $_}")
@@ -208,7 +208,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput( const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.clink.script.fileName())); m_tempDir.filePath(filesToCopy.clink.script.fileName()));
const Result<> copyResult = rcPath.copyFile(tmpRc); const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return); QTC_ASSERT_RESULT(copyResult, return);
env.set("CLINK_HISTORY_LABEL", "QtCreator"); env.set("CLINK_HISTORY_LABEL", "QtCreator");
env.appendOrSet("CLINK_PATH", tmpRc.parentDir().nativePath()); env.appendOrSet("CLINK_PATH", tmpRc.parentDir().nativePath());
@@ -218,7 +218,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
QTC_ASSERT(subDir.createDir(), return); QTC_ASSERT(subDir.createDir(), return);
const Result<> copyResult = filesToCopy.fish.script.copyFile( const Result<> copyResult = filesToCopy.fish.script.copyFile(
subDir.resolvePath(filesToCopy.fish.script.fileName())); subDir.resolvePath(filesToCopy.fish.script.fileName()));
QTC_ASSERT_EXPECTED(copyResult, return); QTC_ASSERT_RESULT(copyResult, return);
env.appendOrSet("XDG_DATA_DIRS", xdgDir.toUserOutput()); env.appendOrSet("XDG_DATA_DIRS", xdgDir.toUserOutput());
} }

View File

@@ -126,7 +126,7 @@ ShellModelPrivate::ShellModelPrivate()
} else { } else {
FilePath shellsFile = FilePath::fromString("/etc/shells"); FilePath shellsFile = FilePath::fromString("/etc/shells");
const auto shellFileContent = shellsFile.fileContents(); const auto shellFileContent = shellsFile.fileContents();
QTC_ASSERT_EXPECTED(shellFileContent, return); QTC_ASSERT_RESULT(shellFileContent, return);
QString shellFileContentString = QString::fromUtf8(*shellFileContent); QString shellFileContentString = QString::fromUtf8(*shellFileContent);

View File

@@ -11,7 +11,6 @@
#include <utils/dropsupport.h> #include <utils/dropsupport.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/expected.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>

View File

@@ -12,7 +12,6 @@
#include <utils/async.h> #include <utils/async.h>
#include <utils/differ.h> #include <utils/differ.h>
#include <utils/expected.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>

View File

@@ -238,7 +238,7 @@ void tst_PluginSpec::locationAndPath()
{ {
Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec( Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec(
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
QVERIFY_EXPECTED(ps); QVERIFY_RESULT(ps);
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get()); CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get());
QCOMPARE(spec->location(), PLUGIN_DIR_PATH / "testplugin"); QCOMPARE(spec->location(), PLUGIN_DIR_PATH / "testplugin");
QCOMPARE(spec->filePath(), PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); QCOMPARE(spec->filePath(), PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
@@ -293,7 +293,7 @@ void tst_PluginSpec::loadLibrary()
Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec( Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec(
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
QVERIFY_EXPECTED(ps); QVERIFY_RESULT(ps);
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get()); CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get());
QCOMPARE(spec->errorString(), QString()); QCOMPARE(spec->errorString(), QString());
@@ -310,7 +310,7 @@ void tst_PluginSpec::initializePlugin()
{ {
Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec( Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec(
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
QVERIFY_EXPECTED(ps); QVERIFY_RESULT(ps);
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get()); CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get());
QVERIFY(spec->resolveDependencies({})); QVERIFY(spec->resolveDependencies({}));
QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString())); QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString()));
@@ -334,7 +334,7 @@ void tst_PluginSpec::initializeExtensions()
{ {
Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec( Utils::Result<std::unique_ptr<PluginSpec>> ps = readCppPluginSpec(
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
QVERIFY_EXPECTED(ps); QVERIFY_RESULT(ps);
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get()); CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps->get());
QVERIFY(spec->resolveDependencies({})); QVERIFY(spec->resolveDependencies({}));
QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString())); QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString()));

View File

@@ -190,22 +190,22 @@ The end.
)"; )";
auto writeResult = fileAccess.writeFileContents(testFile, testData); auto writeResult = fileAccess.writeFileContents(testFile, testData);
QTC_ASSERT_EXPECTED(writeResult, QVERIFY(writeResult)); QTC_ASSERT_RESULT(writeResult, QVERIFY(writeResult));
QCOMPARE(*writeResult, testData.size()); QCOMPARE(*writeResult, testData.size());
auto fileContents = fileAccess.fileContents(testFile, -1, 0); auto fileContents = fileAccess.fileContents(testFile, -1, 0);
QTC_ASSERT_EXPECTED(fileContents, QVERIFY(fileContents)); QTC_ASSERT_RESULT(fileContents, QVERIFY(fileContents));
QVERIFY(fileContents->size() > 100); QVERIFY(fileContents->size() > 100);
auto midContent = fileAccess.fileContents(testFile, 10, 10); auto midContent = fileAccess.fileContents(testFile, 10, 10);
QTC_ASSERT_EXPECTED(midContent, QVERIFY(midContent)); QTC_ASSERT_RESULT(midContent, QVERIFY(midContent));
QCOMPARE(*midContent, fileContents->mid(10, 10)); QCOMPARE(*midContent, fileContents->mid(10, 10));
auto endContent = fileAccess.fileContents(testFile, -1, 10); auto endContent = fileAccess.fileContents(testFile, -1, 10);
QTC_ASSERT_EXPECTED(endContent, QVERIFY(endContent)); QTC_ASSERT_RESULT(endContent, QVERIFY(endContent));
QCOMPARE(*endContent, fileContents->mid(10)); QCOMPARE(*endContent, fileContents->mid(10));
@@ -242,7 +242,7 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(), auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(), HostOsInfo::hostArchitecture(),
FilePath::fromUserInput(libExecPath)); FilePath::fromUserInput(libExecPath));
QTC_ASSERT_EXPECTED(bridgePath, QSKIP("No bridge found")); QTC_ASSERT_RESULT(bridgePath, QSKIP("No bridge found"));
CmdBridge::Client client(*bridgePath, Environment::systemEnvironment()); CmdBridge::Client client(*bridgePath, Environment::systemEnvironment());
client.start(); client.start();
@@ -261,10 +261,10 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(), auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(), HostOsInfo::hostArchitecture(),
FilePath::fromUserInput(libExecPath)); FilePath::fromUserInput(libExecPath));
QTC_ASSERT_EXPECTED(bridgePath, QSKIP("No bridge found")); QTC_ASSERT_RESULT(bridgePath, QSKIP("No bridge found"));
CmdBridge::Client client(*bridgePath, Environment::systemEnvironment()); CmdBridge::Client client(*bridgePath, Environment::systemEnvironment());
QTC_ASSERT_EXPECTED(client.start(), return); QTC_ASSERT_RESULT(client.start(), return);
try { try {
auto result = client.stat("/tmp")->result(); auto result = client.stat("/tmp")->result();
@@ -385,12 +385,12 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(), auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(), HostOsInfo::hostArchitecture(),
FilePath::fromUserInput(libExecPath)); FilePath::fromUserInput(libExecPath));
QTC_ASSERT_EXPECTED(bridgePath, QSKIP("No bridge found")); QTC_ASSERT_RESULT(bridgePath, QSKIP("No bridge found"));
CmdBridge::Client client(*bridgePath, Environment::systemEnvironment()); CmdBridge::Client client(*bridgePath, Environment::systemEnvironment());
auto result = client.start(); auto result = client.start();
QTC_ASSERT_EXPECTED(result, QFAIL("Failed to start bridge")); QTC_ASSERT_RESULT(result, QFAIL("Failed to start bridge"));
auto lsRes = client.execute({"ls", {"-lach"}}); auto lsRes = client.execute({"ls", {"-lach"}});