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

python -m test --coverage doesn't work on Windows #69447

Closed
vstinner opened this issue Sep 28, 2015 · 9 comments
Closed

python -m test --coverage doesn't work on Windows #69447

vstinner opened this issue Sep 28, 2015 · 9 comments
Labels
OS-windows tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 25260
Nosy @warsaw, @birkenfeld, @pfmoore, @vsajip, @vstinner, @nedbat, @tjguk, @bitdancer, @zware, @zooba
Files
  • regrtest_coverage.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-09-30.22:55:16.738>
    created_at = <Date 2015-09-28.22:20:02.721>
    labels = ['tests', 'OS-windows']
    title = "python -m test --coverage doesn't work on Windows"
    updated_at = <Date 2017-05-11.09:41:36.871>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-05-11.09:41:36.871>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-09-30.22:55:16.738>
    closer = 'vstinner'
    components = ['Tests', 'Windows']
    creation = <Date 2015-09-28.22:20:02.721>
    creator = 'vstinner'
    dependencies = []
    files = ['40620']
    hgrepos = []
    issue_num = 25260
    keywords = ['patch']
    message_count = 9.0
    messages = ['251804', '251805', '251807', '251808', '251809', '251847', '251976', '251977', '293478']
    nosy_count = 11.0
    nosy_names = ['barry', 'georg.brandl', 'paul.moore', 'vinay.sajip', 'vstinner', 'nedbat', 'tim.golden', 'r.david.murray', 'python-dev', 'zach.ware', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue25260'
    versions = ['Python 3.6']

    @vstinner
    Copy link
    Member Author

    "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.

    @vstinner vstinner added tests Tests in the Lib/test dir OS-windows labels Sep 28, 2015
    @vstinner
    Copy link
    Member Author

    I added a new test for "-m test --coverage" in test_regrtest, but I skipped the test on Windows.

    @nedbat
    Copy link
    Member

    nedbat commented Sep 28, 2015

    What version of coverage.py is this?

    @vstinner
    Copy link
    Member Author

    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: "bpo-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)

    @vstinner
    Copy link
    Member Author

    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)

    @vstinner
    Copy link
    Member Author

    Attached patch simply removes the list of ignored directories. It fixes test_regrtest.test_coverage() on Windows.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 30, 2015

    New changeset 0f10e0b3e76d by Victor Stinner in branch 'default':
    Fix regrtest --coverage on Windows
    https://hg.python.org/cpython/rev/0f10e0b3e76d

    @vstinner
    Copy link
    Member Author

    Ok, I fixed the issue by removing the list of ignored directories.

    @vstinner
    Copy link
    Member Author

    New changeset a5bb624 by Victor Stinner in branch '2.7':
    [2.7] bpo-30283: regrtest: backport test_slow_interrupted() and test_coverage() (bpo-1541)
    a5bb624

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-windows tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants