Add phorge-json format#188
Conversation
aconrad
left a comment
There was a problem hiding this comment.
Thanks for this! I'll take a closer look this week when I'm at my laptop.
| assert report.generate() == """\ | ||
| { | ||
| "dummy/__init__.py": "", | ||
| "dummy/dummy.py": "CCNCUU", |
There was a problem hiding this comment.
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"
| def generate_one(self, filename): | ||
| statuses = self.cobertura.line_statuses(filename) | ||
| with self.cobertura.filesystem.open(filename) as f: | ||
| lines = ["N" for _ in f] |
There was a problem hiding this comment.
Could we do something like ["N"] * len(f)? On my phone now so I can't test.
There was a problem hiding this comment.
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
| 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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
As per phorge docs, it does not support partially covered lines. A line can only be set to covered, uncovered, not executable, or unreachable.
Adapted from https://lily-is.land/infra/phorge-ci-tools/-/blob/servant/cobertura-to-phorge?ref_type=heads (also written by myself)