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

Provide SQL line table even if running coveragepy in branch coverage mode #762

Open
fkromer opened this issue Jan 25, 2019 · 6 comments
Open
Labels
enhancement New feature or request

Comments

@fkromer
Copy link

fkromer commented Jan 25, 2019

Is your feature request related to a problem? Please describe.

coveragepy provides the line table if run in line coverage mode and the arc table when run in branch coverage mode. python-tia depends on the line to context_id mapping in the line table and should be able to access this data even if coveragepy is run in branch coverage mode.

Describe the solution you'd like

Provide an option to enable line table generation in addition to arc table generation. This prevents from runtime overheads for users which don't need both tables and allows data availability for those which need it.

@fkromer fkromer added the enhancement New feature or request label Jan 25, 2019
@nedbat
Copy link
Owner

nedbat commented Jun 24, 2019

Would a SQLite view work for you?

    create view line (file_id, context_id, lineno) as 
    select file_id, context_id, fromno from arc where fromno > 0 
    union
    select file_id, context_id, tono from arc where tono > 0;

@fkromer
Copy link
Author

fkromer commented Jun 26, 2019

I'm using a simple wrapper for the SQL database access. A SQLite view is not suitable for me. This would require to run coveragepy twice to get both tables I guess. However I'd prefer to have either (1) the line info contained in the arc table as well or (2) the line table generated in addition to the arc table when coveragepy is run in branch coverage mode.

@nedbat
Copy link
Owner

nedbat commented Jun 26, 2019

I don't understand why you would need to run coverage twice. Maybe I didn't explain enough: my idea is that the schema depends on whether you are measuring branch coverage. If not, then you have a line table and no arc table. If you measure branch coverage, then you have an arc table and a line view. So either way you could select from line. It seems pointless to store the data twice, in both the arc table and the line table.

@fkromer
Copy link
Author

fkromer commented Jun 26, 2019

Ah, I understand. Right, storing the data twice makes no sense. Should work for me. Btw: This request is not urgent because I need it for a spare time project only.

@Bachmann1234
Copy link
Contributor

Howdy! I was poking around the pre release tag.

I thew this view into a branch https://github.com/Bachmann1234/coveragepy/tree/line_view and ran it against a project of mine

I was going to write some tests and spin up a PR but first I wanted to confirm this was the solution you wanted.

@nedbat
Copy link
Owner

nedbat commented Sep 1, 2019

I'm not sure what to do with this request. As of now, the line table is not a simple thing to work with. The line numbers are stored in a packed binary format, so we can't mimic it with a view based on the arc table any more.

@nedbat nedbat added this to the 5.0 beta milestone Sep 3, 2019
@nedbat nedbat removed this from the 5.0 milestone Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants