-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rewrite utils and testing framework so code coverage works #1124
Comments
A bonus of rewriting everything like this is that uutils could be embedded into programs (to be used as builtins for a shell, for example). |
This sounds like a good idea for several reasons. I presume it would take pub fn uumain<R: Read, W1: Write, W2: Write>(args: Vec<String>,
stdin: R, stdout: W1, stderr: W2) -> i32 { And then pass One minor issue with this is that it would not be possible to call |
This might be solved by just passing |
Yep, that’s essentially what I’m thinking. I’m only really worried about passing I’ll probably try to push some code outlining things later today or tomorrow. |
I have some stuff here. I still need to work on ways to reduce boilerplate. Note that only |
I patched the
The overall line coverage is 59.3%. You can find details in attached reports. Attached are the generated results: |
Also, I suggest to remove the Codecov CI (badge, PR hook, and reports) for now or write a notice in README. Since the results are mis-leading. The number (20%) does not mean anything related to the code coverage and will not help PRs to improve their testcases. Here is the outputs of
The tarpaulin result shows that only sources under |
Rather than remove the Codecov CI, I think it would make more sense to switch to |
breakpoint-based code coverage (like
https://jbp.io/2017/07/19/measuring-test-coverage-of-rust-programs.html I'm not sure if |
Hm, well, in that case I guess dropping code coverage for the time being is the best solution. |
Thanks. In the meantime, I also create an issue to the |
@rivy did it |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The reason the code coverage seems so low is because it's not actually testing the utilities themselves at the moment as they are tested as subprocesses of the testing executable.
To fix this, I am thinking we need to pass
stdin
,stdout
, andstderr
to each util'suumain()
and rewrite the utils to read and write from the given arguments rather thanstd::io::stdin()
and such. The testing framework would then have to be modified to calluumain()
with the given arguments rather than launching a subprocess with a modifiedstdin
, for example. Unfortunately, doing so requires modifying every util, likely fairly invasively as we will also need to change anything that callsexit()
to instead return aResult
(to avoid crashing the testing executable). Additionally, any panics would just write to the normalstderr
(e.g. any.unwrap()
s).The text was updated successfully, but these errors were encountered: