From 2b0977d2ee975454207f94e518f54329b8a2d391 Mon Sep 17 00:00:00 2001 From: Henry Cox Date: Fri, 10 Jan 2025 12:44:03 -0500 Subject: [PATCH] Testcase portability: default to git unless obviously p4 Signed-off-by: Henry Cox --- tests/common.tst | 12 ++++++++---- tests/lcov/extract/extract.sh | 2 +- tests/lcov/mcdc/mcdc.sh | 6 +++--- tests/py2lcov/py2lcov.sh | 10 +++++----- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/common.tst b/tests/common.tst index 4509982..8437376 100644 --- a/tests/common.tst +++ b/tests/common.tst @@ -135,15 +135,19 @@ git -C . rev-parse > /dev/null 2>&1 if [ 0 == $? ] ; then # this is git IS_GIT=1 - USE_GIT=1 - GET_VERSION=${SCRIPT_DIR}/gitversion.pm - GET_VERSION_EXE=${SCRIPT_DIR}/gitversion - ANNOTATE=${SCRIPT_DIR}/gitblame.pm else p4 have ... > /dev/null 2>&1 if [ 0 == $? ] ; then IS_P4=1 fi +fi + +if [ "$IS_GIT" == 1 ] || [ "$IS_P4" == 0 ] ; then + USE_GIT=1 + GET_VERSION=${SCRIPT_DIR}/gitversion.pm + GET_VERSION_EXE=${SCRIPT_DIR}/gitversion + ANNOTATE=${SCRIPT_DIR}/gitblame.pm +else USE_P4=1 GET_VERSION=${SCRIPT_DIR}/getp4version GET_VERSION_EXE=${SCRIPT_DIR}/getp4version diff --git a/tests/lcov/extract/extract.sh b/tests/lcov/extract/extract.sh index e4902a2..575351d 100755 --- a/tests/lcov/extract/extract.sh +++ b/tests/lcov/extract/extract.sh @@ -248,7 +248,7 @@ if [ 0 != $? ] ; then exit 1 fi fi -grep -E "#.*user:.+$USER" context_comment.info +grep "#user: $USER" context_comment.info if [ 0 != $? ] ; then echo "Error: did not find context data in comment field" if [ $KEEP_GOING == 0 ] ; then diff --git a/tests/lcov/mcdc/mcdc.sh b/tests/lcov/mcdc/mcdc.sh index 0b9cd2a..27ba3c0 100755 --- a/tests/lcov/mcdc/mcdc.sh +++ b/tests/lcov/mcdc/mcdc.sh @@ -11,11 +11,11 @@ if [[ 1 == $CLEAN_ONLY ]] ; then fi # is this git or P4? -if [ 1 == "$USE_GIT" ] ; then +if [ 1 == "$USE_P4" ] ; then + GET_VERSION=${SCRIPT_DIR}/P4version.pm,--local-edit,--md5 +else # this is git GET_VERSION=${SCRIPT_DIR}/gitversion.pm -else - GET_VERSION=${SCRIPT_DIR}/P4version.pm,--local-edit,--md5 fi diff --git a/tests/py2lcov/py2lcov.sh b/tests/py2lcov/py2lcov.sh index 69959c4..7b8aa43 100755 --- a/tests/py2lcov/py2lcov.sh +++ b/tests/py2lcov/py2lcov.sh @@ -24,14 +24,14 @@ if [ ! -f $LCOV_HOME/scripts/getp4version ] ; then MD5_OPT=',--md5' fi # is this git or P4? -if [ 1 == "$USE_GIT" ] ; then - # this is git - VERSION="--version-script ${SCRIPT_DIR}/gitversion${MD5_OPT}" - ANNOTATE="--annotate-script ${SCRIPT_DIR}/gitblame.pm,--cache,my_cache" -else +if [ 1 == "$IS_P4" ] ; then VERSION="--version-script ${SCRIPT_DIR}/P4version.pm,--local-edit${MD5_OPT}" ANNOTATE="--annotate-script ${SCRIPT_DIR}/p4annotate.pm,--cache,./my_cache" DEPOT=",." +else + # this is git + VERSION="--version-script ${SCRIPT_DIR}/gitversion${MD5_OPT}" + ANNOTATE="--annotate-script ${SCRIPT_DIR}/gitblame.pm,--cache,my_cache" fi if [ $IS_GIT == 0 ] && [ $IS_P4 == 0 ] ; then