-
-
Notifications
You must be signed in to change notification settings - Fork 585
fix(coverage): missing files in the coverage report if they have no tests #2607
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
Conversation
--source
flag to coveragepy call
This might be a really interesting thing in the context of https://docs.google.com/document/d/1D_y9PAimvn566VyeLDu-FZLKrAcv48CL6ftKU03_dKs/edit?tab=t.0#heading=h.5mcn15i0e1ch |
I think it's a valuable fix that should be merged. Even if/when the above Bazel issue comes to be, we can port or adopt this code towards that or replace it with upstream bazel capabilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
--source
flag to coveragepy calle9153e4
to
7ec81bd
Compare
Could also add the same fix in the stage2 bootsrap code please? |
7ec81bd
to
9c738e2
Compare
Good call. Updated Can you also point me to the test suite for these files? I can't seem to find specific tests regarding coverage. |
9c738e2
to
b75eb7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in concept.
My only concern is argv length for the system python bootstrap -- isn't this going to dramatically increase it? The argv length is already a source of issues. Can the paths be passed in via a file e.g. the rcfile, instead?
For tests...hm, we don't seem to have much in this area. I think your best bet is to use sh_py_run_test and/or py_reconfig_test -- see tests/bootstrap_impls for example. These let you set arbitrary flags when building a py binary/test and run it via an sh_test. You'll need to modify the py_reconfig rule to allow enabling coverage mode. Something like this, in
You should then be able to use For bootstrap=script, you can probably create more of a unittest by stashing the created Coverage object somewhere. Set an environment variable via |
…ests This ensures that un-executed files (i.e. files that aren't tested) are included in the coverage report. The current behavior is that coverage.py excludes them by default. See https://coverage.readthedocs.io/en/7.6.10/source.html#execution
b75eb7b
to
76786dc
Compare
Cheers for the tips @rickeylev. Updated the PR to use the I got some trouble in adding
It doesn't seem to be present in the builtin_exec_platforms.bzl definitions. (I'm not sure if I'm interpreting it correctly that it's the source of The closest would be
In the meantime, I've tested it manually via https://github.com/BurnzZ/bazel-python-omitted-coverage. Also inspected the generated |
Interesting that you are getting this error. We are matching on it here: https://github.com/bazelbuild/rules_python/blob/a816962e509311c23230730b4b28f9d52a229949/python/private/hermetic_runtime_repo_setup.bzl#L192 Not sure if this sparks any new ideas, but wanted to add the code reference. |
…o coveragepy-source
Let's merge this as this brings us to a better place than we are today. |
This ensures that un-executed files (i.e. files that aren't tested) are included in the coverage report. The current behavior is that coverage.py excludes them by default.
This PR configures source files via the auto-generated
.coveragerc
file.See https://coverage.readthedocs.io/en/7.6.10/source.html#execution:
Closes #2599
Closes #2597
Fixes #2575