Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kcov misses all lines except the last one in a multiline command substitution #164

Open
susam opened this issue Dec 1, 2016 · 0 comments
Labels

Comments

@susam
Copy link

susam commented Dec 1, 2016

Here is an example of a shell script that may be used to reproduce the issue.

echo "foo bar" |
sed "s/ /-/g"

a=$(echo "baz qux" |
    sed 's/ /-/g')

echo "$a"

Save the above code in a file, say foo.sh and execute the following command.

kcov coverage foo.sh

Since every line of the script was executed, the coverage result should show 100% coverage. But the coverage result shows that a=$(echo "baz qux" | was not executed.

Here is the output of the kcov command and the coverage result.

$ kcov coverage foo.sh
foo-bar
baz-qux
$ cat coverage/foo.sh/foo.sh.*.json
var data = {lines:[
{"lineNum":"    1","line":"echo \"foo bar\" |","class":"lineCov","hits":"2","order":"1","possible_hits":"0",},
{"lineNum":"    2","line":"sed \"s/ /-/g\"","class":"lineCov","hits":"2","order":"2","possible_hits":"0",},
{"lineNum":"    3","line":""},
{"lineNum":"    4","line":"a=$(echo \"baz qux\" |","class":"lineNoCov","hits":"0","possible_hits":"0",},
{"lineNum":"    5","line":"    sed \'s/ /-/g\')","class":"lineCov","hits":"4","order":"3","possible_hits":"0",},
{"lineNum":"    6","line":""},
{"lineNum":"    7","line":"echo \"$a\"","class":"lineCov","hits":"2","order":"4","possible_hits":"0",},
]};
var percent_low = 25;var percent_high = 75;
var header = { "command" : "foo.sh", "date" : "2016-12-01 20:58:49", "instrumented" : 5, "covered" : 4,};
var merged_data = [];

kcov-multiline-command-substitution

@susam susam changed the title 0 hits for lines in a multiline command substitution kcov misses all lines except the last one in a multiline command substitution Dec 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants