test_runner: change-aware test selection
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, node.js
Rechercherichtung
Beginne mit dem Einstiegspunkt node --test, der bestehenden Implementierung von --watch und run({ files }); verfolge anschließend den vom Testrunner verwendeten Resolver. Als erledigt gilt die Auswahl von Tests anhand statischer Modulabhängigkeiten, während Tests mit opaken Abhängigkeiten oder globalen Paketänderungen konservativ ausgeführt werden, mit Testabdeckung für die genannten CJS- und Fälle mit unsichtbaren Abhängigkeiten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What is the problem this feature will solve?
node --test always runs every test file. There is no way to run only the tests affected by a change.
--watch does this, but only while it stays running. CI, a pre-commit hook, or a branch diff all start cold and run everything.
Jest (--onlyChanged) and Vitest (--changed) both do this.
What is the feature you are proposing to solve the problem?
Run only the test files whose module graph reaches a given set of files.
$ node --test --related=src/util.ts # tests that depend on a file
$ git diff --name-only | node --test --related=- # tests affected by a change
Graph-aware, not path-based: a test that imports a module that imports the changed file is selected. Conservative by default, so anything the graph cannot see has to run, and a change to package.json or a lockfile disables filtering entirely.
Paths rather than a --changed=<rev> flag, because that would mean core shelling out to git. There is no VCS dependency anywhere in lib/ today and I don't think this justifies introducing one. --changed can be layered on later if the team wants it.
Things to figure out
- CJS. Static imports can be extracted from an ES module without executing it. There is no equivalent for
require(), since the bundled lexer reports exports rather than requires. CJS files would be opaque: any test reaching one always runs. Correct, but a CJS-heavy project gets little out of this. - Invisible dependencies. A test that reads a fixture with
fs, or uses dynamicimport(), cannot be selected statically. Those have to resolve to "run it".
Under-selection is the failure mode that matters. Silently skipping a test the change broke is worse than not having the feature.
What alternatives have you considered?
Userland: a wrapper computing the list and passing it to run({ files }). Every such tool has to reimplement module resolution, and gets TypeScript, subpath imports and node_modules boundaries subtly wrong. The resolver is already in core.
--test-rerun-failures covers rerunning what failed, not running what a change could break.
cc @nodejs/test_runner
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.4k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 277
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nodejs/node
-
doc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
build
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
feature request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Ähnliche Issues
-
Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Automattic/safe-publish#594 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
NousResearch/hermes-agent#121143 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100