Skip to content

Commit

Permalink
run CTest in sanitizer jobs / added gui-tests CMake target (danmar#…
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Dec 4, 2024
1 parent 32e506d commit 1d490d9
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
sudo ./llvm.sh 19
- name: Install Qt ${{ env.QT_VERSION }}
if: false
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
Expand All @@ -73,7 +72,7 @@ jobs:
# TODO: disable all warnings
- name: CMake
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DUSE_QT6=On -DWITH_QCHART=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-19
CXX: clang++-19
Expand All @@ -86,16 +85,18 @@ jobs:
run: |
cmake --build cmake.output --target testrunner -- -j $(nproc)
- name: Build GUI tests
run: |
cmake --build cmake.output --target gui-tests -- -j $(nproc)
- name: Run tests
run: ./cmake.output/bin/testrunner

- name: Run cfg tests
run: |
cmake --build cmake.output --target checkcfg -- -j $(nproc)
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
- name: Run CTest
if: false
run: |
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
sudo ./llvm.sh 19
- name: Install Qt ${{ env.QT_VERSION }}
if: false
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
Expand All @@ -72,7 +71,7 @@ jobs:
- name: CMake
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DUSE_QT6=On -DWITH_QCHART=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-19
CXX: clang++-19
Expand All @@ -85,16 +84,19 @@ jobs:
run: |
cmake --build cmake.output --target testrunner -- -j $(nproc)
- name: Build GUI tests
run: |
cmake --build cmake.output --target gui-tests -- -j $(nproc)
- name: Run tests
run: ./cmake.output/bin/testrunner

- name: Run cfg tests
run: |
cmake --build cmake.output --target checkcfg -- -j $(nproc)
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
- name: Run CTest
if: false
if: false # TODO: test-filelist fails with data race in pthread_cond_destroy
run: |
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ jobs:
run: |
cmake --build cmake.output --target testrunner -- -j $(nproc)
- name: Build GUI tests
run: |
cmake --build cmake.output --target gui-tests -- -j $(nproc)
- name: Run tests
run: ./cmake.output/bin/testrunner

- name: Run cfg tests
run: |
cmake --build cmake.output --target checkcfg -- -j $(nproc)
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
- name: Run CTest
if: false
run: |
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
Expand Down
2 changes: 2 additions & 0 deletions gui/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_custom_target(gui-tests)

add_subdirectory(cppchecklibrarydata)
add_subdirectory(filelist)
add_subdirectory(projectfile)
Expand Down
4 changes: 3 additions & 1 deletion gui/test/cppchecklibrarydata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ endif()

if (REGISTER_GUI_TESTS)
add_test(NAME test-cppchecklibrarydata COMMAND $<TARGET_FILE:test-cppchecklibrarydata>)
endif()
endif()

add_dependencies(gui-tests test-cppchecklibrarydata)
4 changes: 3 additions & 1 deletion gui/test/filelist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ endif()

if (REGISTER_GUI_TESTS)
add_test(NAME test-filelist COMMAND $<TARGET_FILE:test-filelist>)
endif()
endif()

add_dependencies(gui-tests test-filelist)
4 changes: 3 additions & 1 deletion gui/test/projectfile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ endif()

if (REGISTER_GUI_TESTS)
add_test(NAME test-projectfile COMMAND $<TARGET_FILE:test-projectfile>)
endif()
endif()

add_dependencies(gui-tests test-projectfile)
13 changes: 12 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,9 +26,13 @@ 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)
# TODO: does not work in the CI
# add_test(NAME test-resultstree COMMAND $<TARGET_FILE:test-resultstree>)
endif()

add_dependencies(gui-tests test-resultstree)
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
4 changes: 3 additions & 1 deletion gui/test/translationhandler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ endif()
if (REGISTER_GUI_TESTS)
# TODO: requires X session - run with QT_QPA_PLATFORM=offscreen?
#add_test(NAME test-translationhandler COMMAND $<TARGET_FILE:test-translationhandler>)
endif()
endif()

add_dependencies(gui-tests test-translationhandler)
2 changes: 2 additions & 0 deletions gui/test/xmlreportv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ endif()
if (REGISTER_GUI_TESTS)
add_test(NAME test-xmlreportv2 COMMAND $<TARGET_FILE:test-xmlreportv2>)
endif()

add_dependencies(gui-tests test-xmlreportv2)

0 comments on commit 1d490d9

Please sign in to comment.