Problem/Motivation
The new PSR-0 autoloader in Drupal 8 is very fragile in that it requires an exact match between the class name, namespace and location in the filesystem in order to work. If there is a typo in any of those, the class will not be loaded.
For runtime classes, this is generally less of a problem, since if your class fails to load, you'll notice it pretty quickly in most cases (although even then, there are some where you won't, such as those involving dynamic class names that are optionally loaded).
However, for simpletests, this is a major problem. If the class doesn't load, the tests simply won't be run by the testbot at all.... It will be like the test was never written in the first place.
This is more than a theoretical concern, since it's already happened several times. The ones I know about are:
and, one more special one...
Proposed resolution
Write a test that looks through the "lib" directories of all core modules and ensures that all classes which it finds there can actually be found by the PSR-0 autoloader.
Remaining tasks
An initial version of the patch is already written and will be attached in the first comment.
It should work as is, but currently only runs on core modules and isn't easily extensible. We should consider refactoring it into a helper class (to run the tests on a set of locations in the filesystem) and a subclass (to specifically run the test on core modules). This would allow us to also use this to test the "core/lib" and "core/vendor" subdirectories (thereby making the Symfony autoloading tests in #1598610: Convert symfony.test to PSR-0 and remove all the files[] instances in system.info obsolete), as well as core themes, etc. It would also be possible to test all contrib modules on a particular site with this too.
Also, this test is going to use up a lot of memory (since it loads up pretty much every file in the codebase and checks them for classes). If that's a concern, we could break it up into separate test classes, perhaps, each only doing a subset of modules.
This should be backportable to Drupal 7 also, although it's less necessary there since the class registry is less fragile in this regard. But if you forget to list a new test file in the .info file, the same kind of problem can occur, so it wouldn't hurt to backport.
User interface changes
None.
API changes
None.
Beta phase evaluation