Comments (3)
Thank you for this great snippet. However adding even more regexps to address all these examples feels wrong to me because there will always be weird edge cases that can't be handled by regexps. So I'm tagging this issue as a duplicate/reminder of #25
from bashcov.
Indeed, I managed to get a 65.91% coverage on this snippet with a Bash solution, using regular expressions and hacks, but without a lexer it will be impossible to get to 100%.
Something I find quite problematic is how the LINENO
variable behaves.
With normal commands it's fine.
With commands in process substitutions ($()
, ``
, <()
, >()
, ()
, etc.), using backslashes \
, pipes |
and logical operators (&&
, ||
) (and without mentioning handling additional comments #
in regexes, and weird eval
cases), it's completely useless.
The line numbers I get are completely offset, sometimes overlapping with later lines, like empty lines, comments, or commands. It's indecipherable.
I wonder if we could get to 100%, even with a lexer, if the LINENO
variable is not improved.
Bash says it itself:
LINENO Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number (starting with 1) within a script or function. When not in a script or function, the value substituted is not guaranteed to be meaningful.
(Emphasis mine)
Maybe a more reliable way would be to do heuristics to match the actual line using the value of LINENO
and the command written in the trace log. LINENO
gives you a close position in the file, the command helps you identifying the actual line.
I also wonder how Zsh handles this.
from bashcov.
More info on this stackoverflow post and in this gist I made in response.
from bashcov.
Related Issues (20)
- Option to suppress all bashcov output HOT 5
- Error when used with bats HOT 3
- parse_hit fails
- Shell flags inherited by child shells HOT 3
- 0% coverage with BATS on Mac HOT 1
- Is bashcov concurrency safe? HOT 1
- bashcov output should be silent by default HOT 3
- Using PS4 in tested script breaks coverage results HOT 1
- Capturing coverage on sourced script functions executed by bashunit
- `--bash-path` is not respected for `BASH_VERSION` detection HOT 1
- [question] bash 'compiler' HOT 1
- bashcov HOT 1
- Bashcov failing with LINENO related error. Bash is indeed above 4.4 (that was the recommendation till now to this error) HOT 1
- Are you planning a new release? HOT 3
- please rewrite this in bash HOT 2
- How to install on RHEL UBI8? HOT 1
- How to ignore files and folders in bashcov in GitLab-CI yaml? HOT 1
- Use of mutation testing in bashcov - Help needed
- Function definition line missed HOT 4
- Latest release April 2023 No longer has any coverage in report HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bashcov.