Module: Bulldogger::Probe::Comparator

Defined in:
lib/bulldogger/probe/comparator.rb

Overview

Compares two probe evidence files for behavior-preservation: "did this refactor change what the probed methods actually do."

Compares shape (classes seen, nil_count, raised_exits, calls, the set of callers, parameters), not raw sample values, because the default inspect embeds an object's memory address (e.g. #<Order:0x000000012a>), so two probes of identical, unchanged code would otherwise report differences on every run. Samples are still diffed as a secondary signal, but only after normalizing 0x[0-9a-f]+ out of them for exactly this reason.

Constant Summary collapse

HEX_ADDRESS =
/0x[0-9a-f]+/i

Class Method Summary collapse

Class Method Details

.compare(path_a, path_b) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/bulldogger/probe/comparator.rb', line 22

def compare(path_a, path_b)
  a = JSON.parse(File.read(path_a))
  b = JSON.parse(File.read(path_b))
  differences = []
  compare_methods(a["methods"] || {}, b["methods"] || {}, differences)
  { "identical" => differences.empty?, "differences" => differences }
end