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

django-jenkins doesn't work with coverage.py 4.0a1 #246

Closed
nedbat opened this issue Oct 22, 2014 · 9 comments
Closed

django-jenkins doesn't work with coverage.py 4.0a1 #246

nedbat opened this issue Oct 22, 2014 · 9 comments

Comments

@nedbat
Copy link

nedbat commented Oct 22, 2014

Hi, there are a few things you are doing that are not part of the publicly supported API of coverage.py, and one of them is breaking with 4.0a1.
First, you should import "coverage" like this:

from coverage import coverage

Because you are importing from "coverage.control", it doesn't work with coverage.py 4.0a1.
Secondly, I see you are calling _harvest_data directly. You shouldn't need to do this, as the leading underscore indicates.
If I can help to get django-jenkins working using only the public APIs, please let me know.

@kmmbvnr
Copy link
Owner

kmmbvnr commented Oct 22, 2014

Hi, Ned, than you for help.

self.coverage._harvest_data() was added years ago when simple start/stop became not enough. What is the proper way to interact with coverage?

@nedbat
Copy link
Author

nedbat commented Oct 22, 2014

The functions described here should be enough: http://nedbatchelder.com/code/coverage/api.html If they are not, let's talk about it, so that we can extend the API in ways that you need.

@aleator83
Copy link
Contributor

Hello,
i've problem if _harvest_data() is removed.
It seems that it will use "coverage" on all directories instead only the target apps.
The result was, that it also scans the whole virtualenv directory.
I've also tried to exclude it, but it didn't work.

Ended up in reading self.coverage._harvest_data() and everything is fine.

@nedbat
Copy link
Author

nedbat commented Nov 28, 2014

@aleator83 I'm not sure what you are referring to, but if you are calling _harvest_data, then everything is not fine. It will break in the future. We can work out a real solution if you give me more details about the problem.

@aleator83
Copy link
Contributor

The problem only exists with coverage 3.7.1 as set in the requirements.txt

Steps to reproduce

mkdir testcase
cd testcase
virtualenv .env
source .env/bin/activate
pip install Django==1.6.8
pip install git+https://github.com/kmmbvnr/django-jenkins.git
django-admin.py startproject testcase
Add django_jenkins to INSTALLED_APPS
python manage.py jenkins --enable-coverage

In reports/coverage.xml you will see it will also scan stuff under the .env directory.

@kmmbvnr
Copy link
Owner

kmmbvnr commented Nov 29, 2014

If you have no PROJECT_APPS settings all packages are covered.

@aleator83
Copy link
Contributor

PROJECT_APPS setting makes no difference to this problem

@kmmbvnr
Copy link
Owner

kmmbvnr commented Nov 30, 2014

yep, confirmed. without _harvest_data() calls morfs are ignored

there is something wrong with @nedbat coverage.

@nedbat
Copy link
Author

nedbat commented Nov 30, 2014

I'm trying to understand what you are doing here, but I'm not getting the same results you are.

I ran these commands:

virtualenv .env
source .env/bin/activate
pip install Django==1.6.8
pip install coverage==3.7.1
pip install git+https://github.com/kmmbvnr/django-jenkins.git
django-admin.py startproject testcase
vim testcase/testcase/settings.py       # Add django_jenkins to INSTALLED_APPS
cd testcase/
python manage.py jenkins --enable-coverage
vim reports/coverage.xml

When I looked at coverage.xml, it had entries for these files:

.env/lib/python2.7/site-packages/django/contrib/admin/__init__.py
.env/lib/python2.7/site-packages/django/contrib/admin/actions.py
.env/lib/python2.7/site-packages/django/contrib/admin/filters.py
.env/lib/python2.7/site-packages/django/contrib/admin/forms.py
.env/lib/python2.7/site-packages/django/contrib/admin/helpers.py
.env/lib/python2.7/site-packages/django/contrib/admin/models.py
.env/lib/python2.7/site-packages/django/contrib/admin/options.py
.env/lib/python2.7/site-packages/django/contrib/admin/sites.py
.env/lib/python2.7/site-packages/django/contrib/admin/templatetags/__init__.py
.env/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_static.py
.env/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_urls.py
.env/lib/python2.7/site-packages/django/contrib/admin/util.py
.env/lib/python2.7/site-packages/django/contrib/admin/validation.py
.env/lib/python2.7/site-packages/django/contrib/admin/widgets.py
.env/lib/python2.7/site-packages/django/contrib/auth/__init__.py
.env/lib/python2.7/site-packages/django/contrib/auth/forms.py
.env/lib/python2.7/site-packages/django/contrib/auth/hashers.py
.env/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py
.env/lib/python2.7/site-packages/django/contrib/auth/models.py
.env/lib/python2.7/site-packages/django/contrib/auth/tokens.py
.env/lib/python2.7/site-packages/django/contrib/contenttypes/__init__.py
.env/lib/python2.7/site-packages/django/contrib/contenttypes/management.py
.env/lib/python2.7/site-packages/django/contrib/contenttypes/models.py
.env/lib/python2.7/site-packages/django/contrib/contenttypes/views.py
.env/lib/python2.7/site-packages/django/contrib/messages/__init__.py
.env/lib/python2.7/site-packages/django/contrib/messages/api.py
.env/lib/python2.7/site-packages/django/contrib/messages/constants.py
.env/lib/python2.7/site-packages/django/contrib/messages/models.py
.env/lib/python2.7/site-packages/django/contrib/messages/storage/__init__.py
.env/lib/python2.7/site-packages/django/contrib/sessions/__init__.py
.env/lib/python2.7/site-packages/django/contrib/sessions/backends/__init__.py
.env/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py
.env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py
.env/lib/python2.7/site-packages/django/contrib/sessions/exceptions.py
.env/lib/python2.7/site-packages/django/contrib/sessions/management/__init__.py
.env/lib/python2.7/site-packages/django/contrib/sessions/models.py
.env/lib/python2.7/site-packages/django/contrib/staticfiles/management/__init__.py
.env/lib/python2.7/site-packages/django/contrib/staticfiles/models.py
.env/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/__init__.py
.env/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py
.env/lib/python2.7/site-packages/django_jenkins/management/commands/jenkins.py
.env/lib/python2.7/site-packages/django_jenkins/models.py
.env/lib/python2.7/site-packages/django_jenkins/runner.py
.env/lib/python2.7/site-packages/django_jenkins/tasks/with_coverage.py

Yes, files from .env are in there, but none of the files from the project directory are!?

But these instructions install the tip of django_jenkins, which still has the _harvest_data call in it, so I'm very confused.

But let's step back: it seems like a lot of the code in with_coverage.py is trying to emulate options that coverage already supports. Can we talk about what it is you want coverage to do, and I can help you find the best way to do it?

jsteffen added a commit to jsteffen/META-SHARE that referenced this issue Jan 4, 2016
Pin coverage to version 3.7.1 as Jenkins does not work with newer version. See also kmmbvnr/django-jenkins#246
jsteffen added a commit to jsteffen/django-jenkins that referenced this issue Jan 6, 2016
jsteffen added a commit to jsteffen/django-jenkins that referenced this issue Jan 6, 2016
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

3 participants