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

refactor(agent): improve phpunit instrumentation #725

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

lavarou
Copy link
Member

@lavarou lavarou commented Sep 1, 2023

  • improve phpunit detection
    Use file that is loaded also on PHP 8.2 with include/require optimizations that
    don't execute files without executable statements.

  • improve skipped tests handling
    PHPUnit passes skipped tests to addError as well as endTest regardless of
    the version. The difference is that in PHPUnit 5.x it is not possible to obtain
    test outcome for skipped test - $test.getStatus() returns 'null'. Because of
    that, endTest instrumentation bails out and does not generate test event and
    therefore addError needs to be instrumented. It is possible to obtain test
    outcome for skipped tests in PHPUnit 9.x. However, the $time for skipped test
    is not received in endTest as a valid double and therefore it needs to be
    'fixed'. Moreover testcase.getStatusMessage returns 'null' for tests skipped due
    to dependency failure and therefore it is not possible to expect it in the test
    event.

Use file that is loaded also on PHP 8.2 with include/require optimizations that
don't execute files without executable statements.
PHPUnit passes skipped tests to `addError` as well as `endTest` regardless of
the version. The difference is that in PHPUnit 5.x it is not possible to obtain
test outcome for skipped test - `$test.getStatus()` returns 'null'. Because of
that, `endTest` instrumentation bails out and does not generate test event and
therefore `addError` needs to be instrumented. It is possible to obtain test
outcome for skipped tests in PHPUnit 9.x. However, the `$time` for skipped test
is not received in `endTest` as a valid double and therefore it needs to be
'fixed'. Moreover testcase.getStatusMessage returns 'null' for tests skipped due
to dependency failure and therefore it is not possible to expect it in the test
event.
@lavarou lavarou self-assigned this Sep 1, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2023

Codecov Report

Merging #725 (bd240c9) into oapi (8e683b1) will increase coverage by 0.14%.
Report is 1 commits behind head on oapi.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             oapi     #725      +/-   ##
==========================================
+ Coverage   78.88%   79.02%   +0.14%     
==========================================
  Files         191      191              
  Lines       26749    26757       +8     
==========================================
+ Hits        21102    21146      +44     
+ Misses       5647     5611      -36     
Flag Coverage Δ
agent-for-php-5.5 77.86% <0.00%> (+<0.01%) ⬆️
agent-for-php-5.6 77.95% <0.00%> (+<0.01%) ⬆️
agent-for-php-7.0 77.42% <0.00%> (+<0.01%) ⬆️
agent-for-php-7.1 77.14% <0.00%> (+<0.01%) ⬆️
agent-for-php-7.2 77.56% <0.00%> (+<0.01%) ⬆️
agent-for-php-7.3 77.58% <0.00%> (+<0.01%) ⬆️
agent-for-php-7.4 77.26% <0.00%> (+<0.01%) ⬆️
agent-for-php-8.0 77.04% <0.00%> (?)
agent-for-php-8.1 77.00% <0.00%> (?)
agent-for-php-8.2 76.61% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
agent/lib_phpunit.c 0.00% <0.00%> (ø)
agent/php_execute.c 68.03% <ø> (ø)

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lavarou lavarou added this to the OAPI Instrumentation milestone Sep 5, 2023
@@ -491,8 +491,8 @@ static nr_library_table_t libraries[] = {
* /usr/local/bin. While BaseTestRunner isn't the very first file to load,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the comment be updated since we don't use BaseTestRunner anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Comment updated in bd240c9.

Copy link
Contributor

@zsistla zsistla left a comment

Choose a reason for hiding this comment

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

Thanks for updating this.

Remove a reference to a file no longer used to detect PHPUnit framework.
@lavarou lavarou merged commit 7b142fc into oapi Sep 6, 2023
57 checks passed
@lavarou lavarou deleted the refactor/improve-phpunit-instrumentation branch September 6, 2023 18:11
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.

4 participants