Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
recursive symlink significantly slows collection #624
placing "ln -s . link" in a collected dir significantly slows down collection. it seems collection doesn't keep track of directories visited to prevent unnecessary recursion?
I actually found a much more amusing result when attempting to reproduce this:
I'm amused it stops after recusing 40 levels without erroring -- I suspect it hits
EDIT: for best effect, I suggest making the terminal wider so you get a nice pyramid
There are two parts to the fix: * Don't visit directories which have already been visited. This fixes the exponential aspect of the bug. * Don't visit files which have already been visited. This fixes the more minor problem that, without this additional change, test_noop would be run twice, once as test_noop.py and once as symlink-0/test_noop.py. Fixes pytest-dev#624
This fixes trying to traverse exponentially many paths in the presence of symlink loops, and trying to run any tests discovered in that tree exponentially many times if collecting ever finishes. I wanted to also prevent visiting files more than once, but my first attempt broke --keep-duplicates. Fixes pytest-dev#624