Skip to content

Add phorge-json format#188

Open
tusooa wants to merge 1 commit into
aconrad:masterfrom
tusooa:tusooa/phorge-json
Open

Add phorge-json format#188
tusooa wants to merge 1 commit into
aconrad:masterfrom
tusooa:tusooa/phorge-json

Conversation

@tusooa

@tusooa tusooa commented Jun 29, 2024

Copy link
Copy Markdown

@aconrad aconrad left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I'll take a closer look this week when I'm at my laptop.

Comment thread tests/test_reporters.py
assert report.generate() == """\
{
"dummy/__init__.py": "",
"dummy/dummy.py": "CCNCUU",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is N?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is described in https://we.phorge.it/book/phorge/article/arcanist_coverage/#building-coverage-support (I have put this link into README): N means "not executable"; C means "covered" and "U" means "not covered"

Comment thread pycobertura/reporters.py
def generate_one(self, filename):
statuses = self.cobertura.line_statuses(filename)
with self.cobertura.filesystem.open(filename) as f:
lines = ["N" for _ in f]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do something like ["N"] * len(f)? On my phone now so I can't test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, as the file handle is not an array at all.

] python -c 'with open("setup.cfg") as f: print(len(f))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: object of type '_io.TextIOWrapper' has no len()

] python -c 'with open("setup.cfg") as f: print(len(["N" for _ in f]))'
50

Comment thread pycobertura/reporters.py
with self.cobertura.filesystem.open(filename) as f:
lines = ["N" for _ in f]
for lineNum, covered in statuses:
lines[lineNum - 1] = "C" if covered else "U"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a long overdue PR that will introduce partially covered lines. Is there a character you'd like to use when I merge this PR eventually?

@tusooa tusooa Jul 1, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per phorge docs, it does not support partially covered lines. A line can only be set to covered, uncovered, not executable, or unreachable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants