classification
Title: python -m test --coverage doesn't work on Windows
Type: Stage:
Components: Tests, Windows Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, georg.brandl, nedbat, paul.moore, python-dev, r.david.murray, steve.dower, tim.golden, vinay.sajip, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2015-09-28 22:20 by vstinner, last changed 2017-05-11 09:41 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
regrtest_coverage.patch vstinner, 2015-09-29 11:49 review
Messages (9)
msg251804 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-28 22:20
"python -m test --coverage" doesn't work on Windows because the tracer ignores the root directory of Python source code.

The code works on Linux because sys.base_prefix and sys.base_exec_prefix don't point to the Python source code, but to /usr/local.

I'm not sure why sys.base_prefix and sys.base_exec_prefix are ignored.
msg251805 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-28 22:25
I added a new test for "-m test --coverage" in test_regrtest, but I skipped the test on Windows.
msg251807 - (view) Author: Ned Batchelder (nedbat) * (Python triager) Date: 2015-09-28 23:18
What version of coverage.py is this?
msg251808 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-28 23:25
Changes on ignoredirs:

Changeset 294f8aeb4d4b: "Implemented PEP 405 (Python virtual environments)."

-        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix, libpath],
-                             trace=0, count=1)
+        tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,
+                             libpath], trace=0, count=1)


Changeset b43f14c103bb: "#5656: detect correct encoding of files when reporting coverage in trace.py, and ignore files in the temporary direct"

-        import trace
-        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+        import trace, tempfile
+        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,
+                                         tempfile.gettempdir()],

Changeset 308c193f51e3: "adds -T option for code coverage.  The implementation is a fairly simpleminded adaptation of Zope3's test.py -T flag."

+        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+                             trace=False, count=True)
msg251809 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-28 23:30
Ooops, copy/paste failure. The right diff is:

Changeset 294f8aeb4d4b: "Implemented PEP 405 (Python virtual environments)."

-        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,
+        tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,
                                          tempfile.gettempdir()],
                              trace=False, count=True)
msg251847 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-29 11:49
Attached patch simply removes the list of ignored directories. It fixes test_regrtest.test_coverage() on Windows.
msg251976 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-30 22:54
New changeset 0f10e0b3e76d by Victor Stinner in branch 'default':
Fix regrtest --coverage on Windows
https://hg.python.org/cpython/rev/0f10e0b3e76d
msg251977 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-30 22:55
Ok, I fixed the issue by removing the list of ignored directories.
msg293478 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-11 09:30
New changeset a5bb62436e25614276ac4b8e252a87f3fcc946cd by Victor Stinner in branch '2.7':
[2.7] bpo-30283: regrtest: backport test_slow_interrupted() and test_coverage() (#1541)
https://github.com/python/cpython/commit/a5bb62436e25614276ac4b8e252a87f3fcc946cd
History
Date User Action Args
2017-05-11 09:41:36vstinnersetmessages: - msg293482
2017-05-11 09:41:15vstinnersetmessages: + msg293482
2017-05-11 09:30:25vstinnersetmessages: + msg293478
2015-09-30 22:55:16vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg251977
2015-09-30 22:54:55python-devsetnosy: + python-dev
messages: + msg251976
2015-09-29 11:49:39vstinnersetfiles: + regrtest_coverage.patch

nosy: + barry, georg.brandl, vinay.sajip
messages: + msg251847

keywords: + patch
2015-09-28 23:30:03vstinnersetmessages: + msg251809
2015-09-28 23:25:08vstinnersetmessages: + msg251808
2015-09-28 23:18:21nedbatsetnosy: + nedbat
messages: + msg251807
2015-09-28 22:25:06vstinnersetmessages: + msg251805
2015-09-28 22:20:02vstinnercreate