-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[WIP] fix xdebug coverage (part2): support XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE #7900
base: master
Are you sure you want to change the base?
[WIP] fix xdebug coverage (part2): support XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE #7900
Conversation
2 weeks have passed since I submitted this pull request. |
@mofarrell has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Thanks, but I found there is a conflict. I will rebase this pull request. |
800f49a
to
318a34c
Compare
@xKerman updated the pull request - view changes - changes since last import |
@mofarrell has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@mofarrell It has been over 2 weeks since this pull request was imported to Phabricator. |
@@ -129,6 +160,42 @@ Array CodeCoverage::Report(bool sys /* = true */) { | |||
return ret; | |||
} | |||
|
|||
Array CodeCoverage::ReportExecutable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both this and ReportDeadCode could go since all the bookkeeping would happen in m_hits, and be reported by Report.
auto lines = unit->getLinesWithCode(); | ||
TI().m_coverage->RecordAsNotDeadCode(filename, std::move(lines)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could go away, and their logic could be performed when initializing a new std::vector for the file in m_hits.
recordNotDeadCode(unit, filename); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be removed. The filter for initializing a new m_hits entry would handle this.
Also this will recompute the DeadCode, and ExecutableLines every time we switch back to a unit.
for (ArrayIter iter(merged); iter; ++iter) { | ||
Array tmp = iter.second().toArray(); | ||
tmp->ksort(SORT_REGULAR, true); | ||
ret.set(iter.first(), tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should all be able to be left the same. Some filtering may need to happen for the DEAD or UNUSED values if the recording was being performed with it, then stopped without throwing away data, then restarted without DEAD and UNUSED data. I don't quite know xdebug's exact behavior there, but it might not show the older DEAD or UNUSED values.
@@ -288,6 +300,8 @@ struct RequestInjectionData { | |||
|
|||
bool m_debuggerAttached{false}; | |||
bool m_coverage{false}; | |||
bool m_coverageWithUnused{false}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum with possible states for coverage recording.
m_coverageWithDeadCode = flag; | ||
updateJit(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All unneeded if collapsed with enum.
@xKerman Sorry this has taken so long. I kept checking back after test results had expired. This looks like it is working well, but I feel like it would be cleaner to do all the book keeping in a single map. Rather than merging them at the end. |
@mofarrell Thanks for your code review and comments.
I see, I will try to change to use a single map ( |
description
related to: #1589 and #7888
This pull request adds support for
XDEBUG_CC_UNUSED
andXDEBUG_CC_DEAD_CODE
flags toxdebug_start_code_coverage()
.example
With this pull request, code coverage report for moneyphp/money can be generated with HHVM + PHPUnit as following:
https://xkerman.github.io/hhvm-coverage-sample/hhvm/
Contrast coverage report genereated with PHP5.6 + PHPUnit:
https://xkerman.github.io/hhvm-coverage-sample/php56/
Note: In order to generate coverage report with HHVM + PHPUnit, I need to apply the following patch to phpunit/php-code-coverage: