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
713 stars 109 forks source link

Parse correctly the tracing line of PS4 #304

Closed ko1nksm closed 5 years ago

ko1nksm commented 5 years ago

This PR fixes unexpected output to stderr when using --bash-method=PS4

[test.sh]

#!/bin/sh

a='line1\'\''
line2'

if [ "$a" ]; then
  :
fi
$ kcov /tmp/cover ./test.sh >/dev/null
line2'
line2' ']'

I think it works correctly but there is no test. I do not know where to write the test. How can I check if it is broken?

By the way, I found this problem during develop shellspec - new BDD testing framewrok for shell script. Unexpected output to stderr caused failure the tests via shellspec. I managed to integrate kcov using --bash-method=DEBUG (with workaround for #303). kcov is a great software! thanks!

codecov[bot] commented 5 years ago

Codecov Report

Merging #304 into master will increase coverage by 0.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   70.17%   70.18%   +0.01%     
==========================================
  Files          57       57              
  Lines        3701     3706       +5     
==========================================
+ Hits         2597     2601       +4     
- Misses       1104     1105       +1
Impacted Files Coverage Δ
src/engines/bash-engine.cc 88.96% <100%> (-0.16%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 588b209...971f199. Read the comment docs.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.01%) to 70.183% when pulling 971f199d616df47a835a96ede01e4a786a7f66ed on ko1nksm:parse_ps4_tracing_line into 588b209d59edd234bebbdf8273eae36497d27a47 on SimonKagstrom:master.

SimonKagstrom commented 5 years ago

OK, thanks a lot for the fix!

As for writing tests, the tests/tools directory contains the test suites. This should proabably go to the bash.py test file, and the example script itself added to a new file in tests/bash. To run the test suite, run tests/tools/run-tests and follow the on-screen usage (basically you need to point to where kcov was compiled and the kcov source directory).