infertux / bashcov

Code coverage tool for Bash
MIT License
151 stars 20 forks source link

Error with blank script #41

Closed CyberShadow closed 5 years ago

CyberShadow commented 5 years ago

Passing an empty file to bashcov causes it to crash with an exception:

~/tmp/2018-12-29b » bashcov /dev/null 
#<Thread:0x000055b65717d1e0@/home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/runner.rb:42 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
    4: from /home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/runner.rb:42:in `block (2 levels) in run'
    3: from /home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/xtrace.rb:94:in `read'
    2: from /home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/xtrace.rb:94:in `loop'
    1: from /home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/xtrace.rb:96:in `block in read'
/home/vladimir/.gem/ruby/2.5.0/gems/bashcov-1.8.0/lib/bashcov/xtrace.rb:121:in `parse_hit!': expected integer for LINENO, got "" (Bashcov::XtraceError)
bashcov: warning: encountered an error parsing Bash's output (error was: expected integer for LINENO, got ""). This can occur if your script or its path contains the sequence "67f53df5-ad00-4ad7-879f-e8a986e1c478", or if your script unsets LINENO. Aborting early; coverage report will be incomplete.
Run completed using bashcov 1.8.0 with Bash 4.4, Ruby 2.5.3, and SimpleCov 0.15.1.
Coverage report generated for /bin/bash /dev/null to /home/vladimir/tmp/2018-12-29b/coverage. 0.0 / 0.0 LOC (100.0%) covered.
tomeon commented 5 years ago

@CyberShadow -- TYVM for reporting this issue! I've got a fix pending in #42.

CyberShadow commented 5 years ago

Thanks! I was thinking of doing something like bashcov /dev/null to finalize / generate the HTML report as discussed in #40.