Skip to content

Commit

Permalink
test-resultstree: fixed linking with sanitizers by adding more mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Nov 27, 2024
1 parent cd728b7 commit e0eb5f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gui/test/resultstree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions gui/test/resultstree/testresultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
Expand All @@ -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*/) {
Expand Down

0 comments on commit e0eb5f8

Please sign in to comment.