From 6672038f8228af057478bfc7828b3573d3f5ca8a Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 15 Oct 2024 23:22:13 +0200 Subject: [PATCH] test-resultstree: fixed linking with sanitizers by adding more mocks --- gui/test/resultstree/CMakeLists.txt | 11 ++++++++++- gui/test/resultstree/testresultstree.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gui/test/resultstree/CMakeLists.txt b/gui/test/resultstree/CMakeLists.txt index 954ae28dc19..bc7f42be2e4 100644 --- a/gui/test/resultstree/CMakeLists.txt +++ b/gui/test/resultstree/CMakeLists.txt @@ -1,4 +1,11 @@ -qt_wrap_cpp(test-resultstree_SRC testresultstree.h ${CMAKE_SOURCE_DIR}/gui/resultstree.h) +qt_wrap_cpp(test-resultstree_SRC + testresultstree.h + ${CMAKE_SOURCE_DIR}/gui/resultstree.h + ${CMAKE_SOURCE_DIR}/gui/applicationlist.h + ${CMAKE_SOURCE_DIR}/gui/projectfile.h + ${CMAKE_SOURCE_DIR}/gui/threadhandler.h + ${CMAKE_SOURCE_DIR}/gui/threadresult.h +) add_custom_target(build-resultstree-deps SOURCES ${test-resultstree_SRC}) add_dependencies(gui-build-deps build-resultstree-deps) add_executable(test-resultstree @@ -19,6 +26,8 @@ target_link_libraries(test-resultstree ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Q_UNUSED() in generated code target_compile_options_safe(test-resultstree -Wno-extra-semi-stmt) + # caused by mocks + target_compile_options_safe(test-resultstree -Wno-missing-noreturn) endif() if (REGISTER_GUI_TESTS) diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index 003fce9b445..de60cb6e3bd 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -66,6 +66,7 @@ class TestReport : public Report { }; // Mock GUI... +ProjectFile::ProjectFile(QObject *parent) : QObject(parent) {} ProjectFile *ProjectFile::mActiveProject; void ProjectFile::addSuppression(const SuppressionList::Suppression & /*unused*/) {} QString ProjectFile::getWarningTags(std::size_t /*unused*/) const { @@ -78,12 +79,22 @@ bool ProjectFile::write(const QString & /*unused*/) { std::string severityToString(Severity severity) { return std::to_string((int)severity); } +ApplicationList::ApplicationList(QObject *parent) : QObject(parent) {} +ApplicationList::~ApplicationList() = default; int ApplicationList::getApplicationCount() const { return 0; } +ThreadHandler::ThreadHandler(QObject *parent) : QObject(parent) {} +ThreadHandler::~ThreadHandler() = default; bool ThreadHandler::isChecking() const { return false; } +void ThreadHandler::stop() { + throw 1; +} +void ThreadHandler::threadDone() { + throw 1; +} Application& ApplicationList::getApplication(const int /*unused*/) { throw 1; } @@ -101,6 +112,15 @@ QString XmlReport::unquoteMessage(const QString &message) { return message; } XmlReport::XmlReport(const QString& filename) : Report(filename) {} +void ThreadResult::fileChecked(const QString & /*unused*/) { + throw 1; +} +void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) { + throw 1; +} +void ThreadResult::reportErr(const ErrorMessage & /*unused*/) { + throw 1; +} // Mock LIB... bool Path::isHeader(std::string const& /*unused*/) {