bloomberg / pytest-memray

pytest plugin for easy integration of memray memory profiler
https://pytest-memray.readthedocs.io/en/latest/
Apache License 2.0
354 stars 25 forks source link

Make the plugin compatible with pytest-xdist #51

Closed pablogsal closed 2 years ago

pablogsal commented 2 years ago

The pytest-xdist plugin spawns worker processes that run the tests while the main process reports the results. As every process has its own copy of all the plugins, this means that when the main process reports the final summary, it doesn't have access to the results stored by every individual test so the plugin is unable to print the summary.

To make ourselves compatible with pytest-xdist, we make the main process and the workers use a common path to store the metadata and result files (this is communicated from the main process to the workers by an environment variable). Then, at report time, if the main process doesn't have any result data, it will fetch it from this directory instead.

Closes: #2

godlygeek commented 2 years ago

pytest-xdist allows distributing tests across multiple hosts, as well. Should we detect when it was run in that mode and warn or fail?

pablogsal commented 2 years ago

pytest-xdist allows distributing tests across multiple hosts, as well. Should we detect when it was run in that mode and warn or fail?

Hummm. I would need to investigate. Do you mind if we do this in a another PR?

pablogsal commented 2 years ago

I have addressed all comments, please take another look