SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
709 stars 109 forks source link

Bash: heredoc and arrays are not correctly covered #457

Closed beatussum closed 1 month ago

beatussum commented 1 month ago

Description

In bash, if a heredoc has space between the tag and <<[-], the lines of the string are not covered.

Same thing with arrays if they are not defined oneline.

It occurs also with functions in subshells like:

foo() (
    echo "bar"
)

Example

Example

SimonKagstrom commented 1 month ago

Thanks for the clear test!

This, and other bash parsing issues, should really be handled by #145 , but I don't really have any timeframe for that. I mostly (almost only) use kcov for compiled code myself, so the bash support is sort of neglected by me.

beatussum commented 1 month ago

Currently, the following has been fixed (it's not perfect and other issues risk to occur):

SimonKagstrom commented 1 month ago

Thanks a lot for these! I'm closing this issue.

Another note is that there is also a basic parser for bash scripts, which can be used if the default parser goes astray, so I'm not to worried about additional issues.