added handling of library element `entrypoint` to GUI / added GUI tests to CTest (#4744)
This commit is contained in:
parent
f16ffd88e9
commit
b097eca2ec
|
@ -250,8 +250,7 @@ jobs:
|
|||
pushd gui/test/filelist
|
||||
qmake CONFIG+=debug CONFIG+=ccache
|
||||
make -j$(nproc)
|
||||
# TODO: requires X session
|
||||
#./test-filelist
|
||||
./test-filelist
|
||||
popd
|
||||
pushd gui/test/projectfile
|
||||
qmake CONFIG+=debug CONFIG+=ccache
|
||||
|
@ -261,14 +260,13 @@ jobs:
|
|||
pushd gui/test/translationhandler
|
||||
qmake CONFIG+=debug CONFIG+=ccache
|
||||
make -j$(nproc)
|
||||
# TODO: requires X session
|
||||
# TODO: requires X session because of QApplication dependency in translationhandler.cpp
|
||||
#./test-translationhandler
|
||||
popd
|
||||
pushd gui/test/xmlreportv2
|
||||
qmake CONFIG+=debug CONFIG+=ccache
|
||||
make -j$(nproc)
|
||||
# TODO: requires X session
|
||||
#./test-xmlreportv2
|
||||
./test-xmlreportv2
|
||||
|
||||
- name: Generate Qt help file
|
||||
run: |
|
||||
|
|
|
@ -125,7 +125,7 @@ stage
|
|||
compile_commands.json
|
||||
|
||||
# qmake
|
||||
/gui/.qmake.stash
|
||||
.qmake.stash
|
||||
|
||||
#vs code
|
||||
/.vscode
|
||||
|
|
|
@ -43,6 +43,7 @@ option(ENABLE_OSS_FUZZ "Enable the OSS-Fuzz related targets"
|
|||
option(BUILD_GUI "Build the qt application" OFF)
|
||||
option(WITH_QCHART "Enable QtCharts usage in the GUI" OFF)
|
||||
option(USE_QT6 "Prefer Qt6 when available" OFF)
|
||||
option(REGISTER_GUI_TESTS "Register GUI tests in CTest" ON)
|
||||
|
||||
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
|
||||
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)
|
||||
|
|
|
@ -49,6 +49,7 @@ message( STATUS "ENABLE_OSS_FUZZ = ${ENABLE_OSS_FUZZ}" )
|
|||
message( STATUS )
|
||||
message( STATUS "BUILD_GUI = ${BUILD_GUI}" )
|
||||
if (BUILD_GUI)
|
||||
message( STATUS "REGISTER_GUI_TESTS = ${REGISTER_GUI_TESTS}" )
|
||||
message( STATUS "WITH_QCHART = ${WITH_QCHART}" )
|
||||
message( STATUS "USE_QT6 = ${USE_QT6}" )
|
||||
message( STATUS "QT_VERSION = ${QT_VERSION}")
|
||||
|
|
|
@ -446,6 +446,13 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
return markup;
|
||||
}
|
||||
|
||||
static CppcheckLibraryData::Entrypoint loadEntrypoint(QXmlStreamReader &xmlReader)
|
||||
{
|
||||
CppcheckLibraryData::Entrypoint entrypoint;
|
||||
entrypoint.name = xmlReader.attributes().value("name").toString();
|
||||
return entrypoint;
|
||||
}
|
||||
|
||||
QString CppcheckLibraryData::open(QIODevice &file)
|
||||
{
|
||||
clear();
|
||||
|
@ -486,6 +493,8 @@ QString CppcheckLibraryData::open(QIODevice &file)
|
|||
reflections.append(loadReflection(xmlReader));
|
||||
else if (elementName == "markup")
|
||||
markups.append(loadMarkup(xmlReader));
|
||||
else if (elementName == "entrypoint")
|
||||
entrypoints.append(loadEntrypoint(xmlReader));
|
||||
else
|
||||
unhandledElement(xmlReader);
|
||||
} catch (std::runtime_error &e) {
|
||||
|
@ -918,6 +927,12 @@ QString CppcheckLibraryData::toString() const
|
|||
writeMarkup(xmlWriter, mup);
|
||||
}
|
||||
|
||||
for (const Entrypoint &ent : entrypoints) {
|
||||
xmlWriter.writeStartElement("entrypoint");
|
||||
xmlWriter.writeAttribute("name", ent.name);
|
||||
xmlWriter.writeEndElement();
|
||||
}
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
return outputString;
|
||||
|
|
|
@ -238,6 +238,10 @@ public:
|
|||
bool unique;
|
||||
};
|
||||
|
||||
struct Entrypoint {
|
||||
QString name;
|
||||
};
|
||||
|
||||
void clear() {
|
||||
containers.clear();
|
||||
defines.clear();
|
||||
|
@ -250,6 +254,7 @@ public:
|
|||
platformTypes.clear();
|
||||
reflections.clear();
|
||||
markups.clear();
|
||||
entrypoints.clear();
|
||||
}
|
||||
|
||||
void swap(CppcheckLibraryData &other) {
|
||||
|
@ -264,6 +269,7 @@ public:
|
|||
platformTypes.swap(other.platformTypes);
|
||||
reflections.swap(other.reflections);
|
||||
markups.swap(other.markups);
|
||||
entrypoints.swap(other.entrypoints);
|
||||
}
|
||||
|
||||
QString open(QIODevice &file);
|
||||
|
@ -280,6 +286,7 @@ public:
|
|||
QList<struct SmartPointer> smartPointers;
|
||||
QList<struct Reflection> reflections;
|
||||
QList<struct Markup> markups;
|
||||
QList<struct Entrypoint> entrypoints;
|
||||
};
|
||||
|
||||
#endif // CPPCHECKLIBRARYDATA_H
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
qt_wrap_cpp(test-cppchecklibrarydata_SRC testcppchecklibrarydata.h)
|
||||
add_custom_target(build-cppchecklibrarydata-deps SOURCES ${test-cppchecklibrarydata_SRC})
|
||||
QT_ADD_RESOURCES(test-cppchecklibrarydata_resources "resources.qrc")
|
||||
add_custom_target(build-cppchecklibrarydata-deps SOURCES ${test-cppchecklibrarydata_SRC} ${test-cppchecklibrarydata_resources})
|
||||
add_dependencies(gui-build-deps build-cppchecklibrarydata-deps)
|
||||
add_executable(test-cppchecklibrarydata
|
||||
${test-cppchecklibrarydata_SRC}
|
||||
${test-cppchecklibrarydata_resources}
|
||||
testcppchecklibrarydata.cpp
|
||||
${CMAKE_SOURCE_DIR}/gui/cppchecklibrarydata.cpp
|
||||
)
|
||||
target_include_directories(test-cppchecklibrarydata PRIVATE ${CMAKE_SOURCE_DIR}/gui)
|
||||
target_compile_definitions(test-cppchecklibrarydata PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_link_libraries(test-cppchecklibrarydata ${QT_CORE_LIB} ${QT_TEST_LIB})
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Q_UNUSED() in generated code
|
||||
target_compile_options_safe(test-cppchecklibrarydata -Wno-extra-semi-stmt)
|
||||
endif()
|
||||
|
||||
if (REGISTER_GUI_TESTS)
|
||||
add_test(NAME test-cppchecklibrarydata COMMAND $<TARGET_FILE:test-cppchecklibrarydata>)
|
||||
endif()
|
|
@ -7,7 +7,7 @@ MOC_DIR = ../../temp
|
|||
|
||||
QT -= gui
|
||||
QT += core
|
||||
CONFIG += console
|
||||
QT += testlib
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
|
|
|
@ -609,4 +609,20 @@ void TestCppcheckLibraryData::saveCfgFile(const QString &filename, CppcheckLibra
|
|||
file.close();
|
||||
}
|
||||
|
||||
void TestCppcheckLibraryData::validateAllCfg()
|
||||
{
|
||||
const QDir dir(QString(SRCDIR) + "/../../../cfg/");
|
||||
const QStringList files = dir.entryList(QStringList() << "*.cfg",QDir::Files);
|
||||
QVERIFY(files.size() != 0);
|
||||
bool error = false;
|
||||
for (const QString& f : files) {
|
||||
loadCfgFile(dir.absolutePath() + "/" + f, fileLibraryData, result);
|
||||
if (!result.isNull()) {
|
||||
error = true;
|
||||
qDebug() << f << " - " << result;
|
||||
}
|
||||
}
|
||||
QCOMPARE(error, false);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestCppcheckLibraryData)
|
||||
|
|
|
@ -41,6 +41,8 @@ private slots:
|
|||
void markupValid();
|
||||
void containerValid();
|
||||
|
||||
void validateAllCfg();
|
||||
|
||||
private:
|
||||
static void loadCfgFile(const QString &filename, CppcheckLibraryData &data, QString &res, bool removeFile = false);
|
||||
static void saveCfgFile(const QString &filename, CppcheckLibraryData &data);
|
||||
|
|
|
@ -18,3 +18,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
# Q_UNUSED() in generated code
|
||||
target_compile_options_safe(test-filelist -Wno-extra-semi-stmt)
|
||||
endif()
|
||||
|
||||
if (REGISTER_GUI_TESTS)
|
||||
add_test(NAME test-filelist COMMAND $<TARGET_FILE:test-filelist>)
|
||||
endif()
|
|
@ -4,6 +4,9 @@ DEPENDPATH += .
|
|||
INCLUDEPATH += . ../../../externals/simplecpp
|
||||
OBJECTS_DIR = ../../temp
|
||||
MOC_DIR = ../../temp
|
||||
|
||||
QT -= gui
|
||||
QT += core
|
||||
QT += testlib
|
||||
|
||||
include(../common.pri)
|
||||
|
|
|
@ -82,7 +82,7 @@ void TestFileList::addDirectory() const
|
|||
FileList list;
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files");
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 7);
|
||||
QCOMPARE(files.size(), 9);
|
||||
}
|
||||
|
||||
void TestFileList::addDirectory_recursive() const
|
||||
|
@ -90,7 +90,7 @@ void TestFileList::addDirectory_recursive() const
|
|||
FileList list;
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 10);
|
||||
QCOMPARE(files.size(), 12);
|
||||
QDir dir(QString(SRCDIR) + "/../data/files");
|
||||
QString base = dir.canonicalPath();
|
||||
QVERIFY(files.contains(base + "/dir1/foo1.cpp"));
|
||||
|
@ -129,7 +129,7 @@ void TestFileList::filterFiles2() const
|
|||
list.addExcludeList(filters);
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files");
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 5);
|
||||
QCOMPARE(files.size(), 7);
|
||||
QDir dir(QString(SRCDIR) + "/../data/files");
|
||||
QString base = dir.canonicalPath();
|
||||
QVERIFY(!files.contains(base + "/foo1.cpp"));
|
||||
|
@ -144,7 +144,7 @@ void TestFileList::filterFiles3() const
|
|||
list.addExcludeList(filters);
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 6);
|
||||
QCOMPARE(files.size(), 8);
|
||||
QDir dir(QString(SRCDIR) + "/../data/files");
|
||||
QString base = dir.canonicalPath();
|
||||
QVERIFY(!files.contains(base + "/foo1.cpp"));
|
||||
|
@ -161,14 +161,14 @@ void TestFileList::filterFiles4() const
|
|||
list.addExcludeList(filters);
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 8);
|
||||
QCOMPARE(files.size(), 10);
|
||||
QDir dir(QString(SRCDIR) + "/../data/files");
|
||||
QString base = dir.canonicalPath();
|
||||
QVERIFY(!files.contains(base + "/dir1/foo1.cpp"));
|
||||
QVERIFY(!files.contains(base + "/dir1/dir11/foo11.cpp"));
|
||||
}
|
||||
/*
|
||||
void TestFileList::filterFiles5()
|
||||
|
||||
void TestFileList::filterFiles5() const
|
||||
{
|
||||
FileList list;
|
||||
QStringList filters;
|
||||
|
@ -176,11 +176,11 @@ void TestFileList::filterFiles4() const
|
|||
list.addExcludeList(filters);
|
||||
list.addDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||
QStringList files = list.getFileList();
|
||||
QCOMPARE(files.size(), 8);
|
||||
QCOMPARE(files.size(), 10);
|
||||
QDir dir(QString(SRCDIR) + "/../data/files");
|
||||
QString base = dir.canonicalPath();
|
||||
QVERIFY(!files.contains(base + "/dir1/foo1.cpp"));
|
||||
QVERIFY(!files.contains(base + "/dir1/dir11/foo11.cpp"));
|
||||
}
|
||||
*/
|
||||
|
||||
QTEST_MAIN(TestFileList)
|
||||
|
|
|
@ -32,4 +32,5 @@ private slots:
|
|||
void filterFiles2() const;
|
||||
void filterFiles3() const;
|
||||
void filterFiles4() const;
|
||||
void filterFiles5() const;
|
||||
};
|
||||
|
|
|
@ -14,3 +14,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
# Q_UNUSED() in generated code
|
||||
target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt)
|
||||
endif()
|
||||
|
||||
if (REGISTER_GUI_TESTS)
|
||||
add_test(NAME test-projectfile COMMAND $<TARGET_FILE:test-projectfile>)
|
||||
endif()
|
|
@ -4,9 +4,10 @@ DEPENDPATH += .
|
|||
INCLUDEPATH += . ../../../externals/simplecpp ../../../externals/tinyxml2 ../../../externals/picojson
|
||||
OBJECTS_DIR = ../../temp
|
||||
MOC_DIR = ../../temp
|
||||
|
||||
QT -= gui
|
||||
QT += core
|
||||
CONFIG += console
|
||||
QT += testlib
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
|
|
|
@ -12,5 +12,10 @@ target_link_libraries(test-translationhandler ${QT_CORE_LIB} ${QT_WIDGETS_LIB} $
|
|||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Q_UNUSED() in generated code
|
||||
target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt)
|
||||
target_compile_options_safe(test-translationhandler -Wno-extra-semi-stmt)
|
||||
endif()
|
||||
|
||||
if (REGISTER_GUI_TESTS)
|
||||
# TODO: requires X session
|
||||
#add_test(NAME test-translationhandler COMMAND $<TARGET_FILE:test-translationhandler>)
|
||||
endif()
|
|
@ -4,7 +4,11 @@ DEPENDPATH += .
|
|||
INCLUDEPATH += .
|
||||
OBJECTS_DIR = ../../temp
|
||||
MOC_DIR = ../../temp
|
||||
QT += widgets
|
||||
|
||||
QT -= gui
|
||||
QT += core
|
||||
QT += widgets # TODO: get rid of this - causes X server dependency
|
||||
QT += testlib
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
|
|
|
@ -28,3 +28,7 @@ if (BUILD_CORE_DLL)
|
|||
target_compile_definitions(test-xmlreportv2 PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
|
||||
target_link_libraries(test-xmlreportv2 cppcheck-core)
|
||||
endif()
|
||||
|
||||
if (REGISTER_GUI_TESTS)
|
||||
add_test(NAME test-xmlreportv2 COMMAND $<TARGET_FILE:test-xmlreportv2>)
|
||||
endif()
|
||||
|
|
|
@ -5,6 +5,10 @@ INCLUDEPATH += . ../../../externals/simplecpp
|
|||
OBJECTS_DIR = ../../temp
|
||||
MOC_DIR = ../../temp
|
||||
|
||||
QT -= gui
|
||||
QT += core
|
||||
QT += testlib
|
||||
|
||||
include(../common.pri)
|
||||
include(../../../lib/lib.pri)
|
||||
|
||||
|
|
Loading…
Reference in New Issue