Skip to content

fix(go): drop test-binary pseudo-packages from inferred relationships - #2

Closed
jonpoole-fluidstack wants to merge 1 commit into
jon/go-single-module-import-inferencefrom
jon/go-test-binary-root-edge
Closed

fix(go): drop test-binary pseudo-packages from inferred relationships#2
jonpoole-fluidstack wants to merge 1 commit into
jon/go-single-module-import-inferencefrom
jon/go-test-binary-root-edge

Conversation

@jonpoole-fluidstack

Copy link
Copy Markdown
Owner

Stacks on #1 (import-path relationship inference).

With test inference on (inferRelationshipsFromTests), Go projects were picking up a phantom development edge to the module-root project. go list -deps -test reports a synthetic pkg.test package for every tested package; its bare .test suffix means it never matches the package under test (pkg.test isn't nested under pkg/), so it fell through prefix matching to the nearest enclosing project — usually the repo root — as a spurious lib-x -> root [development] edge.

The existing pkg [pkg.test] space form was already handled; the bare pkg.test line was not.

Fix: reduce the pkg.test line to its real package path, so ownership filtering recognises it as the project's own test and drops it.

Package under test Before After
.../libs/b (has _test.go) b -> root [dev] (no edge)

Added a regression test (doesnt_infer_edges_to_root_from_test_binary_pseudo_packages) with a libs/b/lib_test.go fixture and a root project in sources; it fails on the bare-suffix bug and passes with the fix. Full go-toolchain suite green.

`go list -deps -test` reports a synthetic `pkg.test` package for every
tested package. Its bare `.test` suffix meant it never matched the package
under test, so it fell through to the nearest enclosing project — usually
the module root — and produced a phantom development edge (e.g. `lib-x ->
root`).

Reduce the `pkg.test` line to its real package path so ownership filtering
claims it, and add a regression test covering a tested package nested under
a single-module root that is itself a project.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant