From 0cfd60aa34c2b57ca76e8e375654348d8ffde334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 4 Jan 2014 11:37:03 +0100 Subject: [PATCH 1/8] travis: rewrite config file. Uses CXXFLAGS -O2 instead of default flags to speed up self checking. Testing is done with the following settings: 1) gcc CXXFLAGS=-O2 2) gcc CXXFLAGS=-O2 SRCDIR=build VERIFY=1 3) gcc CXXFLAGS=-O2 MAKEFLAGS="HAVE_RULES=yes" 4) gcc CXXFLAGS=-O2 SRCDIR=build VERIFY=1 MAKEFLAGS="HAVE_RULES=yes" 5) clang CXXFLAGS=-O2 6) clang CXXFLAGS=-O2 SRCDIR=build VERIFY=1 7) clang CXXFLAGS=-O2 MAKEFLAGS="HAVE_RULES=yes" 8) clang CXXFLAGS=-O2 SRCDIR=build VERIFY=1 MAKEFLAGS="HAVE_RULES=yes" Changes made to before_install: installe libpcre3 Changes made to script: * make and make test are now called seperately * cppcheck also checks "build" folder (created by SRCDIR=build) if existing. * gui is built twice, one time with HAVE_RULES=yes as qmake argument and one time without it. * a script has been added and run which returns false if cppcheck --showtime=top5 does not return 7 lines indicating that something is broken --- .travis.yml | 41 ++++++++++++++++++++++++++++++-------- tools/test_showtimetop5.sh | 4 ++++ 2 files changed, 37 insertions(+), 8 deletions(-) create mode 100755 tools/test_showtimetop5.sh diff --git a/.travis.yml b/.travis.yml index f2ec8afe3..9c8bfcc38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,30 +2,55 @@ language: cpp compiler: - gcc - clang +env: + global: +# unfortunately we need this to stay within 50min timelimit given by travis. +# this also turns off the debug/warning cxxflags + - CXXFLAGS=-O2 + matrix: + - MAKEFLAGS="HAVE_RULES=yes" SRCDIR=build VERIFY=1 + - SRCDIR=build VERIFY=1 + - MAKEFLAGS="HAVE_RULES=yes" + - before_install: +# install needed deps - sudo apt-get update -qq - - sudo apt-get install -qq python-pygments libqt4-core libqt4-gui libqt4-dev qt4-dev-tools qt4-qmake libxml2-utils + - sudo apt-get install -qq python-pygments libqt4-core libqt4-gui libqt4-dev qt4-dev-tools qt4-qmake libxml2-utils libpcre3 script: - - mkdir build - - make test SRCDIR=build VERIFY=1 -j 4 - - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppress=duplicateBranch cli gui lib -igui/test +# compile cppcheck, default build + - make -j4 + - make test -j4 + - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppress=duplicateBranch cli gui lib build -igui/test +# compile gui - cd gui - qmake - - make -j 4 + - make -j4 + - git clean -dfx . +# can't set this as env flags, so try again with HAVE_RULES=yes + - qmake HAVE_RULES=yes + - make -j4 - cd ../ +# check htmlreport stuff - ./htmlreport/test_htmlreport.py - cd htmlreport - ./check.sh - cd ../ +# check if DESTDIR works TODO: actually execute this - mkdir install_test - make DESTDIR=install_test install - - make clean - - make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg HAVE_RULES=yes -j 4 - - sudo make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg HAVE_RULES=yes install +# rm everything + - git clean -dfx +# check what happens if we want to install it to some other dir, + - make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg -j 4 + - sudo make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg install - sudo mkdir -p /usr/share/cppcheck/cfg - sudo install -D ./cfg/* -t /usr/share/cppcheck/cfg +# check if it actually works: - /usr/bin/cppcheck ./cli +# check if reduce tool compiles - make reduce -j 4 +# check if showtime=top5 works + - ./tools/test_showtimetop5.sh notifications: irc: channels: diff --git a/tools/test_showtimetop5.sh b/tools/test_showtimetop5.sh new file mode 100755 index 000000000..cd051837c --- /dev/null +++ b/tools/test_showtimetop5.sh @@ -0,0 +1,4 @@ +#!/bin/bash +if [[ "`./cppcheck --showtime=top5 cli/cmdlineparser.h --quiet | wc -l`" != 7 ]] ; then + false +fi From 8ae3df3249351e32f51f81458f79ce9f72860287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 6 Jan 2014 19:03:45 +0100 Subject: [PATCH 2/8] travis: use suppression list to suppress warnings. --- .travis.yml | 2 +- .travis_suppressions | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .travis_suppressions diff --git a/.travis.yml b/.travis.yml index 9c8bfcc38..06618fe11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: # compile cppcheck, default build - make -j4 - make test -j4 - - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppress=duplicateBranch cli gui lib build -igui/test + - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions cli gui lib build -igui/test # compile gui - cd gui - qmake diff --git a/.travis_suppressions b/.travis_suppressions new file mode 100644 index 000000000..3e314b88e --- /dev/null +++ b/.travis_suppressions @@ -0,0 +1,4 @@ +uselessAssignmentPtrArg:build/checkstl.cpp +assertWithSideEffect:build/checkuninitvar.cpp +duplicateBranch:build/checkunusedvar.cpp +duplicateBranch:lib/checkunusedvar.cpp From 21a2c4e4688f4484dbae22c09a340897d484d31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 6 Jan 2014 18:15:21 +0100 Subject: [PATCH 3/8] travis: also check "test" directory while ignoring test.cxx --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 06618fe11..18e557da8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: # compile cppcheck, default build - make -j4 - make test -j4 - - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions cli gui lib build -igui/test + - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions cli gui lib build test -igui/test -itest/test.cxx # compile gui - cd gui - qmake From e049a44f6396706280cbf7beda9c8069547a0500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 7 Jan 2014 06:41:27 +0100 Subject: [PATCH 4/8] travis: check cfg files with xmllint. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 18e557da8..5544dc015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,8 @@ script: - make reduce -j 4 # check if showtime=top5 works - ./tools/test_showtimetop5.sh +# check the files in cgf dir with xmllint + - xmllint --noout cfg/* notifications: irc: channels: From 73b7276ae9f3f659a3fa74ec4a72cc6dd132fa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 8 Jan 2014 01:44:17 +0100 Subject: [PATCH 5/8] travis: fail if Makefile is not up to date (check via dmake). --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5544dc015..b96009897 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,12 @@ script: - ./tools/test_showtimetop5.sh # check the files in cgf dir with xmllint - xmllint --noout cfg/* +# check if Makefile needs to be regenerated + - git clean -dfx + - make dmake + - ./dmake +# now, if dmake modified the makefile, return false! + - git diff --exit-code notifications: irc: channels: From e1a5487c70412f796ca810504df119654b639600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 9 Jan 2014 22:46:26 +0100 Subject: [PATCH 6/8] travis: let cppcheck check most of the repo, but suppress files/warnings that we don't care about via suppression file. --- .travis.yml | 2 +- .travis_suppressions | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b96009897..bdb77e223 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: # compile cppcheck, default build - make -j4 - make test -j4 - - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions cli gui lib build test -igui/test -itest/test.cxx + - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions . # compile gui - cd gui - qmake diff --git a/.travis_suppressions b/.travis_suppressions index 3e314b88e..0a647d8a6 100644 --- a/.travis_suppressions +++ b/.travis_suppressions @@ -1,4 +1,14 @@ uselessAssignmentPtrArg:build/checkstl.cpp assertWithSideEffect:build/checkuninitvar.cpp duplicateBranch:build/checkunusedvar.cpp -duplicateBranch:lib/checkunusedvar.cpp +duplicateBranch:lib/checkunusedvar.cpp +*:gui/test* +*:test/test.cxx + +*:democlient* +*:externals* +*:htdocs* +*:htmlreport* +*:samples* +*:tools* +*:win_installer* From 962018b722c6a9a70bbe16aaab2ecf61371efcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 12 Jan 2014 12:34:05 +0100 Subject: [PATCH 7/8] revert: commit f6da9d4e3c2f889be5202b1cbcc159ec3ff9a37b "testcmdlineparser: comment out unused functions fileListStdin(), ignorepaths{1-4}(), ignorefilepaths{1,2}()" instead suppress the files. also suppress unused variable in test/testpreprocessor.cpp --- .travis_suppressions | 2 + test/testcmdlineparser.cpp | 104 ++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/.travis_suppressions b/.travis_suppressions index 0a647d8a6..c38ec4d4c 100644 --- a/.travis_suppressions +++ b/.travis_suppressions @@ -2,6 +2,8 @@ uselessAssignmentPtrArg:build/checkstl.cpp assertWithSideEffect:build/checkuninitvar.cpp duplicateBranch:build/checkunusedvar.cpp duplicateBranch:lib/checkunusedvar.cpp +unusedPrivateFunction:test/testcmdlineparser.cpp +unreadVariable:test/testpreprocessor.cpp *:gui/test* *:test/test.cxx diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 63c83a621..866bed350 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -925,63 +925,63 @@ private: ASSERT_EQUALS(false, parser.ParseFromArgs(2, argv)); ASSERT_EQUALS(0, parser.GetIgnoredPaths().size()); } - /* - void ignorepaths1() { - REDIRECT; - const char *argv[] = {"cppcheck", "-isrc", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); - } - void ignorepaths2() { - REDIRECT; - const char *argv[] = {"cppcheck", "-i", "src", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(4, argv)); - ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); - } + void ignorepaths1() { + REDIRECT; + const char *argv[] = {"cppcheck", "-isrc", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); + } - void ignorepaths3() { - REDIRECT; - const char *argv[] = {"cppcheck", "-isrc", "-imodule", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(4, argv)); - ASSERT_EQUALS(2, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); - ASSERT_EQUALS("module/", parser.GetIgnoredPaths()[1]); - } + void ignorepaths2() { + REDIRECT; + const char *argv[] = {"cppcheck", "-i", "src", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(4, argv)); + ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); + } - void ignorepaths4() { - REDIRECT; - const char *argv[] = {"cppcheck", "-i", "src", "-i", "module", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(6, argv)); - ASSERT_EQUALS(2, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); - ASSERT_EQUALS("module/", parser.GetIgnoredPaths()[1]); - } + void ignorepaths3() { + REDIRECT; + const char *argv[] = {"cppcheck", "-isrc", "-imodule", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(4, argv)); + ASSERT_EQUALS(2, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); + ASSERT_EQUALS("module/", parser.GetIgnoredPaths()[1]); + } - void ignorefilepaths1() { - REDIRECT; - const char *argv[] = {"cppcheck", "-ifoo.cpp", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("foo.cpp", parser.GetIgnoredPaths()[0]); - } + void ignorepaths4() { + REDIRECT; + const char *argv[] = {"cppcheck", "-i", "src", "-i", "module", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(6, argv)); + ASSERT_EQUALS(2, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("src/", parser.GetIgnoredPaths()[0]); + ASSERT_EQUALS("module/", parser.GetIgnoredPaths()[1]); + } + + void ignorefilepaths1() { + REDIRECT; + const char *argv[] = {"cppcheck", "-ifoo.cpp", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("foo.cpp", parser.GetIgnoredPaths()[0]); + } + + void ignorefilepaths2() { + REDIRECT; + const char *argv[] = {"cppcheck", "-isrc/foo.cpp", "file.cpp"}; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); + ASSERT_EQUALS("src/foo.cpp", parser.GetIgnoredPaths()[0]); + } - void ignorefilepaths2() { - REDIRECT; - const char *argv[] = {"cppcheck", "-isrc/foo.cpp", "file.cpp"}; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(1, parser.GetIgnoredPaths().size()); - ASSERT_EQUALS("src/foo.cpp", parser.GetIgnoredPaths()[0]); - } - */ void checkconfig() { REDIRECT; const char *argv[] = {"cppcheck", "--check-config", "file.cpp"}; From edf44d2509727f3605d1df364d5e7a84cd51e69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 12 Jan 2014 16:30:14 +0100 Subject: [PATCH 8/8] travis: check the repo with cppcheck after building gui. --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bdb77e223..7145b048e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,15 @@ script: # compile cppcheck, default build - make -j4 - make test -j4 - - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions . # compile gui - cd gui - qmake - make -j4 +# building gui generates some more files that cppcheck can check, so check the repo *after* building gui + - cd ../ + - ./cppcheck --error-exitcode=1 -Ilib --enable=style --suppressions-list=.travis_suppressions . + - cd ./gui +# clean rebuild - git clean -dfx . # can't set this as env flags, so try again with HAVE_RULES=yes - qmake HAVE_RULES=yes