Skip to content

PHPLIB-582: Create JSON test result file for evergreen #787

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

Merged
merged 2 commits into from
Sep 21, 2020

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Sep 18, 2020

PHPLIB-582

This ticket unfortunately is incomplete due to a few issues with the build system.

Reporting test results using attach.results does not allow us to easily add logs (e.g. information about assertion failures, traces, test output, etc.) to the test results. This is possible using attach.xunit_results, but I could not get that command to read the results files written by PHPUnit. For one, PHPUnit reports nested test suites (a feature of JUnit), which the parser in evergreen does not understand. This should be fixed by EVG-12951.

While I had a temporary listener that worked around this by flattening the file (and to report a single test suite containing all tests), this still didn't yield any results. This went as far as Evergreen happily accepting a non-existent or invalid xUnit result file. So, for the time being, we report test results using the JSON format. This will at least cause them to show up in a "Tests" tab under individual tasks, allowing us to see which test failed without consulting the log. Once the problems mentioned above have been solved, we can revisit this and add more detail to the test reporting.

Note that due to how PHPUnit approaches its PHP version support, we cannot support both PHPUnit 6 and PHPUnit 8 anymore. While we could add return type hints in any class implementing the listener interface, we can't do so until we drop PHP 7.0 as the listener interface requires a void return type which was only introduced in 7.1. The easiest way to fix this is to drop PHPUnit 8 and rely on 6 only, which will work up to PHP 7.4. We can then revisit this once we start removing our custom listeners, drop support for PHP 7.0, or add support for PHP 8.

@alcaeus alcaeus requested a review from jmikola September 18, 2020 09:22
@alcaeus alcaeus self-assigned this Sep 18, 2020
use function round;

// phpcs:disable SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException
class EvergreenLogListener extends Printer implements TestListener
Copy link
Member

Choose a reason for hiding this comment

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

Since we already use symfony/phpunit-bridge, I noticed it has an alias for a SymfonyTestsListener interface. I think you could leverage that instead of implementing PHPUnit's interface directly and preserve our ability to test with PHPUnit 8.x.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, that class is not a generic implementation for test listeners, but rather a specific one to support the use-case of the PHPUnit bridge.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I just poked my head into SymfonyTestsListenerTrait.

@alcaeus alcaeus merged commit 38a1ba9 into mongodb:master Sep 21, 2020
@alcaeus alcaeus deleted the phplib-582 branch September 21, 2020 14:47
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