Class: Henitai::MutantHistoryStore
- Inherits:
-
Object
- Object
- Henitai::MutantHistoryStore
- Includes:
- VerdictCache
- Defined in:
- lib/henitai/mutant_history_store.rb,
lib/henitai/mutant_history_store/sql.rb,
lib/henitai/mutant_history_store/verdict_cache.rb,
sig/henitai.rbs
Overview
Persists mutant outcomes across runs in a lightweight SQLite database.
Defined Under Namespace
Modules: Sql, VerdictCache
Constant Summary
Constants included from VerdictCache
VerdictCache::CACHEABLE_STATUSES
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:, per_test_coverage: nil) ⇒ MutantHistoryStore
constructor
A new instance of MutantHistoryStore.
-
#killed_verdict_for(stable_id) ⇒ Hash[Symbol, untyped]?
Killed-only view of #verdict_for, kept for the original killed reuse path.
- #record(result, version:, recorded_at: Time.now.utc) ⇒ void
- #trend_report ⇒ Hash[Symbol, untyped]
-
#verdict_for(stable_id) ⇒ Hash[Symbol, untyped]?
Verdict-cache lookup for
--incremental: returns the stored hashes for the mutant's LATEST verdict when it is Killed or Survived — the upsert keeps exactly one row per stable id, so current_status is always the most recent outcome.
Constructor Details
#initialize(path:, per_test_coverage: nil) ⇒ MutantHistoryStore
Returns a new instance of MutantHistoryStore.
20 21 22 23 |
# File 'lib/henitai/mutant_history_store.rb', line 20 def initialize(path:, per_test_coverage: nil) @path = path @per_test_coverage = per_test_coverage end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/henitai/mutant_history_store.rb', line 25 def path @path end |
Instance Method Details
#killed_verdict_for(stable_id) ⇒ Hash[Symbol, untyped]?
Killed-only view of #verdict_for, kept for the original killed reuse path.
57 58 59 60 |
# File 'lib/henitai/mutant_history_store.rb', line 57 def killed_verdict_for(stable_id) verdict = verdict_for(stable_id) verdict if verdict && verdict[:status] == :killed end |
#record(result, version:, recorded_at: Time.now.utc) ⇒ void
This method returns an undefined value.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/henitai/mutant_history_store.rb', line 27 def record(result, version:, recorded_at: Time.now.utc) FileUtils.mkdir_p(File.dirname(path)) with_database do |db| ensure_schema(db) db.transaction do insert_run(db, result, version, recorded_at) unless partial_rerun?(result) Array(result.mutants).each do |mutant| upsert_mutant(db, mutant, version, recorded_at) end end end end |
#trend_report ⇒ Hash[Symbol, untyped]
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/henitai/mutant_history_store.rb', line 62 def trend_report with_database do |db| ensure_schema(db) { generatedAt: Time.now.utc.iso8601, runs: load_runs(db), mutants: load_mutants(db) } end end |
#verdict_for(stable_id) ⇒ Hash[Symbol, untyped]?
Verdict-cache lookup for --incremental: returns the stored hashes for
the mutant's LATEST verdict when it is Killed or Survived — the upsert
keeps exactly one row per stable id, so current_status is always the
most recent outcome. nil for every other status, unknown ids and legacy
rows without hashes (recorded before the cache columns existed).
46 47 48 49 50 51 52 53 |
# File 'lib/henitai/mutant_history_store.rb', line 46 def verdict_for(stable_id) return nil unless File.exist?(path) with_database do |db| ensure_schema(db) verdict_from_row(db.get_first_row(Sql::VERDICT_LOOKUP, stable_id)) end end |