Skip to content

Commit 1d490d9

Browse files
authored
run CTest in sanitizer jobs / added gui-tests CMake target (danmar#7046)
1 parent 32e506d commit 1d490d9

File tree

11 files changed

+63
-15
lines changed

11 files changed

+63
-15
lines changed

.github/workflows/asan.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
sudo ./llvm.sh 19
5757
5858
- name: Install Qt ${{ env.QT_VERSION }}
59-
if: false
6059
uses: jurplel/install-qt-action@v4
6160
with:
6261
version: ${{ env.QT_VERSION }}
@@ -73,7 +72,7 @@ jobs:
7372
# TODO: disable all warnings
7473
- name: CMake
7574
run: |
76-
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
75+
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
7776
env:
7877
CC: clang-19
7978
CXX: clang++-19
@@ -86,16 +85,18 @@ jobs:
8685
run: |
8786
cmake --build cmake.output --target testrunner -- -j $(nproc)
8887
88+
- name: Build GUI tests
89+
run: |
90+
cmake --build cmake.output --target gui-tests -- -j $(nproc)
91+
8992
- name: Run tests
9093
run: ./cmake.output/bin/testrunner
9194

9295
- name: Run cfg tests
9396
run: |
9497
cmake --build cmake.output --target checkcfg -- -j $(nproc)
9598
96-
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
9799
- name: Run CTest
98-
if: false
99100
run: |
100101
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
101102

.github/workflows/tsan.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
sudo ./llvm.sh 19
5757
5858
- name: Install Qt ${{ env.QT_VERSION }}
59-
if: false
6059
uses: jurplel/install-qt-action@v4
6160
with:
6261
version: ${{ env.QT_VERSION }}
@@ -72,7 +71,7 @@ jobs:
7271
7372
- name: CMake
7473
run: |
75-
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
74+
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
7675
env:
7776
CC: clang-19
7877
CXX: clang++-19
@@ -85,16 +84,19 @@ jobs:
8584
run: |
8685
cmake --build cmake.output --target testrunner -- -j $(nproc)
8786
87+
- name: Build GUI tests
88+
run: |
89+
cmake --build cmake.output --target gui-tests -- -j $(nproc)
90+
8891
- name: Run tests
8992
run: ./cmake.output/bin/testrunner
9093

9194
- name: Run cfg tests
9295
run: |
9396
cmake --build cmake.output --target checkcfg -- -j $(nproc)
9497
95-
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
9698
- name: Run CTest
97-
if: false
99+
if: false # TODO: test-filelist fails with data race in pthread_cond_destroy
98100
run: |
99101
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
100102

.github/workflows/ubsan.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ jobs:
8585
run: |
8686
cmake --build cmake.output --target testrunner -- -j $(nproc)
8787
88+
- name: Build GUI tests
89+
run: |
90+
cmake --build cmake.output --target gui-tests -- -j $(nproc)
91+
8892
- name: Run tests
8993
run: ./cmake.output/bin/testrunner
9094

9195
- name: Run cfg tests
9296
run: |
9397
cmake --build cmake.output --target checkcfg -- -j $(nproc)
9498
95-
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
9699
- name: Run CTest
97-
if: false
98100
run: |
99101
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
100102

gui/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
add_custom_target(gui-tests)
2+
13
add_subdirectory(cppchecklibrarydata)
24
add_subdirectory(filelist)
35
add_subdirectory(projectfile)

gui/test/cppchecklibrarydata/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ endif()
1919

2020
if (REGISTER_GUI_TESTS)
2121
add_test(NAME test-cppchecklibrarydata COMMAND $<TARGET_FILE:test-cppchecklibrarydata>)
22-
endif()
22+
endif()
23+
24+
add_dependencies(gui-tests test-cppchecklibrarydata)

gui/test/filelist/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ endif()
2222

2323
if (REGISTER_GUI_TESTS)
2424
add_test(NAME test-filelist COMMAND $<TARGET_FILE:test-filelist>)
25-
endif()
25+
endif()
26+
27+
add_dependencies(gui-tests test-filelist)

gui/test/projectfile/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ endif()
1717

1818
if (REGISTER_GUI_TESTS)
1919
add_test(NAME test-projectfile COMMAND $<TARGET_FILE:test-projectfile>)
20-
endif()
20+
endif()
21+
22+
add_dependencies(gui-tests test-projectfile)

gui/test/resultstree/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
qt_wrap_cpp(test-resultstree_SRC testresultstree.h ${CMAKE_SOURCE_DIR}/gui/resultstree.h)
1+
qt_wrap_cpp(test-resultstree_SRC
2+
testresultstree.h
3+
${CMAKE_SOURCE_DIR}/gui/resultstree.h
4+
${CMAKE_SOURCE_DIR}/gui/applicationlist.h
5+
${CMAKE_SOURCE_DIR}/gui/projectfile.h
6+
${CMAKE_SOURCE_DIR}/gui/threadhandler.h
7+
${CMAKE_SOURCE_DIR}/gui/threadresult.h
8+
)
29
add_custom_target(build-resultstree-deps SOURCES ${test-resultstree_SRC})
310
add_dependencies(gui-build-deps build-resultstree-deps)
411
add_executable(test-resultstree
@@ -19,9 +26,13 @@ target_link_libraries(test-resultstree ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS
1926
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2027
# Q_UNUSED() in generated code
2128
target_compile_options_safe(test-resultstree -Wno-extra-semi-stmt)
29+
# caused by mocks
30+
target_compile_options_safe(test-resultstree -Wno-missing-noreturn)
2231
endif()
2332

2433
if (REGISTER_GUI_TESTS)
2534
# TODO: does not work in the CI
2635
# add_test(NAME test-resultstree COMMAND $<TARGET_FILE:test-resultstree>)
2736
endif()
37+
38+
add_dependencies(gui-tests test-resultstree)

gui/test/resultstree/testresultstree.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class TestReport : public Report {
6666
};
6767

6868
// Mock GUI...
69+
ProjectFile::ProjectFile(QObject *parent) : QObject(parent) {}
6970
ProjectFile *ProjectFile::mActiveProject;
7071
void ProjectFile::addSuppression(const SuppressionList::Suppression & /*unused*/) {}
7172
QString ProjectFile::getWarningTags(std::size_t /*unused*/) const {
@@ -78,12 +79,22 @@ bool ProjectFile::write(const QString & /*unused*/) {
7879
std::string severityToString(Severity severity) {
7980
return std::to_string((int)severity);
8081
}
82+
ApplicationList::ApplicationList(QObject *parent) : QObject(parent) {}
83+
ApplicationList::~ApplicationList() = default;
8184
int ApplicationList::getApplicationCount() const {
8285
return 0;
8386
}
87+
ThreadHandler::ThreadHandler(QObject *parent) : QObject(parent) {}
88+
ThreadHandler::~ThreadHandler() = default;
8489
bool ThreadHandler::isChecking() const {
8590
return false;
8691
}
92+
void ThreadHandler::stop() {
93+
throw 1;
94+
}
95+
void ThreadHandler::threadDone() {
96+
throw 1;
97+
}
8798
Application& ApplicationList::getApplication(const int /*unused*/) {
8899
throw 1;
89100
}
@@ -101,6 +112,15 @@ QString XmlReport::unquoteMessage(const QString &message) {
101112
return message;
102113
}
103114
XmlReport::XmlReport(const QString& filename) : Report(filename) {}
115+
void ThreadResult::fileChecked(const QString & /*unused*/) {
116+
throw 1;
117+
}
118+
void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) {
119+
throw 1;
120+
}
121+
void ThreadResult::reportErr(const ErrorMessage & /*unused*/) {
122+
throw 1;
123+
}
104124

105125
// Mock LIB...
106126
bool Path::isHeader(std::string const& /*unused*/) {

gui/test/translationhandler/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ endif()
1818
if (REGISTER_GUI_TESTS)
1919
# TODO: requires X session - run with QT_QPA_PLATFORM=offscreen?
2020
#add_test(NAME test-translationhandler COMMAND $<TARGET_FILE:test-translationhandler>)
21-
endif()
21+
endif()
22+
23+
add_dependencies(gui-tests test-translationhandler)

0 commit comments

Comments
 (0)