infertux / bashcov

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

[BUG] Coverage fails with "excepted integer for LINENO" #86

Closed dalisoft closed 2 months ago

dalisoft commented 5 months ago

Actual Result

BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753407168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168_start_color
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753337168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168is_terminal
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753517168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168'[' -t 1 ']'
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753337168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168echo -en ''
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753417168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168'[' 0 -gt 0 ']'
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753457168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168/bin/cat
Overall result: SUCCESS+BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753227168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168true
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753247168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168echo -en ' \u2713 '
 \u2713 +BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753477168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168_stop_color
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753367168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168is_terminal
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753517168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168'[' -t 1 ']'
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753367168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168echo -en ''
BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366753967168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168echo

BASHCOV>7168c1ca-8bcd-41bf-bdbc-2e7eac8366755737168c1ca-8bcd-41bf-bdbc-2e7eac836675./bash_unit7168exit 0
+ bashcov: warning: encountered an error parsing Bash's output (error was: expected integer for LINENO, got "uname -m\n51W"). This can occur if your script or its path contains the sequence "7168c1ca-8bcd-41bf-bdbc-2e7eac836675", or if your script unsets LINENO. Aborting early; coverage report will be incomplete.
Run completed using bashcov 3.1.2 with Bash 3.2, Ruby 3.3.2, and SimpleCov 0.22.0
Coverage report generated for /bin/bash ./bash_unit tests/cli/core.test.sh tests/cli/no-git.test.sh tests/gpg-sign/git-gpg-sign.test.sh tests/plugins/changelog.test.sh tests/plugins/docker.test.sh tests/plugins/git.test.sh tests/plugins/github-release.test.sh tests/plugins/npm-post.test.sh tests/plugins/npm.test.sh tests/plugins/template.test.sh tests/presets/conventional-commits.test.sh tests/presets/workspace.cargo-undefined.test.sh tests/presets/workspace.cargo.test.sh tests/presets/workspace.nodejs-undefined.test.sh tests/presets/workspace.nodejs.test.sh tests/presets/workspace.python-undefined.test.sh tests/presets/workspace.python.test.sh tests/presets/workspace.undefined.test.sh to /Users/dalisoft/Desktop/open_source/bash/release-me/coverage. 307 / 548 LOC (56.02%) covered.
release-me on  docker-bashcov-fix [$?] via 🐳 orbstack is 📦 v0.8.7 via ⬢ v22.2.0 via 💎 v3.3.2 took 36s 
❯ 

Excepted result

Getting proper coverage as all tests are passing

Information

Additional information

I found reference to error

https://github.com/infertux/bashcov/blob/120eef3e6246c2de321c99224ff4552f4af69cee/lib/bashcov/xtrace.rb#L127

Similar issues

dalisoft commented 5 months ago

Hey @infertux I got there debugging values and repo at there

BASHCOV>fa26f0a5-fe3f-465c-96ee-a0600be01651573fa26f0a5-fe3f-465c-96ee-a0600be01651./bash_unitfa26exit 0
+ bashcov: warning: encountered an error parsing Bash's output (error was: expected integer for LINENO, got "uname -m\n_source/bash/release-me/release.sh"). This can occur if your script or its path contains the sequence "fa26f0a5-fe3f-465c-96ee-a0600be01651", or if your script unsets LINENO. Aborting early; coverage report will be incomplete.
Run completed using bashcov 3.1.2 with Bash 3.2, Ruby 3.3.1, and SimpleCov 0.22.0
Coverage report generated for /bin/bash ./bash_unit tests/cli/core.test.sh tests/cli/no-git.test.sh tests/gpg-sign/git-gpg-sign.test.sh tests/plugins/changelog.test.sh tests/plugins/docker.test.sh tests/plugins/git.test.sh tests/plugins/github-release.test.sh tests/plugins/npm-post.test.sh tests/plugins/npm.test.sh tests/plugins/template.test.sh tests/presets/conventional-commits.test.sh tests/presets/workspace.cargo-undefined.test.sh tests/presets/workspace.cargo.test.sh tests/presets/workspace.nodejs-undefined.test.sh tests/presets/workspace.nodejs.test.sh tests/presets/workspace.python-undefined.test.sh tests/presets/workspace.python.test.sh tests/presets/workspace.undefined.test.sh to /Users/dalisoft/Desktop/open_source/bash/release-me/coverage. 307 / 548 LOC (56.02%) covered.

Repo lives at here and i'm running command via env (cat .env.test) bundle exec bashcov ./bash_unit tests/**.test.sh locally

Originally posted by @dalisoft in https://github.com/infertux/bashcov/issues/82#issuecomment-2094962517

dalisoft commented 5 months ago

I found what's caused this, variables should be quotes as it's contains numbers. I hope ShellCheck will cover this bug-case in future

dalisoft commented 5 months ago

After few iterations, get issue back again

infertux commented 2 months ago

Looks like you found a workaround? Please reopen if not.