test: keep CommandsTest out of app/Commands so parallel runs do not race - #10564
Conversation
neznaika0
left a comment
There was a problem hiding this comment.
After the tests, there’s still other junk left: the sqlite database, test images, empty folders, etc. Should they be deleted to fully revert to the original state?
If so, then the empty folders probably need to be cleaned up.
michalsn
left a comment
There was a problem hiding this comment.
Wouldn't the simpler solution be to use @rmdir($dir) here - after all, these are just test cleanups (we can add an inline comment for the reason we use these)?
That way we still clean up the directory when it's empty, but we don't fail if another test happens to be using it at the same time.
70adeab to
c8fa36a
Compare
|
The issue here is that both |
michalsn
left a comment
There was a problem hiding this comment.
Okay, thank you - let's see how this works for us.
Description
The random-order workflow runs components in parallel, and two of them share
app/Commands/. That produces this failure in the Commands component:CommandsTest::testDiscoveredCommandsCanBeOverridden(CLI component) copies a fixture intoapp/Commands/, while the generator tests (Commands component) create files there and remove the directory afterwards. Whenever the CLI fixture is present at that moment, thermdir()throws. The reverse can also happen: the directory disappears betweenCommandsTest'smkdir()andcopy().This removes the sharing.
CommandsTestno longer writes toapp/. The override rule lives inCommands::discoverCommands()(the first class to claim a name wins), so the testrequire_onces the_command/ListCommands.phpfixture and feeds discovery through a mocked locator that lists it ahead of the systemListCommands. This is the same pattern the neighbouring discovery tests use. The copy/delete helpers are gone.The generator tests are untouched. Their
rmdir()cleanup is safe because the Commands component is now the only user of that directory, and a component runs as a single sequential process. The tree is fully restored after both sequential and parallel runs, with no error suppression and no leftoverapp/Commands/.Trade-off: the test no longer proves that the real locator lists
Appbeforesystem. It proves the override rule only. The ordering isFileLocator's own contract.Checklist: