Skip to main content

Module deps

Module deps 

Source
Expand description

Test impact analysis: which test files a change can affect.

The graph links every file of the project to the files it uses, as far as they can be read from the source:

  • in a script: extends, preload/load and any other "res://…" or "uid://…" string, the class_name of another script used by name, and an autoload used by name;
  • in a scene or text resource (.tscn, .tres): its ext_resources.

A test file is affected by a change when it reaches a changed file through these links. What the source cannot tell is handled cautiously:

  • a script that loads a computed path (load(path)) may load any file, so the tests that reach it always run; with a known folder (load("res://items/" + id)), it depends on every file of that folder;
  • project.godot, the autoloads and the test runner’s own files change what every test runs with, so a change to one of them affects every test.

What the tests did when they last ran adds to that, as Vitest learns a test’s dynamic imports by running it: the worker reports the scenes and scripts of the nodes each test added to the tree, and record_uses keeps them per test file. A test file uses what it was seen to use, and once seen, a computed load() it reaches no longer makes it run on every change.

Structs§

FileDeps
What one file uses, read from its source.
Graph
The project’s dependency graph.

Enums§

Impact
Which test files a change affects.

Functions§

affected_files
Every file that uses one of changed, directly or not, without the changed files themselves.
build_dep_graph
Forward and reverse graphs of the project. See Graph::build.
parse_file_deps
The res:// paths a script names in extends, preload and load. Kept for callers of the first version; parse_script reads more.
parse_script
Reads what a script uses.
parse_text_resource
Reads what a scene or text resource uses: its ext_resources.
read_uses
What each test file was seen to use: test file → res:// paths.
record_uses
Adds what the test files of a run used to what was seen before. Kept across runs, so a test that loads different scenes on different runs depends on all of them.
uses_path
Where gdtest keeps what each test file used when it last ran.

Type Aliases§

DepGraph
Maps res:// path → set of res:// paths.