Skip to content

Commit

Permalink
Fix #9162 (Invalid --project files do not give any error) (danmar#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Dec 19, 2021
1 parent bb327be commit cc24d6f
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 87 deletions.
57 changes: 37 additions & 20 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,59 @@ jobs:
if: contains(matrix.os, 'ubuntu')
run: |
pushd gui
qmake HAVE_QCHART=yes
qmake CONFIG+=debug HAVE_QCHART=yes
make -j$(nproc)
- name: Run GUI tests on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
pushd gui/test/cppchecklibrarydata
qmake CONFIG+=debug
make -j$(nproc)
./test-cppchecklibrarydata
popd
pushd gui/test/filelist
qmake CONFIG+=debug
make -j$(nproc)
# TODO: requires X session
#./test-filelist
popd
pushd gui/test/projectfile
qmake
qmake CONFIG+=debug
make -j$(nproc)
./test-projectfile
popd
pushd gui/test/cppchecklibrarydata
qmake
pushd gui/test/translationhandler
qmake CONFIG+=debug
make -j$(nproc)
./test-cppchecklibrarydata
# TODO: requires X session
#./test-translationhandler
popd
pushd gui/test/xmlreportv2
qmake CONFIG+=debug
make -j$(nproc)
# TODO: requires X session
#./test-xmlreportv2
- name: Generate Qt help file on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
pushd gui/help
qhelpgenerator online-help.qhcp -o online-help.qhc
- name: Build triage on ubuntu
if: matrix.os == 'ubuntu-20.04'
run: |
pushd tools/triage
qmake CONFIG+=debug
make -j$(nproc)
- name: Build Fuzzer
if: matrix.os == 'ubuntu-20.04'
run: |
pushd oss-fuzz
make -j$(nproc) CXX=clang++ CXXFLAGS="-fsanitize=address" fuzz-client translate
- name: Self check (build)
if: matrix.os == 'ubuntu-20.04'
run: |
Expand All @@ -196,18 +227,4 @@ jobs:
mkdir b2
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --cppcheck-build-dir=b2 -D__CPPCHECK__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings gui/*.cpp gui/temp/*.cpp
# self check test and tools
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings test/*.cpp tools
- name: Build triage on ubuntu
if: matrix.os == 'ubuntu-20.04'
run: |
pushd tools/triage
qmake
make -j$(nproc)
- name: Build Fuzzer
if: matrix.os == 'ubuntu-20.04'
run: |
pushd oss-fuzz
make -j$(nproc) CXX=clang++ CXXFLAGS="-fsanitize=address" fuzz-client translate
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings test/*.cpp tools
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ gui/cppcheck-gui
gui/cppcheck-gui.exe
gui/gui.sln
gui/gui.vcproj
gui/help/online-help.qch
gui/help/online-help.qhc
gui/Makefile
gui/Makefile.debug
gui/Makefile.release
Expand All @@ -66,11 +68,11 @@ gui/test/Makefile
gui/test/*/Makefile
gui/test/*/*/Makefile
gui/test/benchmark/simple/benchmark-simple
gui/test/cppchecklibrarydata/qrc_resources.cpp
gui/test/cppchecklibrarydata/test-cppchecklibrarydata
gui/test/filelist/test-filelist
gui/test/projectfile/test-projectfile
gui/test/translationhandler/test-translationhandler
gui/test/xmlreport/test-xmlreport
gui/test/xmlreportv1/test-xmlreportv1
gui/test/xmlreportv2/test-xmlreportv2

# Doxygen output folder
Expand Down
1 change: 1 addition & 0 deletions .travis_suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ useStlAlgorithm
simplifyUsing:lib/valueptr.h
symbolDatabaseWarning:gui/temp/moc_*.cpp
simplifyUsing:gui/temp/moc_*.cpp
symbolDatabaseWarning:tools/triage/moc_*.cpp

# debug suppressions
valueFlowBailout
Expand Down
6 changes: 5 additions & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,17 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
}
}
if (projType == ImportProject::Type::MISSING) {
printError("failed to open project '" + projectFile + "'.");
printError("failed to open project '" + projectFile + "'. The file does not exist.");
return false;
}
if (projType == ImportProject::Type::UNKNOWN) {
printError("failed to load project '" + projectFile + "'. The format is unknown.");
return false;
}
if (projType == ImportProject::Type::FAILURE) {
printError("failed to load project '" + projectFile + "'. An error occurred.");
return false;
}
}

// --project-configuration
Expand Down
8 changes: 0 additions & 8 deletions gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ int main(int argc, char *argv[])

QApplication app(argc, argv);

#if QT_VERSION < 0x050000
// Set codecs so that UTF-8 strings in sources are handled correctly.
// This is ONLY needed for Qt versions 4.x.
// Qt 5.x assumes UTF-8 by default.
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif

QCoreApplication::setOrganizationName("Cppcheck");
QCoreApplication::setApplicationName("Cppcheck-GUI");

Expand Down
2 changes: 2 additions & 0 deletions gui/test/filelist/filelist.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ SOURCES += testfilelist.cpp \
../../filelist.cpp \
../../../lib/pathmatch.cpp \
../../../lib/path.cpp \
../../../lib/utils.cpp \
../../../externals/simplecpp/simplecpp.cpp

HEADERS += testfilelist.h \
../../filelist.h \
../../../lib/pathmatch.h \
../../../lib/path.h \
../../../lib/utils.h \
../../../externals/simplecpp/simplecpp.h
9 changes: 3 additions & 6 deletions gui/test/projectfile/projectfile.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = test-projectfile
DEPENDPATH += .
INCLUDEPATH += . ../../../externals/simplecpp
INCLUDEPATH += . ../../../externals/simplecpp ../../../externals/tinyxml2 ../../../externals/picojson
OBJECTS_DIR = ../build
MOC_DIR = ../build
QT -= gui
Expand All @@ -14,11 +14,8 @@ DEFINES += SRCDIR=\\\"$$PWD\\\"

# tests
SOURCES += testprojectfile.cpp \
../../projectfile.cpp \
../../../lib/path.cpp \
../../../externals/simplecpp/simplecpp.cpp
../../projectfile.cpp

HEADERS += testprojectfile.h \
../../projectfile.h \
../../../lib/path.h \
../../../externals/simplecpp/simplecpp.h
../../../externals/picojson/picojson.h
1 change: 1 addition & 0 deletions gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Settings::Settings() : maxCtuDepth(10), maxTemplateRecursion(100) {}
cppcheck::Platform::Platform() {}
Library::Library() {}
ImportProject::ImportProject() {}
bool ImportProject::sourceFileExists(const std::string &/*file*/) { return true; }

void TestProjectFile::loadInexisting()
{
Expand Down
8 changes: 6 additions & 2 deletions gui/test/translationhandler/translationhandler.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ QT += widgets
include(../common.pri)

# tests
SOURCES += testtranslationhandler.cpp
SOURCES += testtranslationhandler.cpp \
../../translationhandler.cpp \
../../common.cpp

HEADERS += testtranslationhandler.h
HEADERS += testtranslationhandler.h \
../../translationhandler.h \
../../common.h
2 changes: 1 addition & 1 deletion gui/test/xmlreportv2/xmlreportv2.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = test-xmlreportv2
DEPENDPATH += .
INCLUDEPATH += . ../../../externals/simplecpp ../../../externals/tinyxml
INCLUDEPATH += . ../../../externals/simplecpp
OBJECTS_DIR = ../build
MOC_DIR = ../build

Expand Down
Loading

0 comments on commit cc24d6f

Please sign in to comment.