added handling of library element `entrypoint` to GUI / added GUI tes… · cppchecksolutions/cppcheck@b097eca · GitHub
Skip to content

Commit b097eca

Browse files
authored
added handling of library element entrypoint to GUI / added GUI tests to CTest (cppcheck-opensource#4744)
1 parent f16ffd8 commit b097eca

20 files changed

Lines changed: 101 additions & 24 deletions

‎.github/workflows/CI-unixish.yml‎

Lines changed: 3 additions & 5 deletions

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ stage
125125
compile_commands.json
126126

127127
# qmake
128-
/gui/.qmake.stash
128+
.qmake.stash
129129

130130
#vs code
131131
/.vscode

‎cmake/options.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ option(ENABLE_OSS_FUZZ "Enable the OSS-Fuzz related targets"
4343
option(BUILD_GUI "Build the qt application" OFF)
4444
option(WITH_QCHART "Enable QtCharts usage in the GUI" OFF)
4545
option(USE_QT6 "Prefer Qt6 when available" OFF)
46+
option(REGISTER_GUI_TESTS "Register GUI tests in CTest" ON)
4647

4748
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
4849
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)

‎cmake/printInfo.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ message( STATUS "ENABLE_OSS_FUZZ = ${ENABLE_OSS_FUZZ}" )
4949
message( STATUS )
5050
message( STATUS "BUILD_GUI = ${BUILD_GUI}" )
5151
if (BUILD_GUI)
52+
message( STATUS "REGISTER_GUI_TESTS = ${REGISTER_GUI_TESTS}" )
5253
message( STATUS "WITH_QCHART = ${WITH_QCHART}" )
5354
message( STATUS "USE_QT6 = ${USE_QT6}" )
5455
message( STATUS "QT_VERSION = ${QT_VERSION}")

‎gui/cppchecklibrarydata.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
446446
return markup;
447447
}
448448

449+
static CppcheckLibraryData::Entrypoint loadEntrypoint(QXmlStreamReader &xmlReader)
450+
{
451+
CppcheckLibraryData::Entrypoint entrypoint;
452+
entrypoint.name = xmlReader.attributes().value("name").toString();
453+
return entrypoint;
454+
}
455+
449456
QString CppcheckLibraryData::open(QIODevice &file)
450457
{
451458
clear();
@@ -486,6 +493,8 @@ QString CppcheckLibraryData::open(QIODevice &file)
486493
reflections.append(loadReflection(xmlReader));
487494
else if (elementName == "markup")
488495
markups.append(loadMarkup(xmlReader));
496+
else if (elementName == "entrypoint")
497+
entrypoints.append(loadEntrypoint(xmlReader));
489498
else
490499
unhandledElement(xmlReader);
491500
} catch (std::runtime_error &e) {
@@ -918,6 +927,12 @@ QString CppcheckLibraryData::toString() const
918927
writeMarkup(xmlWriter, mup);
919928
}
920929

930+
for (const Entrypoint &ent : entrypoints) {
931+
xmlWriter.writeStartElement("entrypoint");
932+
xmlWriter.writeAttribute("name", ent.name);
933+
xmlWriter.writeEndElement();
934+
}
935+
921936
xmlWriter.writeEndElement();
922937

923938
return outputString;

‎gui/cppchecklibrarydata.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ class CppcheckLibraryData {
238238
bool unique;
239239
};
240240

241+
struct Entrypoint {
242+
QString name;
243+
};
244+
241245
void clear() {
242246
containers.clear();
243247
defines.clear();
@@ -250,6 +254,7 @@ class CppcheckLibraryData {
250254
platformTypes.clear();
251255
reflections.clear();
252256
markups.clear();
257+
entrypoints.clear();
253258
}
254259

255260
void swap(CppcheckLibraryData &other) {
@@ -264,6 +269,7 @@ class CppcheckLibraryData {
264269
platformTypes.swap(other.platformTypes);
265270
reflections.swap(other.reflections);
266271
markups.swap(other.markups);
272+
entrypoints.swap(other.entrypoints);
267273
}
268274

269275
QString open(QIODevice &file);
@@ -280,6 +286,7 @@ class CppcheckLibraryData {
280286
QList<struct SmartPointer> smartPointers;
281287
QList<struct Reflection> reflections;
282288
QList<struct Markup> markups;
289+
QList<struct Entrypoint> entrypoints;
283290
};
284291

285292
#endif // CPPCHECKLIBRARYDATA_H
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
qt_wrap_cpp(test-cppchecklibrarydata_SRC testcppchecklibrarydata.h)
2-
add_custom_target(build-cppchecklibrarydata-deps SOURCES ${test-cppchecklibrarydata_SRC})
2+
QT_ADD_RESOURCES(test-cppchecklibrarydata_resources "resources.qrc")
3+
add_custom_target(build-cppchecklibrarydata-deps SOURCES ${test-cppchecklibrarydata_SRC} ${test-cppchecklibrarydata_resources})
34
add_dependencies(gui-build-deps build-cppchecklibrarydata-deps)
45
add_executable(test-cppchecklibrarydata
56
${test-cppchecklibrarydata_SRC}
7+
${test-cppchecklibrarydata_resources}
68
testcppchecklibrarydata.cpp
79
${CMAKE_SOURCE_DIR}/gui/cppchecklibrarydata.cpp
810
)
911
target_include_directories(test-cppchecklibrarydata PRIVATE ${CMAKE_SOURCE_DIR}/gui)
12+
target_compile_definitions(test-cppchecklibrarydata PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
1013
target_link_libraries(test-cppchecklibrarydata ${QT_CORE_LIB} ${QT_TEST_LIB})
1114

1215
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1316
# Q_UNUSED() in generated code
1417
target_compile_options_safe(test-cppchecklibrarydata -Wno-extra-semi-stmt)
18+
endif()
19+
20+
if (REGISTER_GUI_TESTS)
21+
add_test(NAME test-cppchecklibrarydata COMMAND $<TARGET_FILE:test-cppchecklibrarydata>)
1522
endif()

‎gui/test/cppchecklibrarydata/cppchecklibrarydata.pro‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MOC_DIR = ../../temp
77

88
QT -= gui
99
QT += core
10-
CONFIG += console
10+
QT += testlib
1111

1212
include(../common.pri)
1313

‎gui/test/cppchecklibrarydata/testcppchecklibrarydata.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,4 +609,20 @@ void TestCppcheckLibraryData::saveCfgFile(const QString &filename, CppcheckLibra
609609
file.close();
610610
}
611611

612+
void TestCppcheckLibraryData::validateAllCfg()
613+
{
614+
const QDir dir(QString(SRCDIR) + "/../../../cfg/");
615+
const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files);
616+
QVERIFY(files.size() != 0);
617+
bool error = false;
618+
for (const QString& f : files) {
619+
loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result);
620+
if (!result.isNull()) {
621+
error = true;
622+
qDebug() << f << " - " << result;
623+
}
624+
}
625+
QCOMPARE(error, false);
626+
}
627+
612628
QTEST_MAIN(TestCppcheckLibraryData)

‎gui/test/cppchecklibrarydata/testcppchecklibrarydata.h‎

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)