Class: Testprune::Analysis
- Inherits:
-
Object
- Object
- Testprune::Analysis
- Defined in:
- lib/testprune/analysis.rb
Overview
Loads run.json, builds semantic footprints, runs detection + safety, and bundles everything the report and patch writer need.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(config) ⇒ Analysis
constructor
A new instance of Analysis.
Constructor Details
#initialize(config) ⇒ Analysis
Returns a new instance of Analysis.
21 22 23 |
# File 'lib/testprune/analysis.rb', line 21 def initialize(config) @config = config end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/testprune/analysis.rb', line 25 def call unless File.directory?(@config.root) raise Error, "root directory #{@config.root.inspect} does not exist. " \ "Check TESTPRUNE_ROOT or --root." end unless File.exist?(@config.run_file) raise Error, "no coverage data found. Run `testprune run` first to capture per-test coverage." end run = begin JSON.parse(File.read(@config.run_file)) rescue JSON::ParserError => e raise Error, "run.json is not valid JSON (#{e.}) — it may be truncated. " \ "Re-run 'testprune run'." end index = SemanticIndex.new(run['root'] || @config.root) footprints = index.build_footprints(run['tests'] || []) detector = DuplicationDetector.new( footprints, overlap_threshold: @config.overlap_threshold, baseline_fraction: @config.baseline_fraction ).call Result.new(detector_result: detector, index: index, savings: SavingsEstimator.new(run, detector), run: run) end |