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

Branch coverage differing between 3.8/9 and 3.10/3.11 in some environments #1672

Closed
ross opened this issue Aug 18, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ross
Copy link

ross commented Aug 18, 2023

Describe the bug

As part of working on some refactoring in octoDNS I ran into a situation where coverage when run in the GitHub actions environment was saying that 2 branches weren't covered in Python 3.8/9 and were in 3.10/3.11. I couldn't reproduce this locally with 3.9 on OSX, nor could I reproduce it on linux within Docker containers of various sorts.

GitHub Actions is uses ubuntu-latest with actions/setup-python@v2

To Reproduce

Python Version & Envs

Problem with 3.8 and 3.9 in GitHub Actions, worked in 3.10 and 3.11. I couldn't reproduce locally on OSX or in Docker containers. A co-contributor @viranch was able to, but I don't know the details of his env ATM.

I verified that python, pip, and all module versions were the same in both envs so it seems to be something deeper. Happy to help look at other details if you point me at what you want collected.

Coverage Version

coverage==7.3.0

If need I could work on trying to get coverage debug sys out of an actions run.

Module Versions

Search for "environment & versions" in the "CI Build" section's output:

Problematic 3.9 - https://github.com/octodns/octodns/actions/runs/5895338935/job/15990899071
Working 3.10 - https://github.com/octodns/octodns/actions/runs/5895338935/job/15990899215

Problematic code

PR is octodns/octodns#1044

Screenshot of the html report saying a branch wasn't covered (test would have failed where that true):

Screenshot showing problem where coverage is incomplete

SHA octodns/octodns@65096c0 exhibited the problem and I fixed it by switching the order of the clauses of the IFs in octodns/octodns@b0dff4f.

Commands to run locally

May or may not reproduce locally, but the commands to try would be:

  • git clone git@github.com:octodns/octodns.git
  • python3.9 -mvenv env
  • source env/bin/activate
  • ./script/coverage

If you can reproduce locally with 3.9, you can swap in python3.10 above and it should pass.

Expected behavior

Full coverage of the branches that matches across python versions.

@nedbat
Copy link
Owner

nedbat commented Aug 18, 2023

This is due to an optimization in earlier versions of Python that weren't properly traced. Newer versions of Python correctly trace it: #198

@ross
Copy link
Author

ross commented Aug 18, 2023

🆒 was feeling like it was something of that sort. I guess when I flipped the order of the clauses causing both cases to be used explicitly it was enough to work around that.

I did a bit of searching around to see if I could find related issues, but I don't think I zeroed in on continue being part of it so didn't turn anything up.

Should this close as duplicate or stay open? Thanks.

@nedbat
Copy link
Owner

nedbat commented Aug 18, 2023

I thought I had closed it! :)

@nedbat nedbat closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants