Skip to content

Commit bc814f2

Browse files
committed
Tests should run under both git and p4
Signed-off-by: Henry Cox <[email protected]>
1 parent 6dc0bba commit bc814f2

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

tests/gendiffcov/errs/msgtest.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,22 @@ if [ -f $LCOV_HOME/scripts/getp4version ] ; then
108108
else
109109
SCRIPTS_DIR=$LCOV_HOME/share/lcov/support-scripts
110110
fi
111-
GET_VERSION=$SCRIPTS_DIR/getp4version
112111
SELECT_SCRIPT=$SCRIPTS_DIR/select.pm
113112
CRITERIA_SCRIPT=$SCRIPTS_DIR/criteria.pm
114-
ANNOTATE_SCRIPT=$SCRIPTS_DIR/p4annotate.pm
115113
GITBLAME_SCRIPT=$SCRIPTS_DIR/gitblame.pm
116114
GITVERSION_SCRIPT=$SCRIPTS_DIR/gitversion.pm
117115

116+
# is this git or P4?
117+
git -C . rev-parse > /dev/null 2>&1
118+
if [ 0 == $? ] ; then
119+
# this is git
120+
VERSION_SCRIPT=${SCRIPTS_DIR}/gitversion.pm
121+
ANNOTATE_SCRIPT=${SCRIPTS_DIR}/gitblame.pm
122+
else
123+
VERSION_SCRIPT=${SCRIPTS_DIR}/getp4version
124+
ANNOTATE_SCRIPT=${SCRIPTS_DIR}/p4annotate.pm
125+
fi
126+
118127

119128
# filter out the compiler-generated _GLOBAL__sub_... symbol
120129
LCOV_BASE="$EXTRA_GCOV_OPTS --branch-coverage $PARALLEL $PROFILE --no-external --ignore unused,unsupported --erase-function .*GLOBAL.*"
@@ -374,8 +383,8 @@ if [ 0 != $? ] ; then
374383
fi
375384
# and again, as a differential report with annotation
376385
NOW=`date`
377-
echo genhtml $DIFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $SCRIPTS_DIR/p4annotate --baseline-file initial.info
378-
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $SCRIPTS_DIR/p4annotate --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix 2>&1 | tee select_scr.log
386+
echo genhtml $DIFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT --baseline-file initial.info
387+
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix 2>&1 | tee select_scr.log
379388
if [ 0 != ${PIPESTATUS[0]} ] ; then
380389
echo "ERROR: genhtml select failed"
381390
if [ 0 == $KEEP_GOING ] ; then
@@ -385,8 +394,8 @@ fi
385394
386395
# differntial report with empty diff file
387396
touch diff.txt
388-
echo genhtml $DIFCOV_OPTS initial.info -o empty --diff diff.txt --annotate $SCRIPTS_DIR/p4annotate --baseline-file initial.info
389-
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o empty --diff diff.txt --annotate $SCRIPTS_DIR/p4annotate --baseline-file initial.info 2>&1 | tee empty_diff.log
397+
echo genhtml $DIFCOV_OPTS initial.info -o empty --diff diff.txt --annotate $ANNOTATE_SCTIPT --baseline-file initial.info
398+
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o empty --diff diff.txt --annotate $ANNOTATE_SCRIPT --baseline-file initial.info 2>&1 | tee empty_diff.log
390399
if [ 0 == ${PIPESTATUS[0]} ] ; then
391400
echo "ERROR: genhtml select failed"
392401
if [ 0 == $KEEP_GOING ] ; then
@@ -465,8 +474,10 @@ if [ 0 != $? ] ; then
465474
fi
466475
467476
# resolve
468-
echo lcov $LCOV_OPTS --summary initial.info --rc case_insensitive=1 --resolve ./genError.pm
469-
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --rc case_insensitive=1 --resolve ./genError.pm 2>&1 | tee resolve_err.log
477+
# apply substitution to ensure that the file is not found so the resolve callback
478+
# is called
479+
echo lcov $LCOV_OPTS --summary initial.info --rc case_insensitive=1 --filter branch --resolve ./genError.pm --substitute s/test.cpp/noSuchFile.cpp/i
480+
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --rc case_insensitive=1 --filter branch --resolve ./genError.pm --substitute s/test.cpp/noSuchFile.cpp/i 2>&1 | tee resolve_err.log
470481
if [ 0 == ${PIPESTATUS[0]} ] ; then
471482
echo "ERROR: lcov --summary resolve"
472483
if [ 0 == $KEEP_GOING ] ; then

tests/gendiffcov/simple/script.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ git -C . rev-parse > /dev/null 2>&1
114114
if [ 0 == $? ] ; then
115115
# this is git
116116
GET_VERSION=${SCRIPT_DIR}/gitversion.pm
117-
P4ANNOTATE=${SCRIPT_DIR}/gitblame.pm
117+
GET_VERSION_EXE=${SCRIPT_DIR}/gitversion
118+
ANNOTATE=${SCRIPT_DIR}/gitblame.pm
118119
else
119120
GET_VERSION=${SCRIPT_DIR}/getp4version
120-
P4ANNOTATE=${SCRIPT_DIR}/p4annotate.pm
121+
GET_VERSION_EXE=${SCRIPT_DIR}/getp4version
122+
ANNOTATE=${SCRIPT_DIR}/p4annotate.pm
121123
fi
122124
CRITERIA=${SCRIPT_DIR}/criteria
123125
SELECT=${SCRIPT_DIR}/select.pm
@@ -257,7 +259,7 @@ if [ 0 != $? ] ; then
257259
fi
258260
# run again with version script options passed in string
259261
# test filter with differing version
260-
$COVER $LCOV_TOOL $EXTRA_GCOV_OPTS --branch-coverage --version-script "$GET_VERSION --md5 --allow-missing" $PARALLEL $PROFILE --output filt2.info --filter branch,line -a baseline2.info $IGNORE
262+
$COVER $LCOV_TOOL $EXTRA_GCOV_OPTS --branch-coverage --version-script "$GET_VERSION_EXE --md5 --allow-missing" $PARALLEL $PROFILE --output filt2.info --filter branch,line -a baseline2.info $IGNORE
261263
if [ 0 == $? ] ; then
262264
echo "ERROR: filter with mismatched version did not fail"
263265
status=1
@@ -272,7 +274,7 @@ if [ -e filt2.info ] ; then
272274
exit 1
273275
fi
274276
fi
275-
$COVER $LCOV_TOOL $EXTRA_GCOV_OPTS --branch-coverage --version-script "$GET_VERSION --md5 --allow-missing" $PARALLEL $PROFILE --output filt2.info --filter branch,line -a baseline2.info $IGNORE --ignore version
277+
$COVER $LCOV_TOOL $EXTRA_GCOV_OPTS --branch-coverage --version-script "$GET_VERSION_EXE --md5 --allow-missing" $PARALLEL $PROFILE --output filt2.info --filter branch,line -a baseline2.info $IGNORE --ignore version
276278
if [ 0 != $? ] ; then
277279
echo "ERROR: ignore error filter with combined opts and mismatched version failed"
278280
status=1
@@ -1304,19 +1306,19 @@ if [ 0 != $? ] ; then
13041306
exit 1
13051307
fi
13061308
fi
1307-
echo genhtml $DIFFCOV_OPTS --output-directory ./annotate --annotate $P4ANNOTATE annotate.info
1308-
$COVER $GENHTML_TOOL $DIFFCOV_OPTS --output-directory ./annotate --annotate $P4ANNOTATE annotate.info
1309+
echo genhtml $DIFFCOV_OPTS --output-directory ./annotate --annotate $ANNOTATE annotate.info
1310+
$COVER $GENHTML_TOOL $DIFFCOV_OPTS --output-directory ./annotate --annotate $ANNOTATE annotate.info
13091311
if [ 0 == $? ] ; then
1310-
echo "ERROR: p4annotate with no annotation"
1312+
echo "ERROR: annotate with no annotation"
13111313
status=1
13121314
if [ 0 == $KEEP_GOING ] ; then
13131315
exit 1
13141316
fi
13151317
fi
1316-
echo genhtml $DIFFCOV_OPTS --output-directory ./annotate --annotate $P4ANNOTATE
1317-
$COVER $GENHTML_TOOL $DIFFCOV_OPTS --output-directory ./annotate --annotate $P4ANNOTATE --ignore annotate annotate.info
1318+
echo genhtml $DIFFCOV_OPTS --output-directory ./annotate --annotate $ANNOTATE
1319+
$COVER $GENHTML_TOOL $DIFFCOV_OPTS --output-directory ./annotate --annotate $ANNOTATE --ignore annotate annotate.info
13181320
if [ 0 != $? ] ; then
1319-
echo "ERROR: p4annotate with no annotation ignore did not pass"
1321+
echo "ERROR: annotate with no annotation ignore did not pass"
13201322
status=1
13211323
if [ 0 == $KEEP_GOING ] ; then
13221324
exit 1
@@ -1379,7 +1381,7 @@ if [ "x$COVER" != "x" ] ; then
13791381
if [ 0 != $LOCAL_COVERAGE ] ; then
13801382
cover $COVER_DB
13811383
${LCOV_HOME}/bin/perl2lcov -o perlcov.info --testname simple --version-script $GET_VERSION $COVER_DB
1382-
${LCOV_HOME}/bin/genhtml -o html_report perlcov.info pycov.info --branch --flat --show-navigation --show-proportion --version-script $GET_VERSION --annotate-script $P4ANNOTATE --parallel --ignore empty,usage
1384+
${LCOV_HOME}/bin/genhtml -o html_report perlcov.info pycov.info --branch --flat --show-navigation --show-proportion --version-script $GET_VERSION --annotate-script $ANNOTATE --parallel --ignore empty,usage
13831385
echo "see HTML report 'html_report'"
13841386
else
13851387
echo cp pycov.info $COVER_DB/spreadsheet.info

0 commit comments

Comments
 (0)