forked from ondra/server-sdk
added cppcheck script
This commit is contained in:
parent
b36238fc6d
commit
735f4c294e
@ -48,4 +48,4 @@ cppcheck:
|
||||
- shell # spaceti-runner server has running runners and one has tag 'hw'
|
||||
# allow_failure: true
|
||||
script: # run in bash
|
||||
- cppcheck src --suppress=missingIncludeSystem --suppress=unusedFunction --enable=all -i build --error-exitcode=100
|
||||
- scripts/cppcheck.sh
|
||||
|
||||
46
scripts/cppcheck.sh
Executable file
46
scripts/cppcheck.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
||||
set -e
|
||||
|
||||
trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ $FAIL == 1 ]; then fail finished with error; exit 1; else pass "finished all";fi' EXIT
|
||||
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
DIRNAME="${SRCDIR##*/}"
|
||||
|
||||
exclude_dir=build
|
||||
check_dir=$SRCDIR/../src
|
||||
|
||||
main() {
|
||||
FAIL=0;
|
||||
RESULT=$(cppcheck $check_dir --quiet --suppress=missingIncludeSystem --suppress=unusedFunction --enable=all -i $exclude_dir 2>&1)
|
||||
|
||||
if [ ! -z "$RESULT" ]; then
|
||||
echo "$RESULT"
|
||||
fail "Cppcheck finished with error"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# ################
|
||||
# Output funcitons
|
||||
# ################
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
function info () {
|
||||
echo -e "[${BLUE} $@ ${NC}]"
|
||||
}
|
||||
|
||||
function pass() {
|
||||
echo -e "[${GREEN}PASS${NC}] $@"
|
||||
}
|
||||
|
||||
function fail() {
|
||||
FAIL=1; echo -e "[${RED}FAIL${NC}] $@"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Loading…
x
Reference in New Issue
Block a user