Examples.EXref (gt_bridge v0.17.3)

Copy Markdown View Source

I exercise the long-lived GtBridge.Xref service end-to-end and the refactored callers (function_references/3, module_graph/1) that depend on it. Acts as a regression catcher for the substrate cleanup — if anyone removes the xref subscription or the supervision child, these examples go red.

Summary

Functions

I find callers of GtBridge.Xref.q/1 — known to be called from GtBridge.Analysis (function_references/3 and module_graph/1 both use it). Asserts the long-lived xref index sees these and returns hydrated entries with module/name/arity.

I run a real call-graph query and verify the long-lived index sees edges from this very module. Uses GtBridge.Analysis.module_graph/1 scoped to gt_bridge so the result set is bounded.

I prove the xref index reacts to BeamModuleRecompiled events. Insert a fake module in the index, broadcast a recompile event for a known module, and assert the xref query reflects the BEAM's current state.

I assert that the long-lived xref process is registered, indexed, and answering basic queries. Returns the loaded-modules count so callers can sanity-check it grew with the BEAM.

Callback implementation for ExExample.Behaviour.copy/1.

Callback implementation for ExExample.Behaviour.rerun?/1.

Functions

__ex_example__function_references_finds_callers__()

I find callers of GtBridge.Xref.q/1 — known to be called from GtBridge.Analysis (function_references/3 and module_graph/1 both use it). Asserts the long-lived xref index sees these and returns hydrated entries with module/name/arity.

__ex_example__module_graph_finds_edges__()

I run a real call-graph query and verify the long-lived index sees edges from this very module. Uses GtBridge.Analysis.module_graph/1 scoped to gt_bridge so the result set is bounded.

__ex_example__recompile_event_keeps_index_valid__()

I prove the xref index reacts to BeamModuleRecompiled events. Insert a fake module in the index, broadcast a recompile event for a known module, and assert the xref query reflects the BEAM's current state.

Indirect verification — we can't easily diff xref state before/after without another query — so we just assert the recompile path doesn't crash and the post-recompile query still works.

__ex_example__running__()

I assert that the long-lived xref process is registered, indexed, and answering basic queries. Returns the loaded-modules count so callers can sanity-check it grew with the BEAM.

copy(item)

Callback implementation for ExExample.Behaviour.copy/1.

function_references_finds_callers()

@spec function_references_finds_callers() :: [map()]

module_graph_finds_edges()

@spec module_graph_finds_edges() :: non_neg_integer()

recompile_event_keeps_index_valid()

@spec recompile_event_keeps_index_valid() :: non_neg_integer()

rerun?(_)

Callback implementation for ExExample.Behaviour.rerun?/1.

running()

@spec running() :: non_neg_integer()