A test can change its behavior when a data file changes and every line of application code stays the same. The file might provide examples, a query, or a template. A changed-file list tells us that the file was edited. To choose individual tests, we also need a way to connect that file to the code that reads it. A selector we inspected uses a simple rule for some of those connections and requests a broader run when certain changes are harder to trace. Synthetic fixtures let us see which tests it would choose before asking whether that choice was sufficient.

Follow a data file through its loader

In one fixture, a helper names a JSON file and a test imports the helper. The test does not name the JSON file itself. When we supplied that file as the change, the selector chose the test that imported the helper and left out a separate, unrelated test in the fixture. The result shows that selection can follow a dependency through an intermediate module instead of relying solely on filenames mentioned in the test. The check also gives the unrelated test a purpose. If the selector had simply returned every test, checking only for the presence of the importing test would have passed.

A second fixture put a query in a separate file. An application module named that file, and a test imported that module. The selector again chose the importing test when the data file was the only changed input supplied to it. Together these cases show a way to turn a change outside the programming language into a change the selector can follow. The selector looks for a reference to the file in module text and walks imports from the modules it finds, within a bounded distance. That makes the mapping practical for straightforward loaders. It can still miss connections that exist only while the program is running.

Decide when to ask for the full suite

A third fixture supplied a changed template with no module naming it. The selector requested the full suite. The absence of a name in the inspected text leaves open whether a loader finds the template through a naming convention or whether nothing reads it at all. Choosing a narrower run on that basis would require more information. The fallback makes that uncertainty visible as a broader request, at the cost of giving up the narrower selection for that edit.

A fourth case showed a different reason to request a broad run. A test enumerated a directory of data files, and the input was one changed file in that directory. A test can discover files this way without listing each name in its source. The selector requested the full suite in that fixture. Those two examples give the fallback cases distinct roles. One covers a file for which the selector found no naming module. The other covers a recognized pattern for discovering a group of files. Neither example establishes that the selector recognizes every way a program can build a path or find its inputs.

Check the selector and the tests it selects

All 33 tests in the selector suite passed locally on the merged revision. The cases above checked its decisions on supplied changes. They did not execute the backend tests named in the results. A separate hosted backend run on the pull request head passed its test steps using the full invocation. That result answers whether those hosted test steps passed on that revision. It leaves open what would have happened had the workflow run only the selected tests.

For a practical comparison, we would need to keep the revision and inputs fixed and observe both a targeted run and a full run. Then we could ask which failures each run reported and how much time each took. We did not make that comparison here. The useful result is narrower. For named files in these examples, the selector can follow a loader to an importing test. For the two less direct cases, it can ask for the broader suite. That gives us a way to test the selection rule on a data-only change, including cases where the most appropriate result is to ask for more tests.

← All engineering articles