I have a problem getting code coverage to work with shellspec
I have a directory at $HOME/work/hello
It’s contents are as followed:
hello
|______ hello.sh
|______ spec
|______ hello_spec.sh
hello.sh
looks like this:
echo hello
spec/hello_spec.sh
looks like this:
Describe 'spec for my test'
It 'says hello'
When call ./hello.sh
The output should eq "hello"
End
End
In $HOME/work/hello
I then execute
shellspec --shell bash -f d --kcov --kcov-options="--include-pattern=$(pwd)/hello.sh"
To my understanding, this launches shellspec with bash selected as my shell, and using a formatter aliased by d
. --kcov
then enables kcov integration (which I have installed), and kcov-options
should then pass --include-pattern
to point at my script hello.sh
The output shows that the test has executed and passed, yet kcov reports 0% coverage.
14:24:01 ❯ shellspec --shell bash -f d --kcov --kcov-options="--include-pattern=hello.sh"
Running: /usr/bin/bash [bash 5.1.16(1)-release]
spec for my test
says hello
Finished in 0.12 seconds (user 0.10 seconds, sys 0.02 seconds)
1 example, 0 failures
Code covered: 0.00%, Executed lines: 0, Instrumented lines: 1
When I open $HOME/work/hello/coverage/index.html
I can see that kcov succesfully recognized my hello.sh
file.
It reads the line echo hello
, but it reports no coverage.
What am I doing wrong?
I have tried the pattern without $(PWD)
, and I have also tried When call $(PWD)/hello.sh
to ensure the paths exactly match.
For reference, when I run kcov coverage hello.sh
kcov reports 100% coverage just fine.