forked from NOAA-EMC/CICE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update coverage tool to manually filter some Fortran90 continuation l…
…ines (CICE-Consortium#604) * Update the coverage implementation. The gcov/lcov tool occasionally generates false negatives or incorrect statistics with respect to coverage for Fortran 90 continuation lines (using "&"). In some cases, within a single continuation block, some lines have hits which are correctly counted while other lines have misses which are incorrect and also counted. This seems to be partly associate with the lcov -a feature that we use to aggregate multiple tests, but it also probably is ultimately created by gcov because it doesn't seem to handle skipped vs missed lines entirely consistently. With this modification, --coverage creates a temporary sandbox where the tests are run. Prior to running the tests, lcov_modify_source.sh is invoked. " ! LCOV_EXCL_LINE" (a special defined string in lcov) is added to the end of some source code lines to request that gcov exclude them. The lines excluded are Fortran 90 continuation lines. In all cases the first and last line of a continuation block and lines that continue after an "if" are never excluded. This seems to improve the accuracy of the coverage output overall. Several other attempts were made to modify the lcov and geninfo perl scripts to handle the Fortran90 continuation line filtering there without success, so this solution was implemented. * update documentation
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
filelist=`find cicecore icepack -type f -name "*.F90"` | ||
LCOV_EXCL=" ! LCOV_EXCL_LINE" | ||
|
||
#echo $filelist | ||
|
||
for file in $filelist; do | ||
|
||
echo $file | ||
ofile=${file}.orig | ||
nfile=${file} | ||
|
||
mv ${file} ${file}.orig | ||
|
||
# line by line making sure each line has a trailing newline (-n) | ||
# preserve whitespace (IFS) | ||
# and include backslashes (-r) | ||
IFS='' | ||
contblock=0 | ||
cat $ofile | while read -r line || [[ -n $line ]]; do | ||
|
||
if [[ $contblock == 1 ]]; then | ||
# in a continuation block | ||
if [[ $line =~ ^.*"&".*$ ]]; then | ||
# found another continuation line, add exclude string and write out line | ||
echo ${line} ${LCOV_EXCL} >> ${nfile} | ||
else | ||
# continuation block ends, write out line | ||
contblock=0 | ||
echo ${line} >> ${nfile} | ||
fi | ||
else | ||
# not in a continuation block, write out line | ||
echo ${line} >> ${nfile} | ||
if [[ $line =~ ^\s*.*"&".*$ && ! $line =~ ^\s*( if ).*$ ]]; then | ||
# new continuation block found | ||
contblock=1 | ||
fi | ||
fi | ||
|
||
done | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters