Class: Ast::Merge::Git::LocalBenchmarkRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/git/local_benchmark.rb,
sig/ast/merge/git.rbs

Overview

Executes the same authored merge bytes through Git and the installed driver.

Constant Summary collapse

DEFAULT_TIMEOUT =

Returns:

  • (Integer)
30

Instance Method Summary collapse

Constructor Details

#initialize(benchmark:, driver_path:, tmp_root:, timeout: DEFAULT_TIMEOUT) ⇒ LocalBenchmarkRunner

Returns a new instance of LocalBenchmarkRunner.



352
353
354
355
356
357
# File 'lib/ast/merge/git/local_benchmark.rb', line 352

def initialize(benchmark:, driver_path:, tmp_root:, timeout: DEFAULT_TIMEOUT)
  @benchmark = benchmark
  @driver_path = Pathname(driver_path).expand_path
  @tmp_root = Pathname(tmp_root).expand_path
  @timeout = Integer(timeout)
end

Instance Method Details

#run(profile:, changed_paths: []) ⇒ Hash[String, untyped]

Parameters:

  • profile: (String, Symbol)
  • changed_paths: (Array[String]) (defaults to: [])

Returns:

  • (Hash[String, untyped])


359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/ast/merge/git/local_benchmark.rb', line 359

def run(profile:, changed_paths: [])
  verify_environment!
  selection = @benchmark.select(profile: profile, changed_paths: changed_paths)
  original_cwd = Dir.pwd
  results = selection['selected_case_ids'].flat_map do |id|
    execute_case(@benchmark.case_by_id(id))
  end
  raise LocalBenchmark::Error, 'runner changed its working directory' unless Dir.pwd == original_cwd

  {
    'schema_version' => 'structuredmerge.benchmark.run/v1',
    'kind' => 'paired_local_run',
    'corpus_id' => @benchmark.document['id'],
    'corpus_digest' => @benchmark.corpus_digest,
    'selection' => selection,
    'cache_identity' => cache_identity(selection),
    'results' => results
  }
ensure
  Dir.chdir(original_cwd) if original_cwd && Dir.pwd != original_cwd
end