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)
{
const Result<QByteArray> content = filePath.fileContents();
QTC_ASSERT_EXPECTED(content, return false);
QTC_ASSERT_RESULT(content, return false);
QDomDocument doc;
QString error_msg;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,8 +3,6 @@
#pragma once
#include "qtcassert.h"
#include "../3rdparty/tl_expected/include/tl/expected.hpp"
namespace Utils {
@@ -12,30 +10,3 @@ namespace Utils {
using namespace tl;
} // 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;
const Result<DeviceFileAccess *> access = getFileAccess(*this);
QTC_ASSERT_EXPECTED(access, return &dummy);
QTC_ASSERT_RESULT(access, return &dummy);
return *access;
}
@@ -1900,7 +1900,7 @@ FilePaths FilePath::searchAllInPath(const FilePaths &additionalDirs,
Environment FilePath::deviceEnvironment() const
{
Result<Environment> env = deviceEnvironmentWithError();
QTC_ASSERT_EXPECTED(env, return {});
QTC_ASSERT_RESULT(env, return {});
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
// original state.
Result<> rmResult = target.removeFile();
QTC_CHECK_EXPECTED(rmResult);
QTC_CHECK_RESULT(rmResult);
return ResultError(
Tr::tr("Failed to move %1 to %2. Removing the source file failed: %3")
.arg(toUserOutput())

View File

@@ -144,10 +144,10 @@ bool FSEngineImpl::open(QIODeviceBase::OpenMode openMode, std::optional<QFile::P
if (read || append) {
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);
QTC_ASSERT_EXPECTED(writeResult, return false);
QTC_ASSERT_RESULT(writeResult, return false);
if (!append)
m_tempStorage->seek(0);

View File

@@ -6,6 +6,7 @@
#include "utils_global.h"
#include "expected.h"
#include "qtcassert.h"
#include <QString>
@@ -39,3 +40,31 @@ private:
.arg(#cond).arg(__FILE__).arg(__LINE__)))
} // 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())
return false;
Result<> result = sourceFilePath.copyFile(destinationFilePath);
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
return true;
}

View File

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

View File

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

View File

@@ -52,7 +52,7 @@ public:
const FilePath path = FilePath::fromUserInput(QString::fromStdString(Name.str()));
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);
}

View File

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

View File

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

View File

@@ -149,7 +149,7 @@ public:
if (!res) {
if (!path.exists())
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] {

View File

@@ -598,7 +598,7 @@ bool ExternalToolRunner::resolve()
}
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_resolvedInput = expander->expand(m_tool->input());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -62,7 +62,7 @@ public:
auto result = ::Lua::void_safe_call(
callback, ::Lua::toTable(callback.lua_state(), msg.toJsonObject()));
QTC_CHECK_EXPECTED(result);
QTC_CHECK_RESULT(result);
}};
}
};
@@ -357,7 +357,7 @@ public:
return;
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 {};
};
QTC_CHECK_EXPECTED(callback(dest));
QTC_CHECK_RESULT(callback(dest));
return callback;
}
return {};

View File

@@ -71,7 +71,7 @@ void setupActionModule()
else if (key == "onTrigger")
b.addOnTriggered([f = v.as<sol::main_function>()]() {
auto res = void_safe_call(f);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
else if (key == "text")
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>()) {
const sol::function f = child.get<sol::function>();
auto res = void_safe_call(f, item);
QTC_ASSERT_EXPECTED(res, continue);
QTC_ASSERT_RESULT(res, continue);
} else if (child.is<Span>()) {
const Span &span = child.get<Span>();
item->addItem(span);
@@ -315,7 +315,7 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
guard,
[f = *onTextChanged](const QString &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,
[f = *onClicked]() {
auto res = void_safe_call(f);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
}
}

View File

@@ -19,7 +19,7 @@ void setupHookModule()
guard,
[func](Core::IDocument *document) {
Result<> res = void_safe_call(func, document);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -30,7 +30,7 @@ void setupHookModule()
guard,
[func](Core::IDocument *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] {
qDebug() << "CONNECTED";
auto res = void_safe_call(cb, true);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
QObject::disconnect(socket, &QLocalSocket::errorOccurred, socket, nullptr);
}, Qt::SingleShotConnection);
QObject::connect(socket, &QLocalSocket::errorOccurred, socket, [socket, cb] {
qDebug() << "CONNECT ERROR";
auto res = void_safe_call(cb, false, socket->errorString());
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
QObject::disconnect(socket, &QLocalSocket::connected, socket, nullptr);
}, Qt::SingleShotConnection);
@@ -79,7 +79,7 @@ void setupLocalSocketModule()
QObject::connect(socket, &QLocalSocket::readyRead, socket, [socket, cb] {
auto res = void_safe_call(cb, socket->readAll().toStdString());
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
}, Qt::SingleShotConnection);
};

View File

@@ -151,7 +151,7 @@ void setupProjectModule()
guard,
[func](Project *project) {
Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -163,7 +163,7 @@ void setupProjectModule()
guard,
[func](Project *project) {
Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -175,7 +175,7 @@ void setupProjectModule()
guard,
[func](Project *project) {
Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -187,7 +187,7 @@ void setupProjectModule()
guard,
[func](Project *project) {
Result<> res = void_safe_call(func, project);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -199,7 +199,7 @@ void setupProjectModule()
guard,
[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) {
const bool isBuilding = BuildManager::isBuilding(pro);
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(
[func = v.as<sol::main_function>()]() -> Layouting::Layout {
auto res = safe_call<Layouting::Layout>(func);
QTC_ASSERT_EXPECTED(res, return {});
QTC_ASSERT_RESULT(res, return {});
return *res;
});
} 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)
-> std::optional<QString> {
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;
});
else if (key == "showToolTipOnLabel")
@@ -159,7 +159,7 @@ void typedAspectCreate(StringAspect *aspect, const std::string &key, const sol::
else if (key == "displayFilter")
aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &value) {
auto res = safe_call<QString>(func, value);
QTC_ASSERT_EXPECTED(res, return value);
QTC_ASSERT_RESULT(res, return value);
return *res;
});
else if (key == "placeHolderText")
@@ -205,7 +205,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol
else if (key == "openTerminalHandler")
aspect->setOpenTerminalHandler([func = value.as<sol::main_function>()]() {
auto res = void_safe_call(func);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
else if (key == "expectedKind")
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)
-> std::optional<QString> {
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;
});
else if (key == "showToolTipOnLabel")
@@ -234,7 +234,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol
else if (key == "displayFilter")
aspect->setDisplayFilter([func = value.as<sol::main_function>()](const QString &path) {
auto res = safe_call<QString>(func, path);
QTC_ASSERT_EXPECTED(res, return path);
QTC_ASSERT_RESULT(res, return path);
return *res;
});
else if (key == "placeHolderText")
@@ -376,10 +376,10 @@ void setupSettingsModule()
aspect->requestValue([callback](const Result<QString> &secret) {
if (secret) {
auto res = void_safe_call(callback, true, secret.value());
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
} else {
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>()]()
-> std::shared_ptr<BaseAspect> {
auto res = safe_call<std::shared_ptr<BaseAspect>>(func);
QTC_ASSERT_EXPECTED(res, return nullptr);
QTC_ASSERT_RESULT(res, return nullptr);
return *res;
});
} else if (key == "onItemAdded") {
aspect->setItemAddedCallback([func = value.as<sol::main_function>()](
std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(func, item);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
} else if (key == "onItemRemoved") {
aspect->setItemRemovedCallback([func = value.as<sol::main_function>()](
std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(func, item);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
} else {
baseAspectCreate(aspect, key, value);
@@ -624,14 +624,14 @@ void setupSettingsModule()
[](AspectList *a, const sol::function &clbk) {
a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item) {
auto res = void_safe_call(clbk, item);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
},
"enumerate",
[](AspectList *a, const sol::function &clbk) {
a->forEachItem<BaseAspect>([clbk](std::shared_ptr<BaseAspect> item, int idx) {
auto res = void_safe_call(clbk, item, idx);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
},
sol::base_classes,

View File

@@ -25,7 +25,7 @@ struct FPTR<Ret (Obj::*)(Args...)>
{
return [func](Args... 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.callback = [callback](TextEditorWidget *) {
Result<> res = Lua::void_safe_call(callback);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
};
marker.type = id;
@@ -408,7 +408,7 @@ void setupTextEditorModule()
[guard](EmbeddedWidgetInterface *widget, sol::main_function func) {
QObject::connect(widget, &EmbeddedWidgetInterface::shouldClose, guard, [func]() {
Result<> res = void_safe_call(func);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -603,7 +603,7 @@ void setupTextEditorModule()
guard,
[func](BaseTextEditor *editor) {
Result<> res = void_safe_call(func, editor);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -614,7 +614,7 @@ void setupTextEditorModule()
guard,
[func](TextEditorPtr 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) {
Result<> res
= void_safe_call(func, document, position, charsRemoved, charsAdded);
QTC_CHECK_EXPECTED(res);
QTC_CHECK_RESULT(res);
});
});
@@ -637,7 +637,7 @@ void setupTextEditorModule()
guard,
[func](BaseTextEditor *editor, const MultiTextCursor &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();
QTC_ASSERT_EXPECTED(tmpDir, return);
QTC_ASSERT_RESULT(tmpDir, return);
QString id = name;
static const QRegularExpression regexp("[^a-zA-Z0-9_]");
id = id.replace(regexp, "_").toLower();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -327,7 +327,7 @@ QString ArgumentsAspect::arguments() const
m_currentlyExpanding = true;
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;
return *expanded;

View File

@@ -195,7 +195,7 @@ void BundleHelper::importBundleToProject()
for (const QString &file : std::as_const(allFiles)) {
Utils::FilePath filePath = bundlePath.pathAppended(file);
filePath.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(filePath.writeFileContents(zipReader.fileData(file)),);
QTC_ASSERT_RESULT(filePath.writeFileContents(zipReader.fileData(file)),);
}
QString typePrefix = compUtils.userBundleType(bundleId);
@@ -323,7 +323,7 @@ QJsonObject BundleHelper::exportNode(const ModelNode &node, const QPixmap &iconP
auto qmlFilePath = tempPath.pathAppended(qml);
auto result = qmlFilePath.writeFileContents(qmlString.toUtf8());
QTC_ASSERT_EXPECTED(result, return {});
QTC_ASSERT_RESULT(result, return {});
m_zipWriter->addFile(qmlFilePath.fileName(), qmlString.toUtf8());
// 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
auto result = sourcePath.copyFile(targetPath);
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
targetPathsToAdd.append(targetPath);
}
@@ -675,7 +675,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node)
targetPath.parentDir().ensureWritableDir();
auto result = targetPath.writeFileContents(assetContent);
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
if (assetAbsPath.fileName() != compFileName) // skip component file (only collect dependencies)
filesList.append(asset.relativePath);
@@ -695,7 +695,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node)
auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
m_widget->userModel()->addItem(m_bundleId, compBaseName, compFileName, iconSavePath.toUrl(),
filesList);
@@ -760,7 +760,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
depAssetsRelativePaths.append(assetPath.relativePath);
auto result = bundlePath.pathAppended(qml).writeFileContents(qmlString.toUtf8());
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
// get icon path
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)
.writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
// copy item's assets to target folder
for (const AssetPath &assetPath : depAssetsList) {
@@ -793,7 +793,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
assetPathTarget.parentDir().ensureWritableDir();
auto result = assetPathSource.copyFile(assetPathTarget);
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
}
Utils::FilePath iconSavePath = bundlePath.pathAppended(iconPath);
@@ -925,7 +925,7 @@ void ContentLibraryView::importBundleToContentLib()
for (const QString &file : std::as_const(files)) {
Utils::FilePath filePath = bundlePath.pathAppended(file);
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);
@@ -939,7 +939,7 @@ void ContentLibraryView::importBundleToContentLib()
auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson());
QTC_ASSERT_EXPECTED(result,);
QTC_ASSERT_RESULT(result,);
}
ModelNode ContentLibraryView::getBundleMaterialDefaultInstance(const TypeName &type)

View File

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

View File

@@ -8,9 +8,8 @@
#include <nodemetainfo.h>
#include <sourcepathstorage/sourcepathcache.h>
#include <utils/expected.h>
#include <utils/ranges.h>
#include <utils/result.h>
#include <algorithm>
#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;
}

View File

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

View File

@@ -145,7 +145,7 @@ bool ScriptHelper::writeScriptFile(const Utils::FilePath &outScriptFile,
data.append(line).append('\n');
const Utils::Result<qint64> result = outScriptFile.writeFileContents(data);
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
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)
{
Utils::Result<> result = destination.ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
const bool scripted = suiteConf.objectMapStyle() == "script";
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);
QTC_ASSERT(!testFile.exists(), return false);
result = test.copyFile(testFile);
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
if (scripted)
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');
}
const Utils::Result<qint64> result = file.writeFileContents(outData);
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
return true;
}
@@ -324,9 +324,9 @@ bool SuiteConf::ensureObjectMapExists() const
const Utils::FilePath objectMap = scripts.pathAppended("objectmap_template" + extension);
Utils::Result<> result = destinationObjectMap.parentDir().ensureWritableDir();
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
result = objectMap.copyFile(destinationObjectMap);
QTC_ASSERT_EXPECTED(result, return false);
QTC_ASSERT_RESULT(result, return false);
return true;
}

View File

@@ -173,7 +173,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.bash.rcFile.fileName()));
const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return);
QTC_ASSERT_RESULT(copyResult, return);
if (cmd.arguments() == "-l")
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)) {
const Result<> copyResult = file.source.copyFile(
FilePath::fromUserInput(m_tempDir.filePath(file.destName)));
QTC_ASSERT_EXPECTED(copyResult, return);
QTC_ASSERT_RESULT(copyResult, return);
}
const Utils::FilePath originalZdotDir = FilePath::fromUserInput(
@@ -197,7 +197,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.pwsh.script.fileName()));
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 "
"integration error:\" $_}")
@@ -208,7 +208,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
const FilePath tmpRc = FilePath::fromUserInput(
m_tempDir.filePath(filesToCopy.clink.script.fileName()));
const Result<> copyResult = rcPath.copyFile(tmpRc);
QTC_ASSERT_EXPECTED(copyResult, return);
QTC_ASSERT_RESULT(copyResult, return);
env.set("CLINK_HISTORY_LABEL", "QtCreator");
env.appendOrSet("CLINK_PATH", tmpRc.parentDir().nativePath());
@@ -218,7 +218,7 @@ void ShellIntegration::prepareProcess(Utils::Process &process)
QTC_ASSERT(subDir.createDir(), return);
const Result<> copyResult = filesToCopy.fish.script.copyFile(
subDir.resolvePath(filesToCopy.fish.script.fileName()));
QTC_ASSERT_EXPECTED(copyResult, return);
QTC_ASSERT_RESULT(copyResult, return);
env.appendOrSet("XDG_DATA_DIRS", xdgDir.toUserOutput());
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -190,22 +190,22 @@ The end.
)";
auto writeResult = fileAccess.writeFileContents(testFile, testData);
QTC_ASSERT_EXPECTED(writeResult, QVERIFY(writeResult));
QTC_ASSERT_RESULT(writeResult, QVERIFY(writeResult));
QCOMPARE(*writeResult, testData.size());
auto fileContents = fileAccess.fileContents(testFile, -1, 0);
QTC_ASSERT_EXPECTED(fileContents, QVERIFY(fileContents));
QTC_ASSERT_RESULT(fileContents, QVERIFY(fileContents));
QVERIFY(fileContents->size() > 100);
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));
auto endContent = fileAccess.fileContents(testFile, -1, 10);
QTC_ASSERT_EXPECTED(endContent, QVERIFY(endContent));
QTC_ASSERT_RESULT(endContent, QVERIFY(endContent));
QCOMPARE(*endContent, fileContents->mid(10));
@@ -242,7 +242,7 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(),
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());
client.start();
@@ -261,10 +261,10 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(),
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());
QTC_ASSERT_EXPECTED(client.start(), return);
QTC_ASSERT_RESULT(client.start(), return);
try {
auto result = client.stat("/tmp")->result();
@@ -385,12 +385,12 @@ The end.
auto bridgePath = CmdBridge::Client::getCmdBridgePath(HostOsInfo::hostOs(),
HostOsInfo::hostArchitecture(),
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());
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"}});