Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measure code coverage of an executed shell script with kcov/shunit2

Is it possible to measure the code coverage of an executed shell script instead of a sourced one?

I have a shell script with a couple of switches, options. I have added a few tests and I want to measure the test suite's coverage.

Sources:

The script.

And its tests.

As you can see the tests.sh executes the shell script instead of calling its functions in the same shell. This way I couldn't get kcov to measure the coverage on the script. I was only able to measure the coverage on the file tests.sh.

Is it possible somehow to force kcov to measure the main script's coverage?

This command was the best I could achieve:

/usr/local/bin/kcov --debug=31 coverage/ test/tests.sh

And in the result I see only coverage report about shunit2 and tests.sh, but in the debug output I see references to misspell_fixer.sh as well. So I'm suspicious that it could work.

like image 707
Lajos Veres Avatar asked Oct 20 '22 20:10

Lajos Veres


1 Answers

Please submit a bug report to the kcov issue tracker,

https://github.com/SimonKagstrom/kcov

it should support this as far as I can tell. (I'm the author of Kcov).

like image 183
Simon Kågström Avatar answered Oct 22 '22 21:10

Simon Kågström