<div dir="ltr"><div>Hi there</div><div><br></div><div>I'm really enjoying using pytest (and currently porting a <a href="https://github.com/OSGeo/gdal/pull/963">large OSS project</a> to it).</div><div><br></div><div>The project I'm porting has a large number of tests that depend on other tests. In particular, combining certain tests in the same run as other tests appears to cause segfaults sometimes, or double-free errors at process exit (particularly annoying since it's very hard to pinpoint what caused it)<br></div><div><br></div><div>My current workflow for finding these dependencies involves:</div><div> * run all the tests, note a failure.</div><div> * run half the tests, see if it still fails. If not, run the other half<br></div><div> * run half of <i>those </i>tests, etc.</div><div><br></div><div>This is pretty similar to the `git bisect` workflow when debugging when a bug was introduced in a codebase.</div><div><br></div><div>I'd like to find or write a similar plugin for pytest, that would repeatedly run teh tests with smaller and smaller subsets of tests until the dependent tests are identified.</div><div><br></div><div>Since sometimes the failure mode I'm tracking is a crash at the end of the process (after all tests have succeeded), I will need to run tests as a subprocess of the main process (so I can restart it when it fails.)</div><div><div><br></div><div>The simplest implementation I can think of is a plugin that completely takes over the parent pytest process, runs pytest itself repeatedly in a `subprocess.check_call()`, then calls `sys.exit(0)` when done. This sounds pretty wrong but it could be a good starting point?<br><div><br></div><div>However, I note the excellent pytest-xdist plugin is good at spawning worker subprocesses and sending tests to them, and rather than re-invent the wheel I wondered
if I could make my plugin depend on xdist, and <i>control</i> the xdist workers (e.g. run one worker with all the tests; if it crashes, run a new worker with half the tests, etc).</div></div></div><div><br></div><div>Could someone knowledgeable in this area give me some pointers on whether this is a good idea; what exactly is possible; and where to look for code to re-use? Particularly if you know of any plugins that might do similar things that I could take inspiration from.<br></div><div><br></div><div>Thanks for reading :)</div><div><br></div><div>Craig de Stigter<br></div></div>