From a51a334941961df687ed43f4083658a7b1b4b83f Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 14 Apr 2025 09:29:10 +0200 Subject: [PATCH] Utils: Move and rename result testing macros from expected.h to result.h Change-Id: I65d682054d4774b8937ecce9728a9d2f2e75cc2a Reviewed-by: Jarek Kobus --- .../advanceddockingsystem/dockmanager.cpp | 2 +- src/libs/extensionsystem/pluginspec.cpp | 2 +- src/libs/extensionsystem/pluginspec.h | 1 - .../gocmdbridge/client/bridgedfileaccess.cpp | 48 +++++++++---------- .../gocmdbridge/client/cmdbridgeclient.cpp | 2 +- src/libs/gocmdbridge/client/cmdbridgeclient.h | 1 - src/libs/utils/expected.h | 29 ----------- src/libs/utils/filepath.cpp | 6 +-- src/libs/utils/fsengine/fsenginehandler.cpp | 4 +- src/libs/utils/result.h | 29 +++++++++++ src/plugins/android/androidbuildapkstep.cpp | 2 +- .../clangformat/clangformatconfigwidget.cpp | 3 +- src/plugins/clangformat/clangformatutils.cpp | 3 +- src/plugins/clangformat/llvmfilesystem.h | 2 +- .../cmakeprojectmanager/fileapireader.cpp | 4 +- .../compilerexplorereditor.cpp | 4 +- src/plugins/coreplugin/documentmanager.cpp | 2 +- src/plugins/coreplugin/externaltool.cpp | 2 +- src/plugins/coreplugin/session.cpp | 2 +- src/plugins/cppeditor/compilationdb.h | 1 - src/plugins/cppeditor/cpptoolsjsextension.cpp | 2 +- src/plugins/docker/dockerapi.h | 2 +- src/plugins/docker/dockerdevice.cpp | 3 +- .../lualanguageclient/lualanguageclient.cpp | 6 +-- src/plugins/lua/bindings/action.cpp | 2 +- src/plugins/lua/bindings/gui.cpp | 6 +-- src/plugins/lua/bindings/hook.cpp | 4 +- src/plugins/lua/bindings/localsocket.cpp | 6 +-- src/plugins/lua/bindings/project.cpp | 12 ++--- src/plugins/lua/bindings/settings.cpp | 26 +++++----- src/plugins/lua/bindings/taskhub.cpp | 2 +- src/plugins/lua/bindings/texteditor.cpp | 12 ++--- src/plugins/lua/luaengine.cpp | 2 +- src/plugins/lua/luaengine.h | 1 - src/plugins/lua/luaplugin.cpp | 4 +- src/plugins/lua/luapluginspec.cpp | 1 - src/plugins/lua/luapluginspec.h | 1 - .../projectexplorer/devicesupport/idevice.cpp | 2 +- .../projectexplorer/devicesupport/idevice.h | 1 - src/plugins/projectexplorer/extracompiler.cpp | 6 +-- src/plugins/projectexplorer/gcctoolchain.cpp | 12 ++--- .../runconfigurationaspects.cpp | 2 +- .../components/componentcore/bundlehelper.cpp | 4 +- .../contentlibrary/contentlibraryview.cpp | 16 +++---- .../components/edit3d/bakelightsdatamodel.cpp | 1 - .../designercoreutils/modelutils.cpp | 3 +- .../mcumoduleprojectitem.cpp | 2 +- src/plugins/qtsupport/examplesparser.h | 3 +- src/plugins/squish/scripthelper.cpp | 2 +- src/plugins/squish/squishtesttreeview.cpp | 4 +- src/plugins/squish/suiteconf.cpp | 6 +-- src/plugins/terminal/shellintegration.cpp | 10 ++-- src/plugins/terminal/shellmodel.cpp | 2 +- src/plugins/terminal/terminalsettings.cpp | 1 - src/plugins/texteditor/formattexteditor.cpp | 1 - .../pluginspec/tst_pluginspec.cpp | 8 ++-- tests/manual/cmdbridge/tst_cmdbridge.cpp | 18 +++---- 57 files changed, 166 insertions(+), 179 deletions(-) diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp index d599226dbf5..e4cee5fb1ea 100644 --- a/src/libs/advanceddockingsystem/dockmanager.cpp +++ b/src/libs/advanceddockingsystem/dockmanager.cpp @@ -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 content = filePath.fileContents(); - QTC_ASSERT_EXPECTED(content, return false); + QTC_ASSERT_RESULT(content, return false); QDomDocument doc; QString error_msg; diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index b778dc10613..3e575ea1b44 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -1441,7 +1441,7 @@ static QList createCppPluginsFromArchive(const FilePath &path) if (path.isFile()) { if (QLibrary::isLibrary(path.toFSPathString())) { Result> spec = readCppPluginSpec(path); - QTC_CHECK_EXPECTED(spec); + QTC_CHECK_RESULT(spec); if (spec) results.push_back(spec->release()); } diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index 90d4333dcca..7148f4f580a 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -7,7 +7,6 @@ #include "iplugin.h" -#include #include #include diff --git a/src/libs/gocmdbridge/client/bridgedfileaccess.cpp b/src/libs/gocmdbridge/client/bridgedfileaccess.cpp index 8cea067560f..b735d81c752 100644 --- a/src/libs/gocmdbridge/client/bridgedfileaccess.cpp +++ b/src/libs/gocmdbridge/client/bridgedfileaccess.cpp @@ -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> 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> 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> 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> 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> 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> 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 FileAccess::fileContents(const FilePath &filePath, Result> 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 FileAccess::writeFileContents(const FilePath &filePath, { try { Result> 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 FileAccess::createTempFile(const FilePath &filePath) } Utils::Result> f = m_client->createTempFile(path); - QTC_ASSERT_EXPECTED(f, return {}); + QTC_ASSERT_RESULT(f, return {}); f->waitForFinished(); Result 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; diff --git a/src/libs/gocmdbridge/client/cmdbridgeclient.cpp b/src/libs/gocmdbridge/client/cmdbridgeclient.cpp index 366a2891e45..294bf0fcb79 100644 --- a/src/libs/gocmdbridge/client/cmdbridgeclient.cpp +++ b/src/libs/gocmdbridge/client/cmdbridgeclient.cpp @@ -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); } } }; diff --git a/src/libs/gocmdbridge/client/cmdbridgeclient.h b/src/libs/gocmdbridge/client/cmdbridgeclient.h index 5252a32ab00..cb78b28be00 100644 --- a/src/libs/gocmdbridge/client/cmdbridgeclient.h +++ b/src/libs/gocmdbridge/client/cmdbridgeclient.h @@ -5,7 +5,6 @@ #include "cmdbridgeglobal.h" -#include #include #include #include diff --git a/src/libs/utils/expected.h b/src/libs/utils/expected.h index fccd979d69c..bf1dc0d64de 100644 --- a/src/libs/utils/expected.h +++ b/src/libs/utils/expected.h @@ -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(expected.error().toUtf8())) diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index d92dd2cb55c..f1e45a71273 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -1340,7 +1340,7 @@ DeviceFileAccess *FilePath::fileAccess() const { static DeviceFileAccess dummy; const Result 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 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()) diff --git a/src/libs/utils/fsengine/fsenginehandler.cpp b/src/libs/utils/fsengine/fsenginehandler.cpp index 2ce7014ea53..4d69623d846 100644 --- a/src/libs/utils/fsengine/fsenginehandler.cpp +++ b/src/libs/utils/fsengine/fsenginehandler.cpp @@ -144,10 +144,10 @@ bool FSEngineImpl::open(QIODeviceBase::OpenMode openMode, std::optional readResult = m_filePath.fileContents(); - QTC_ASSERT_EXPECTED(readResult, return false); + QTC_ASSERT_RESULT(readResult, return false); const Result writeResult = m_tempStorage->write(*readResult); - QTC_ASSERT_EXPECTED(writeResult, return false); + QTC_ASSERT_RESULT(writeResult, return false); if (!append) m_tempStorage->seek(0); diff --git a/src/libs/utils/result.h b/src/libs/utils/result.h index 86892592dde..d29496cd28c 100644 --- a/src/libs/utils/result.h +++ b/src/libs/utils/result.h @@ -6,6 +6,7 @@ #include "utils_global.h" #include "expected.h" +#include "qtcassert.h" #include @@ -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(result.error().toUtf8())) diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index c95595c3309..d19cc699c3e 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -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; } diff --git a/src/plugins/clangformat/clangformatconfigwidget.cpp b/src/plugins/clangformat/clangformatconfigwidget.cpp index 03c425abb8a..d15e50fc8df 100644 --- a/src/plugins/clangformat/clangformatconfigwidget.cpp +++ b/src/plugins/clangformat/clangformatconfigwidget.cpp @@ -33,11 +33,10 @@ #include #include +#include #include #include #include -#include -#include #include #include diff --git a/src/plugins/clangformat/clangformatutils.cpp b/src/plugins/clangformat/clangformatutils.cpp index b6dad2e802e..6790ae590a9 100644 --- a/src/plugins/clangformat/clangformatutils.cpp +++ b/src/plugins/clangformat/clangformatutils.cpp @@ -17,9 +17,8 @@ #include #include -#include -#include #include +#include #include #include diff --git a/src/plugins/clangformat/llvmfilesystem.h b/src/plugins/clangformat/llvmfilesystem.h index 70dfe2498a7..0bfa5afe614 100644 --- a/src/plugins/clangformat/llvmfilesystem.h +++ b/src/plugins/clangformat/llvmfilesystem.h @@ -52,7 +52,7 @@ public: const FilePath path = FilePath::fromUserInput(QString::fromStdString(Name.str())); const Result 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); } diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 127a3be9665..9d5ced2e25e 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -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() diff --git a/src/plugins/compilerexplorer/compilerexplorereditor.cpp b/src/plugins/compilerexplorer/compilerexplorereditor.cpp index 8fc2ad56fee..2ea71e12f4b 100644 --- a/src/plugins/compilerexplorer/compilerexplorereditor.cpp +++ b/src/plugins/compilerexplorer/compilerexplorereditor.cpp @@ -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 &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); diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 8db637c3f9e..43f5d85cdde 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -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] { diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 26927011589..9c0b55f2b62 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -598,7 +598,7 @@ bool ExternalToolRunner::resolve() } const Result 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()); diff --git a/src/plugins/coreplugin/session.cpp b/src/plugins/coreplugin/session.cpp index c615fbc7e08..a149f1d5902 100644 --- a/src/plugins/coreplugin/session.cpp +++ b/src/plugins/coreplugin/session.cpp @@ -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); } diff --git a/src/plugins/cppeditor/compilationdb.h b/src/plugins/cppeditor/compilationdb.h index 8a7856dabb5..876b743f2fa 100644 --- a/src/plugins/cppeditor/compilationdb.h +++ b/src/plugins/cppeditor/compilationdb.h @@ -6,7 +6,6 @@ #include "cppeditor_global.h" #include "projectinfo.h" -#include #include #include diff --git a/src/plugins/cppeditor/cpptoolsjsextension.cpp b/src/plugins/cppeditor/cpptoolsjsextension.cpp index 20da5c15261..d76a95c6527 100644 --- a/src/plugins/cppeditor/cpptoolsjsextension.cpp +++ b/src/plugins/cppeditor/cpptoolsjsextension.cpp @@ -150,7 +150,7 @@ bool CppToolsJsExtension::hasQObjectParent(const QString &klassName) const std::optional source = workingCopy.source(item->filePath()); if (!source) { const Utils::Result 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()); diff --git a/src/plugins/docker/dockerapi.h b/src/plugins/docker/dockerapi.h index 309cb2423f7..859cd753281 100644 --- a/src/plugins/docker/dockerapi.h +++ b/src/plugins/docker/dockerapi.h @@ -3,9 +3,9 @@ #pragma once -#include #include #include +#include #include #include diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index a072193ee04..9d8fa9e91d0 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -928,7 +927,7 @@ Result DockerDevicePrivate::getCmdBridgePath() const QStringList DockerDevicePrivate::createMountArgs() const { const Utils::Result cmdBridgePath = getCmdBridgePath(); - QTC_CHECK_EXPECTED(cmdBridgePath); + QTC_CHECK_RESULT(cmdBridgePath); QStringList cmds; QList mounts; diff --git a/src/plugins/languageclient/lualanguageclient/lualanguageclient.cpp b/src/plugins/languageclient/lualanguageclient/lualanguageclient.cpp index e69183f8a46..78ba4c18934 100644 --- a/src/plugins/languageclient/lualanguageclient/lualanguageclient.cpp +++ b/src/plugins/languageclient/lualanguageclient/lualanguageclient.cpp @@ -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 {}; diff --git a/src/plugins/lua/bindings/action.cpp b/src/plugins/lua/bindings/action.cpp index 1a08b6ce486..73dc7fb2ad7 100644 --- a/src/plugins/lua/bindings/action.cpp +++ b/src/plugins/lua/bindings/action.cpp @@ -71,7 +71,7 @@ void setupActionModule() else if (key == "onTrigger") b.addOnTriggered([f = v.as()]() { auto res = void_safe_call(f); - QTC_CHECK_EXPECTED(res); + QTC_CHECK_RESULT(res); }); else if (key == "text") b.setText(v.as()); diff --git a/src/plugins/lua/bindings/gui.cpp b/src/plugins/lua/bindings/gui.cpp index f08cb041288..be1501eb40f 100644 --- a/src/plugins/lua/bindings/gui.cpp +++ b/src/plugins/lua/bindings/gui.cpp @@ -41,7 +41,7 @@ static void processChildren(T *item, const sol::table &children) } else if (child.is()) { const sol::function f = child.get(); auto res = void_safe_call(f, item); - QTC_ASSERT_EXPECTED(res, continue); + QTC_ASSERT_RESULT(res, continue); } else if (child.is()) { const Span &span = child.get(); item->addItem(span); @@ -315,7 +315,7 @@ void setProperties(std::unique_ptr &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 &item, const sol::table &children, QObject guard, [f = *onClicked]() { auto res = void_safe_call(f); - QTC_CHECK_EXPECTED(res); + QTC_CHECK_RESULT(res); }); } } diff --git a/src/plugins/lua/bindings/hook.cpp b/src/plugins/lua/bindings/hook.cpp index 663b64088b1..00b6961217a 100644 --- a/src/plugins/lua/bindings/hook.cpp +++ b/src/plugins/lua/bindings/hook.cpp @@ -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); }); }); } diff --git a/src/plugins/lua/bindings/localsocket.cpp b/src/plugins/lua/bindings/localsocket.cpp index bb4215a5553..771e800292a 100644 --- a/src/plugins/lua/bindings/localsocket.cpp +++ b/src/plugins/lua/bindings/localsocket.cpp @@ -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); }; diff --git a/src/plugins/lua/bindings/project.cpp b/src/plugins/lua/bindings/project.cpp index ada4fb314f5..ebf9bf2e8f6 100644 --- a/src/plugins/lua/bindings/project.cpp +++ b/src/plugins/lua/bindings/project.cpp @@ -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); } ); }); diff --git a/src/plugins/lua/bindings/settings.cpp b/src/plugins/lua/bindings/settings.cpp index 3dba28e1f43..5a3044bc64e 100644 --- a/src/plugins/lua/bindings/settings.cpp +++ b/src/plugins/lua/bindings/settings.cpp @@ -70,7 +70,7 @@ std::unique_ptr aspectContainerCreate(const sol::main_table container->setLayouter( [func = v.as()]() -> Layouting::Layout { auto res = safe_call(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()](const QString &oldValue, const QString &newValue) -> std::optional { auto res = safe_call>(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()](const QString &value) { auto res = safe_call(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()]() { auto res = void_safe_call(func); - QTC_CHECK_EXPECTED(res); + QTC_CHECK_RESULT(res); }); else if (key == "expectedKind") aspect->setExpectedKind((PathChooser::Kind) value.as()); @@ -218,7 +218,7 @@ void typedAspectCreate(FilePathAspect *aspect, const std::string &key, const sol [func = value.as()](const QString &oldValue, const QString &newValue) -> std::optional { auto res = safe_call>(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()](const QString &path) { auto res = safe_call(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 &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()]() -> std::shared_ptr { auto res = safe_call>(func); - QTC_ASSERT_EXPECTED(res, return nullptr); + QTC_ASSERT_RESULT(res, return nullptr); return *res; }); } else if (key == "onItemAdded") { aspect->setItemAddedCallback([func = value.as()]( std::shared_ptr 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()]( std::shared_ptr 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([clbk](std::shared_ptr 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([clbk](std::shared_ptr item, int idx) { auto res = void_safe_call(clbk, item, idx); - QTC_CHECK_EXPECTED(res); + QTC_CHECK_RESULT(res); }); }, sol::base_classes, diff --git a/src/plugins/lua/bindings/taskhub.cpp b/src/plugins/lua/bindings/taskhub.cpp index 21e9bdaf185..90d17f08c37 100644 --- a/src/plugins/lua/bindings/taskhub.cpp +++ b/src/plugins/lua/bindings/taskhub.cpp @@ -25,7 +25,7 @@ struct FPTR { return [func](Args... args) { Result<> res = void_safe_call(func, args...); - QTC_CHECK_EXPECTED(res); + QTC_CHECK_RESULT(res); }; } }; diff --git a/src/plugins/lua/bindings/texteditor.cpp b/src/plugins/lua/bindings/texteditor.cpp index 5e62d1b892f..c33a94778c6 100644 --- a/src/plugins/lua/bindings/texteditor.cpp +++ b/src/plugins/lua/bindings/texteditor.cpp @@ -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); }); }); } diff --git a/src/plugins/lua/luaengine.cpp b/src/plugins/lua/luaengine.cpp index 6eea730c7b1..3b19fcf518c 100644 --- a/src/plugins/lua/luaengine.cpp +++ b/src/plugins/lua/luaengine.cpp @@ -141,7 +141,7 @@ void prepareLuaState( } }; const Result 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(); diff --git a/src/plugins/lua/luaengine.h b/src/plugins/lua/luaengine.h index f2f14ac6098..7c18f3893dd 100644 --- a/src/plugins/lua/luaengine.h +++ b/src/plugins/lua/luaengine.h @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/src/plugins/lua/luaplugin.cpp b/src/plugins/lua/luaplugin.cpp index 3609534d5a8..82fa78e7f50 100644 --- a/src/plugins/lua/luaplugin.cpp +++ b/src/plugins/lua/luaplugin.cpp @@ -327,7 +327,7 @@ public: if (path.isFile()) { if (path.suffix() == "lua") { Utils::Result 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 spec = loadPlugin(specFilePath); - QTC_CHECK_EXPECTED(spec); + QTC_CHECK_RESULT(spec); if (spec) plugins.push_back(*spec); } diff --git a/src/plugins/lua/luapluginspec.cpp b/src/plugins/lua/luapluginspec.cpp index 37435588630..72d7d1534ad 100644 --- a/src/plugins/lua/luapluginspec.cpp +++ b/src/plugins/lua/luapluginspec.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/src/plugins/lua/luapluginspec.h b/src/plugins/lua/luapluginspec.h index 5e215bfd8fd..a19eb6eb17f 100644 --- a/src/plugins/lua/luapluginspec.h +++ b/src/plugins/lua/luapluginspec.h @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index be0d35069bb..5a520e9af20 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -329,7 +329,7 @@ FileTransferInterface *IDevice::createFileTransferInterface( Environment IDevice::systemEnvironment() const { Result env = systemEnvironmentWithError(); - QTC_ASSERT_EXPECTED(env, return {}); + QTC_ASSERT_RESULT(env, return {}); return *env; } diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 99089fabff4..9d08accdaec 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index 37c9fae946f..95895529b10 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -14,8 +14,8 @@ #include #include -#include #include +#include #include #include @@ -89,7 +89,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const FilePath &source, d->compileTime = lastModified; const Result 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 contents = target.fileContents(); - QTC_ASSERT_EXPECTED(contents, return); + QTC_ASSERT_RESULT(contents, return); d->compileTime = generateTime; setContent(target, *contents); diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 504120394f8..1f4e5a359e9 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -214,7 +214,7 @@ static HeaderPaths gccHeaderPaths(const FilePath &gcc, const Environment &env) { Result 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 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 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 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 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 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; diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index c251650f812..d415f1a6742 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -327,7 +327,7 @@ QString ArgumentsAspect::arguments() const m_currentlyExpanding = true; const Result expanded = macroExpander()->expandProcessArgs(m_arguments); - QTC_ASSERT_EXPECTED(expanded, return m_arguments); + QTC_ASSERT_RESULT(expanded, return m_arguments); m_currentlyExpanding = false; return *expanded; diff --git a/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp b/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp index 68468239763..b911ab76ab3 100644 --- a/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp @@ -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) diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp index 1bba42563aa..7f41ebb4e83 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp @@ -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) diff --git a/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp b/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp index bce2777f0d9..37e035699c4 100644 --- a/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp +++ b/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp @@ -19,7 +19,6 @@ #include -#include #include #include diff --git a/src/plugins/qmldesigner/libs/designercore/designercoreutils/modelutils.cpp b/src/plugins/qmldesigner/libs/designercore/designercoreutils/modelutils.cpp index c22b9175c55..1345603b9cc 100644 --- a/src/plugins/qmldesigner/libs/designercore/designercoreutils/modelutils.cpp +++ b/src/plugins/qmldesigner/libs/designercore/designercoreutils/modelutils.cpp @@ -8,9 +8,8 @@ #include #include - -#include #include +#include #include #include diff --git a/src/plugins/qmlprojectmanager/qmldirtoqmlproject/mcumoduleprojectitem.cpp b/src/plugins/qmlprojectmanager/qmldirtoqmlproject/mcumoduleprojectitem.cpp index 3d58818bbd3..14db6e9be73 100644 --- a/src/plugins/qmlprojectmanager/qmldirtoqmlproject/mcumoduleprojectitem.cpp +++ b/src/plugins/qmlprojectmanager/qmldirtoqmlproject/mcumoduleprojectitem.cpp @@ -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; } diff --git a/src/plugins/qtsupport/examplesparser.h b/src/plugins/qtsupport/examplesparser.h index 07109bca539..af3430e6852 100644 --- a/src/plugins/qtsupport/examplesparser.h +++ b/src/plugins/qtsupport/examplesparser.h @@ -6,8 +6,9 @@ #include "qtsupport_global.h" #include -#include + #include +#include namespace QtSupport::Internal { diff --git a/src/plugins/squish/scripthelper.cpp b/src/plugins/squish/scripthelper.cpp index 283d3b16d9c..2b4f7c19360 100644 --- a/src/plugins/squish/scripthelper.cpp +++ b/src/plugins/squish/scripthelper.cpp @@ -145,7 +145,7 @@ bool ScriptHelper::writeScriptFile(const Utils::FilePath &outScriptFile, data.append(line).append('\n'); const Utils::Result result = outScriptFile.writeFileContents(data); - QTC_ASSERT_EXPECTED(result, return false); + QTC_ASSERT_RESULT(result, return false); return true; } diff --git a/src/plugins/squish/squishtesttreeview.cpp b/src/plugins/squish/squishtesttreeview.cpp index 4021bc94e18..75d5684b8ad 100644 --- a/src/plugins/squish/squishtesttreeview.cpp +++ b/src/plugins/squish/squishtesttreeview.cpp @@ -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(); diff --git a/src/plugins/squish/suiteconf.cpp b/src/plugins/squish/suiteconf.cpp index 350e73bbe90..801614b11ab 100644 --- a/src/plugins/squish/suiteconf.cpp +++ b/src/plugins/squish/suiteconf.cpp @@ -112,7 +112,7 @@ static bool writeSuiteConfContent(const Utils::FilePath &file, const QMap 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; } diff --git a/src/plugins/terminal/shellintegration.cpp b/src/plugins/terminal/shellintegration.cpp index 11f9dcc2c27..67dbba14d36 100644 --- a/src/plugins/terminal/shellintegration.cpp +++ b/src/plugins/terminal/shellintegration.cpp @@ -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()); } diff --git a/src/plugins/terminal/shellmodel.cpp b/src/plugins/terminal/shellmodel.cpp index dd45515b09b..5f5fe439d53 100644 --- a/src/plugins/terminal/shellmodel.cpp +++ b/src/plugins/terminal/shellmodel.cpp @@ -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); diff --git a/src/plugins/terminal/terminalsettings.cpp b/src/plugins/terminal/terminalsettings.cpp index 1873d712056..b0f4f7cea45 100644 --- a/src/plugins/terminal/terminalsettings.cpp +++ b/src/plugins/terminal/terminalsettings.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/src/plugins/texteditor/formattexteditor.cpp b/src/plugins/texteditor/formattexteditor.cpp index 2d53b19c1ce..3cd971d65a6 100644 --- a/src/plugins/texteditor/formattexteditor.cpp +++ b/src/plugins/texteditor/formattexteditor.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp index c996c174b79..9466c64d37f 100644 --- a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp +++ b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp @@ -238,7 +238,7 @@ void tst_PluginSpec::locationAndPath() { Utils::Result> ps = readCppPluginSpec( PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); - QVERIFY_EXPECTED(ps); + QVERIFY_RESULT(ps); CppPluginSpec *spec = static_cast(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> ps = readCppPluginSpec( PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); - QVERIFY_EXPECTED(ps); + QVERIFY_RESULT(ps); CppPluginSpec *spec = static_cast(ps->get()); QCOMPARE(spec->errorString(), QString()); @@ -310,7 +310,7 @@ void tst_PluginSpec::initializePlugin() { Utils::Result> ps = readCppPluginSpec( PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); - QVERIFY_EXPECTED(ps); + QVERIFY_RESULT(ps); CppPluginSpec *spec = static_cast(ps->get()); QVERIFY(spec->resolveDependencies({})); QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString())); @@ -334,7 +334,7 @@ void tst_PluginSpec::initializeExtensions() { Utils::Result> ps = readCppPluginSpec( PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test"))); - QVERIFY_EXPECTED(ps); + QVERIFY_RESULT(ps); CppPluginSpec *spec = static_cast(ps->get()); QVERIFY(spec->resolveDependencies({})); QVERIFY2(spec->loadLibrary(), qPrintable(spec->errorString())); diff --git a/tests/manual/cmdbridge/tst_cmdbridge.cpp b/tests/manual/cmdbridge/tst_cmdbridge.cpp index 2c91ca093d5..79d22a7b8bf 100644 --- a/tests/manual/cmdbridge/tst_cmdbridge.cpp +++ b/tests/manual/cmdbridge/tst_cmdbridge.cpp @@ -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"}});