expected integer for LINENO, got "\\${LINENO-}"
Description
Running bashcov as non-root with the following command line:
bashcov -- ./main/idmdoctor export -l admin -u http://idmui.vmware:50000 -d ~/tmp/export/
This results in the following error/stacktrace:
#<Thread:0x00005a56a42613a8 /var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/runner.rb:63 run> terminated with exception (report_on_exception is true):
/var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/xtrace.rb:126:in `parse_hit!': expected integer for LINENO, got "\\\\${LINENO-}" (Bashcov::XtraceError)
from /var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/xtrace.rb:96:in `block in read'
from /var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/xtrace.rb:93:in `loop'
from /var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/xtrace.rb:93:in `read'
from /var/lib/gems/3.0.0/gems/bashcov-3.1.3/lib/bashcov/runner.rb:63:in `block (2 levels) in run'
The program under test continues to run and coverage reports are generated, but the resulting bashcov report content is evidently incorrect. From the program under test's MAIN function, coverage is only correct until after the first subfunction call (DO_LOAD_BOOTSTRAP). Everything following this function call is reported as uncovered, which is not plausible.
Here's a screenshot of the coverage report from MAIN:
An interesting side note is that this bug seems to depend on the program under test. In exactly the same environment, when testing a different program, e.g.
bashcov -- ./main/smoke ~/tmp/export/
the exception does not occur and the coverage report looks absolutely plausible.
Environment
Ubuntu 22.04
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
bashcov 3.1.3 (via gem install bashcov)
GNU bash, Version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Not sure if related but there is a similiar problem in kcov: https://github.com/SimonKagstrom/kcov/issues/478
This is duplicate/related to #86 ?
@boskamp Getting ${LINENO-} is normal behavior when the line is missed, however I don't understand why it's being escaped as \\${LINENO-} in your case. Can you share a bit more about what the DO_LOAD_BOOTSTRAP function does? Does it call the set command such as set -x or similar?
@boskamp Getting
${LINENO-}is normal behavior when the line is missed, however I don't understand why it's being escaped as\\${LINENO-}in your case. Can you share a bit more about what theDO_LOAD_BOOTSTRAPfunction does? Does it call thesetcommand such asset -xor similar?
DO_LOAD_BOOTSTRAP sources a bunch of other script files containing function and global variable definitions, but it doesn't contain any set command. Here's the full source code:
DO_LOAD_BOOTSTRAP() {
local BOOTSTRAP_DIR="$ME_DIR/bootstrap"
for f in "$BOOTSTRAP_DIR"/*; do
source "$f"
done
}