Skip to content

Commit cc24d6f

Browse files
authored
Fix #9162 (Invalid --project files do not give any error) (danmar#3177)
1 parent bb327be commit cc24d6f

15 files changed

Lines changed: 347 additions & 87 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,59 @@ jobs:
156156
if: contains(matrix.os, 'ubuntu')
157157
run: |
158158
pushd gui
159-
qmake HAVE_QCHART=yes
159+
qmake CONFIG+=debug HAVE_QCHART=yes
160160
make -j$(nproc)
161161
162162
- name: Run GUI tests on ubuntu
163163
if: contains(matrix.os, 'ubuntu')
164164
run: |
165+
pushd gui/test/cppchecklibrarydata
166+
qmake CONFIG+=debug
167+
make -j$(nproc)
168+
./test-cppchecklibrarydata
169+
popd
170+
pushd gui/test/filelist
171+
qmake CONFIG+=debug
172+
make -j$(nproc)
173+
# TODO: requires X session
174+
#./test-filelist
175+
popd
165176
pushd gui/test/projectfile
166-
qmake
177+
qmake CONFIG+=debug
167178
make -j$(nproc)
168179
./test-projectfile
169180
popd
170-
pushd gui/test/cppchecklibrarydata
171-
qmake
181+
pushd gui/test/translationhandler
182+
qmake CONFIG+=debug
172183
make -j$(nproc)
173-
./test-cppchecklibrarydata
184+
# TODO: requires X session
185+
#./test-translationhandler
186+
popd
187+
pushd gui/test/xmlreportv2
188+
qmake CONFIG+=debug
189+
make -j$(nproc)
190+
# TODO: requires X session
191+
#./test-xmlreportv2
174192
175193
- name: Generate Qt help file on ubuntu
176194
if: contains(matrix.os, 'ubuntu')
177195
run: |
178196
pushd gui/help
179197
qhelpgenerator online-help.qhcp -o online-help.qhc
180198
199+
- name: Build triage on ubuntu
200+
if: matrix.os == 'ubuntu-20.04'
201+
run: |
202+
pushd tools/triage
203+
qmake CONFIG+=debug
204+
make -j$(nproc)
205+
206+
- name: Build Fuzzer
207+
if: matrix.os == 'ubuntu-20.04'
208+
run: |
209+
pushd oss-fuzz
210+
make -j$(nproc) CXX=clang++ CXXFLAGS="-fsanitize=address" fuzz-client translate
211+
181212
- name: Self check (build)
182213
if: matrix.os == 'ubuntu-20.04'
183214
run: |
@@ -196,18 +227,4 @@ jobs:
196227
mkdir b2
197228
./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
198229
# self check test and tools
199-
./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
200-
201-
- name: Build triage on ubuntu
202-
if: matrix.os == 'ubuntu-20.04'
203-
run: |
204-
pushd tools/triage
205-
qmake
206-
make -j$(nproc)
207-
208-
- name: Build Fuzzer
209-
if: matrix.os == 'ubuntu-20.04'
210-
run: |
211-
pushd oss-fuzz
212-
make -j$(nproc) CXX=clang++ CXXFLAGS="-fsanitize=address" fuzz-client translate
213-
230+
./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

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ gui/cppcheck-gui
5858
gui/cppcheck-gui.exe
5959
gui/gui.sln
6060
gui/gui.vcproj
61+
gui/help/online-help.qch
62+
gui/help/online-help.qhc
6163
gui/Makefile
6264
gui/Makefile.debug
6365
gui/Makefile.release
@@ -66,11 +68,11 @@ gui/test/Makefile
6668
gui/test/*/Makefile
6769
gui/test/*/*/Makefile
6870
gui/test/benchmark/simple/benchmark-simple
71+
gui/test/cppchecklibrarydata/qrc_resources.cpp
72+
gui/test/cppchecklibrarydata/test-cppchecklibrarydata
6973
gui/test/filelist/test-filelist
7074
gui/test/projectfile/test-projectfile
7175
gui/test/translationhandler/test-translationhandler
72-
gui/test/xmlreport/test-xmlreport
73-
gui/test/xmlreportv1/test-xmlreportv1
7476
gui/test/xmlreportv2/test-xmlreportv2
7577

7678
# Doxygen output folder

.travis_suppressions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ useStlAlgorithm
1111
simplifyUsing:lib/valueptr.h
1212
symbolDatabaseWarning:gui/temp/moc_*.cpp
1313
simplifyUsing:gui/temp/moc_*.cpp
14+
symbolDatabaseWarning:tools/triage/moc_*.cpp
1415

1516
# debug suppressions
1617
valueFlowBailout

cli/cmdlineparser.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,17 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
644644
}
645645
}
646646
if (projType == ImportProject::Type::MISSING) {
647-
printError("failed to open project '" + projectFile + "'.");
647+
printError("failed to open project '" + projectFile + "'. The file does not exist.");
648648
return false;
649649
}
650650
if (projType == ImportProject::Type::UNKNOWN) {
651651
printError("failed to load project '" + projectFile + "'. The format is unknown.");
652652
return false;
653653
}
654+
if (projType == ImportProject::Type::FAILURE) {
655+
printError("failed to load project '" + projectFile + "'. An error occurred.");
656+
return false;
657+
}
654658
}
655659

656660
// --project-configuration

gui/main.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ int main(int argc, char *argv[])
4848

4949
QApplication app(argc, argv);
5050

51-
#if QT_VERSION < 0x050000
52-
// Set codecs so that UTF-8 strings in sources are handled correctly.
53-
// This is ONLY needed for Qt versions 4.x.
54-
// Qt 5.x assumes UTF-8 by default.
55-
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
56-
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
57-
#endif
58-
5951
QCoreApplication::setOrganizationName("Cppcheck");
6052
QCoreApplication::setApplicationName("Cppcheck-GUI");
6153

gui/test/filelist/filelist.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ SOURCES += testfilelist.cpp \
1515
../../filelist.cpp \
1616
../../../lib/pathmatch.cpp \
1717
../../../lib/path.cpp \
18+
../../../lib/utils.cpp \
1819
../../../externals/simplecpp/simplecpp.cpp
1920

2021
HEADERS += testfilelist.h \
2122
../../filelist.h \
2223
../../../lib/pathmatch.h \
2324
../../../lib/path.h \
25+
../../../lib/utils.h \
2426
../../../externals/simplecpp/simplecpp.h
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TEMPLATE = app
22
TARGET = test-projectfile
33
DEPENDPATH += .
4-
INCLUDEPATH += . ../../../externals/simplecpp
4+
INCLUDEPATH += . ../../../externals/simplecpp ../../../externals/tinyxml2 ../../../externals/picojson
55
OBJECTS_DIR = ../build
66
MOC_DIR = ../build
77
QT -= gui
@@ -14,11 +14,8 @@ DEFINES += SRCDIR=\\\"$$PWD\\\"
1414

1515
# tests
1616
SOURCES += testprojectfile.cpp \
17-
../../projectfile.cpp \
18-
../../../lib/path.cpp \
19-
../../../externals/simplecpp/simplecpp.cpp
17+
../../projectfile.cpp
2018

2119
HEADERS += testprojectfile.h \
2220
../../projectfile.h \
23-
../../../lib/path.h \
24-
../../../externals/simplecpp/simplecpp.h
21+
../../../externals/picojson/picojson.h

gui/test/projectfile/testprojectfile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Settings::Settings() : maxCtuDepth(10), maxTemplateRecursion(100) {}
3131
cppcheck::Platform::Platform() {}
3232
Library::Library() {}
3333
ImportProject::ImportProject() {}
34+
bool ImportProject::sourceFileExists(const std::string &/*file*/) { return true; }
3435

3536
void TestProjectFile::loadInexisting()
3637
{

gui/test/translationhandler/translationhandler.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ QT += widgets
99
include(../common.pri)
1010

1111
# tests
12-
SOURCES += testtranslationhandler.cpp
12+
SOURCES += testtranslationhandler.cpp \
13+
../../translationhandler.cpp \
14+
../../common.cpp
1315

14-
HEADERS += testtranslationhandler.h
16+
HEADERS += testtranslationhandler.h \
17+
../../translationhandler.h \
18+
../../common.h

gui/test/xmlreportv2/xmlreportv2.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TEMPLATE = app
22
TARGET = test-xmlreportv2
33
DEPENDPATH += .
4-
INCLUDEPATH += . ../../../externals/simplecpp ../../../externals/tinyxml
4+
INCLUDEPATH += . ../../../externals/simplecpp
55
OBJECTS_DIR = ../build
66
MOC_DIR = ../build
77

0 commit comments

Comments
 (0)