diff --git a/scripts/codecoverage.sh b/scripts/codecoverage.sh index b87a307..4750c65 100755 --- a/scripts/codecoverage.sh +++ b/scripts/codecoverage.sh @@ -3,16 +3,18 @@ # @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" -eq "1" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT + +#trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" -eq "1" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIRNAME="${SRCDIR##*/}" +SOURCE_DIR=$PWD +PRO_FILE=$(find . -d 1 -type f -name "*.pro") -BUILDPATH=$SRCDIR"/../build/testcc" -COVERAGE_DIR=$SRCDIR"/../build/testcc-info" -SOURCE_CODE=$SRCDIR"/.." -HTML_RESULTS_DIR=$SRCDIR"/../build/testcc-html" -COVERAGE_FILTER="*Qt*.framework* *Xcode.app* *.moc *moc_*.cpp */test/* *qrc_* ui_* */invsdk/* *qt.headers */build/* *main*.* *c++*" +BUILDPATH=$SOURCE_DIR"/../build/testcc" +COVERAGE_DIR=$SOURCE_DIR"/../build/testcc-info" +HTML_RESULTS_DIR=$SOURCE_DIR"/../build/testcc-html" +COVERAGE_FILTER="*Qt*.framework* *Xcode.app* *.moc *moc_*.cpp */test/* *qrc_* ui_* *qt.headers */build/* *main*.* *c++* */server-sdk/*" main() { @@ -33,12 +35,25 @@ function setup() { function testcc() { + if [ ! -d src ]; then + fail "src dir does not exists" + else + pass "src dir exits" + fi + if [ ! -f $PRO_FILE ]; then + fail ".pro file does not exists: " $PRO_FILE + else + pass ".pro file: " $PRO_FILE + fi + + + info "Creating: $BUILDPATH" mkdir -p $BUILDPATH cd $BUILDPATH info "Generate makefile with coverage option" - qmake $SOURCE_CODE/server-sdk.pro "QMAKE_CXXFLAGS += --coverage" "QMAKE_LFLAGS += --coverage" + qmake $SOURCE_DIR/$PRO_FILE "QMAKE_CXXFLAGS += --coverage" "QMAKE_LFLAGS += --coverage" info "Remove previous *.gcda files" find $BUILDPATH -name *.gcda -exec rm "{}" \; @@ -55,7 +70,7 @@ function testcc() { echo "Build : $BUILDPATH" echo "Makeflags : $MAKEFLAGS" echo "COVERAGE_DIR : $COVERAGE_DIR" - echo "SOURCE_CODE : $SOURCE_CODE" + echo "SOURCE_DIR : $SOURCE_DIR" echo "HTML_RESULTS_DIR : $HTML_RESULTS_DIR" echo "COVERAGE_FILTER : $COVERAGE_FILTER" echo "--------------------" diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index b373266..74a8ab6 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -5,15 +5,22 @@ set -e trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" -eq "1" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT -SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -DIRNAME="${SRCDIR##*/}" +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DIRNAME="${CURRENT_DIR##*/}" +SOURCE_DIR=$PWD exclude_dir=build -check_dir=$SRCDIR/../src +check_dir=$CURRENT_DIR/../src suppress="--suppress=missingInclude --suppress=unusedFunction" FAIL=0 main() { + if [ ! -d src ]; then + fail "src dir does not exists" + else + pass "src dir exits" + fi + { ERROR="$( { cppcheck $check_dir $suppress --enable=all -i $exclude_dir; } 2>&1 1>&3 3>&- )"; } 3>&1; if [ ! -z "$ERROR" ]; then diff --git a/scripts/doc.sh b/scripts/doc.sh index bab8d2a..1949268 100755 --- a/scripts/doc.sh +++ b/scripts/doc.sh @@ -8,13 +8,18 @@ trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR_NAME="${CURRENT_DIR##*/}" - FAIL=0 -SOURCE_DIR=$CURRENT_DIR"/.." +SOURCE_DIR=$PWD BUILD_DIR=$SOURCE_DIR"/build" DOC_DIR=$BUILD_DIR"/doc" main() { + if [ ! -d src ]; then + fail "src dir does not exists" + else + pass "src dir exits" + fi + doc "$@" }