-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Subprocess coverage - strange detection of lines losing coverage #492
Comments
Original comment by Dan Riti (Bitbucket: danriti, GitHub: danriti) This seems like this may be related to this previously resolved issue by @nedbat: https://bitbucket.org/ned/coveragepy/issues/262/when-parallel-true-erase-should-erase-all Continuing to investigate. |
Original comment by Dan Riti (Bitbucket: danriti, GitHub: danriti) So that above bug was patched in version & https://github.com/butla/experiments/blob/master/subprocess_coverage/requirements.txt#L3 Going to see if I can replicate this problem with a unit test. |
Original comment by Dan Riti (Bitbucket: danriti, GitHub: danriti) After some more investigation, it seems this is occurring because of the inclusion of the https://github.com/butla/experiments/blob/master/subprocess_coverage/requirements.txt#L4 This seems to be causing coverage to generate coverage data files when you run any coverage command. For instance: (.env)[driti@ubuntu subprocess_coverage]$ coverage run -m py.test tests/
================================== test session starts ==================================
platform linux2 -- Python 2.7.3, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /home/driti/dev/experiments/subprocess_coverage/tests, inifile:
collected 5 items
tests/test_bla.py .
tests/test_bottle_service.py .
tests/test_wsgi_app.py ...
=============================== 5 passed in 4.46 seconds ================================
(.env)[driti@ubuntu subprocess_coverage]$ ls -al
total 56
drwxrwxr-x 4 driti driti 4096 Jun 2 19:51 .
drwxr-xr-x 9 driti driti 4096 Jun 2 18:15 ..
-rw-rw-r-- 1 driti driti 43 Jun 2 16:55 .coveragerc
-rw-rw-r-- 1 driti driti 389 Jun 2 19:51 .coverage.ubuntu.76695.615877
-rw-rw-r-- 1 driti driti 414 Jun 2 19:51 .coverage.ubuntu.76695.989394
-rw-rw-r-- 1 driti driti 406 Jun 2 19:51 .coverage.ubuntu.76702.583650
-rw-rw-r-- 1 driti driti 409 Jun 2 19:51 .coverage.ubuntu.76703.517175
-rw-rw-r-- 1 driti driti 426 Jun 2 19:51 .coverage.ubuntu.76704.344998
-rw-rw-r-- 1 driti driti 389 Jun 2 19:51 .coverage.ubuntu.76713.186275
-rw-rw-r-- 1 driti driti 434 Jun 2 19:51 .coverage.ubuntu.76718.515879
-rw-rw-r-- 1 driti driti 264 Jun 2 18:15 requirements.txt
-rwxrwxr-x 1 driti driti 224 Jun 2 18:15 run_coverage.sh
drwxrwxr-x 3 driti driti 4096 Jun 2 18:20 some_code
drwxrwxr-x 3 driti driti 4096 Jun 2 18:38 tests You can see in the output above, that we get the expected (.env)[driti@ubuntu subprocess_coverage]$ coverage combine
(.env)[driti@ubuntu subprocess_coverage]$ ls -al
total 36
drwxrwxr-x 4 driti driti 4096 Jun 2 19:51 .
drwxr-xr-x 9 driti driti 4096 Jun 2 18:15 ..
-rw-rw-r-- 1 driti driti 485 Jun 2 19:51 .coverage
-rw-rw-r-- 1 driti driti 43 Jun 2 16:55 .coveragerc
-rw-rw-r-- 1 driti driti 389 Jun 2 19:51 .coverage.ubuntu.76783.398020
-rw-rw-r-- 1 driti driti 264 Jun 2 18:15 requirements.txt
-rwxrwxr-x 1 driti driti 224 Jun 2 18:15 run_coverage.sh
drwxrwxr-x 3 driti driti 4096 Jun 2 18:20 some_code
drwxrwxr-x 3 driti driti 4096 Jun 2 18:38 tests We get out expected With this file lingering around, it will cause follow on runs to have skewed results, which the original issue creator was able to observe. Thus, a workaround would be to manually delete the coverage data files (using Continuing investigation for a code fix. |
Original comment by Dan Riti (Bitbucket: danriti, GitHub: danriti) After several discussions with @nedbat, there doesn't seem (at least to me) to be an easy way to solve this problem. So this might need some more thought to be solved. On the bright side, here is a PR that includes a unit test that replicates this problem: |
@danriti's test is here and the previous commit: https://bitbucket.org/ned/coveragepy/commits/e72ccc3a913280de298bec8757f1461bef7d8cb8 |
Fixed in d89704fe7b17 (bb) |
Originally reported by Michał Bultrowicz (Bitbucket: Butla, GitHub: Butla)
I wanted to test out how well subprocess coverage works for WSGI apps and I came across a strange behavior. After running the tests a few times I deliberately commented out a test to see if the coverage dropped - it didn't.
I experimented with that a bit and it turns out, that the loss of coverage will be detected if I run "coverage erase" twice before running the tests. It also seems that it works when I run "erase" from shell and then run my "run_coverage" script with "coverage erase" lines removed. Adding "sleep" in "run_coverage" before a single "coverage erase" doesn't work.
Reproduction steps:
The text was updated successfully, but these errors were encountered: