fix(tia): select only the tests that touch a changed migration's tables - #1879
Open
talaridisTh wants to merge 1 commit into
Open
fix(tia): select only the tests that touch a changed migration's tables#1879talaridisTh wants to merge 1 commit into
talaridisTh wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Description:
On a Laravel suite whose base
TestCaseusesRefreshDatabase, changing any migration makes--tiaselect the entire suite, even though the graph already knows exactly which tables each test file queried.The cause is
Tia::augmentDatabaseTestTables: every test whose class usesRefreshDatabase/DatabaseMigrations/DatabaseTransactionsgets every table declared underdatabase/migrationsmerged into its recorded table list, whether or not it recorded tables of its own. With the trait on the base class, that is every test, soGraph::applyMigrationChangesintersects the changed migration against a table list that contains everything, and a one-column migration onordersre-runs 13k tests. On the suite I measured, that is the difference between a few seconds and a full run on every migration.This keeps the conservative behaviour only where it is needed:
ordersnow selects the tests that queriedorders, which is what the table tracking exists for.Graph::applyMigrationChangesroutes a parseable migration that matches no recorded test through the watch-pattern fallback, the same path an unparseable migration takes. Before, that case could only happen withoutRefreshDatabase; now it is reachable for every suite, and it must not silently select nothing.The augmentation moves out of the plugin into
Tia\DatabaseTestTablesso it can be unit tested; the traversal ofdatabase/migrationsis unchanged.Tests:
tests/Unit/Plugins/Tia/DatabaseTestTables.phpcovers the three shapes (tracked, untracked, no database), andGraph.phpgains the no-match fallback and the no-match-no-pattern case.tests/Features/Tia(200) andtests/Unit/Plugins/Tia(174) pass,composer lintandcomposer test:type:checkare clean.