diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 9dd2daf94..f6e390f5b 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -100,6 +100,23 @@ jobs: cd 'cpp check/test/cli' pytest test-*.py + # fails on macos since some includes (e.g. sys/epoll.h) are not available + - name: Run cfg tests + if: contains(matrix.os, 'ubuntu') + run: | + make -j$(nproc) checkcfg + + # it seems macos has no "wc" command + - name: Run showtimetop5 tests + if: contains(matrix.os, 'ubuntu') + run: | + ./tools/test_showtimetop5.sh + + - name: Run --dump test + run: | + ./cppcheck test/testpreprocessor.cpp --dump + xmllint --noout test/testpreprocessor.cpp.dump + - name: Validate run: | make -j$(nproc) checkCWEEntries validateXML diff --git a/.github/workflows/scriptcheck.yml b/.github/workflows/scriptcheck.yml index 2639e5633..664f84f11 100644 --- a/.github/workflows/scriptcheck.yml +++ b/.github/workflows/scriptcheck.yml @@ -21,17 +21,22 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install missing software on ubuntu + run: | + sudo apt-get update + sudo apt-get install tidy libxml2-utils + - name: Install missing software on ubuntu (Python 2) if: matrix.python-version == '2.7' run: | python -m pip install pip --upgrade python -m pip install pytest + python -m pip install pygments - name: Install missing software on ubuntu (Python 3) if: matrix.python-version != '2.7' run: | - sudo apt-get update - sudo apt-get install shellcheck libxml2-utils + sudo apt-get install shellcheck python -m pip install pip --upgrade python -m pip install natsort python -m pip install pexpect @@ -81,10 +86,21 @@ jobs: run: | python tools/test_matchcompiler.py - - name: test addons + - name: build cppcheck run: | make -j$(nproc) -s - PYTHONPATH=./addons python -m pytest addons/test/test-*.py + + - name: test addons + run: | + python -m pytest addons/test/test-*.py + env: + PYTHONPATH: ./addons + + - name: test htmlreport + run: | + htmlreport/test_htmlreport.py + cd htmlreport + ./check.sh - name: dmake if: matrix.python-version == '3.9' diff --git a/.travis.yml b/.travis.yml index a63e94a21..4fe087e48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,15 +45,6 @@ matrix: compiler: clang script: - make -j$(nproc) -s - # check cfg files - - make checkcfg -# check htmlreport stuff - - python2 htmlreport/test_htmlreport.py - - python3 htmlreport/test_htmlreport.py - - cd htmlreport - - PYTHON=python2 ./check.sh - - PYTHON=python3 ./check.sh - - cd ../ # check if DESTDIR works TODO: actually execute this - mkdir install_test - echo $CXXFLAGS @@ -65,12 +56,7 @@ matrix: - make -s MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck -j$(nproc) - sudo make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck install # check if it actually works: - - /usr/bin/cppcheck ./cli -# check if showtime=top5 works - - ./tools/test_showtimetop5.sh -# check --dump - - ${CPPCHECK} test/testpreprocessor.cpp --dump - - xmllint --noout test/testpreprocessor.cpp.dump + - /usr/bin/cppcheck -j$(nproc) ./cli # check addons/misc.py - cd addons/test - ${CPPCHECK} --dump misc-test.cpp @@ -132,8 +118,6 @@ matrix: script: # fail the entire job as soon as one of the subcommands exits non-zero to save time and resources - set -e -# Determine CPU count. As of January 2019 it seems to be 2 - so use this for job count in suitable calls to make or cppcheck - - cat /proc/cpuinfo # check with TEST_MATHLIB_VALUE enabled - touch lib/mathlib.cpp test/testmathlib.cpp - echo $CXXFLAGS diff --git a/htmlreport/check.sh b/htmlreport/check.sh index 3734c2a2e..44be21688 100755 --- a/htmlreport/check.sh +++ b/htmlreport/check.sh @@ -1,22 +1,23 @@ #!/bin/bash -ex # Command for checking HTML syntax with HTML Tidy, see http://www.html-tidy.org/ -# newer tidy (5.6.0) command, if using this it is not necessary to ignore warnings: -#tidy_cmd='tidy -o /dev/null -eq --drop-empty-elements no' -# older tidy from 2009 (Ubuntu 16.04 Xenial comes with this old version): -tidy_cmd='tidy -o /dev/null -eq' +tidy_version=$(tidy --version) + +if [[ "$tidy_version" == *"5.6.0"* ]] ;then + # newer tidy (5.6.0) command, if using this it is not necessary to ignore warnings: + tidy_cmd='tidy -o /dev/null -eq --drop-empty-elements no' +else + # older tidy from 2009 (Ubuntu 16.04 Xenial comes with this old version): + tidy_cmd='tidy -o /dev/null -eq' +fi function validate_html { if [ ! -f "$1" ]; then echo "File $1 does not exist!" - exit 1 + exit 1 fi - set +e - ${tidy_cmd} "$1" - tidy_status=$? - set -e - if [ $tidy_status -eq 2 ]; then - echo "HTML does not validate!" + if ! ${tidy_cmd} "$1"; then + echo "HTML validation failed!" exit 1 fi } diff --git a/tools/test_showtimetop5.sh b/tools/test_showtimetop5.sh index 02c6aaaf6..99677225c 100755 --- a/tools/test_showtimetop5.sh +++ b/tools/test_showtimetop5.sh @@ -1,4 +1,6 @@ #!/bin/bash -if [[ "$(./cppcheck --showtime=top5 cli/cmdlineparser.h --language=c++ --quiet | wc -l)" != 7 ]] ; then +output=$(./cppcheck --showtime=top5 cli/cmdlineparser.h --language=c++ --quiet) +echo "$output" +if [[ "$(echo "$output" | wc -l)" != 7 ]] ; then false fi