Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing coverage for multiline bash arrays and named pipes #363

Closed
Ayowel opened this issue Aug 28, 2021 · 3 comments
Closed

Missing coverage for multiline bash arrays and named pipes #363

Ayowel opened this issue Aug 28, 2021 · 3 comments

Comments

@Ayowel
Copy link

Ayowel commented Aug 28, 2021

Tested on a CentOS 8 container with kcov tag pre-v40

As said in the title, kcov fails to detect usage of multiline arrays and named pipes in bash if they span multiple lines. What seems to happen is that the usage is detected but only attributed to the closing parenthesis' line.

Can be seen with this test file, which yields a 44.4% coverage rate instead of the expected 100%:

#!/bin/bash

# This works
a=( this is a test )

# This doesn't
b=(
  this is
  a test
)

# This works
cat <(echo Hello)

# This doesn't
cat <(
  echo Hello
)
@SimonKagstrom
Copy link
Owner

Yes, unfortunately I'd say this is yet another instance where #145 (a proper parser for Bash) would be needed. The current parser already has a set of nasty special-cases, and I suppose it would be possible to add more, but #145 would solve that once and for all.

@Ayowel
Copy link
Author

Ayowel commented Aug 28, 2021

Hadn't found the issue when searching, thanks for pointing me to it.
Is there a list of sample codes that currently get an improper result or is the issue used to track the relevant issues and those individual issues should be used as code samples ?
Re-using shfmt's parser was discussed, however after looking at shfmt's code it seems that you would need a wrapper library to be able to use it in C. Is this solution still on the table ?

@SimonKagstrom
Copy link
Owner

Unfortunately, there isn't really a conclusive list of improper results.

One way would be to add it to one of the scripts in tests, which gets run in the CI tests. That would be a good way of asserting that it works properly with a real parser.

I haven't looked more at shfmt, but I agree it would be a cumbersome way of implementing it.

Closing this since I think it's best to implement as a part of #145, although I can't really say when/if I'll work on that one. I'm personally mainly using kcov for compiled code and sometimes python, so I'm not actively bothered by the bash bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants