Class: Bparity::Adequacy::MutantBridge

Inherits:
Object
  • Object
show all
Defined in:
lib/bparity/adequacy.rb

Constant Summary collapse

SCORE =
/Mutation coverage:\s*([\d.]+)%/

Instance Method Summary collapse

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/bparity/adequacy.rb', line 10

def available?
  _output, _error, status = Open3.capture3("bundle", "exec", "mutant", "--version")
  status.success?
rescue Errno::ENOENT
  false
end

#runObject



17
18
19
20
21
22
23
24
25
# File 'lib/bparity/adequacy.rb', line 17

def run
  return { "status" => "skipped", "reason" => "mutant is not installed" } unless available?

  output, error, status = Open3.capture3("bundle", "exec", "mutant", "run")
  match = output.match(SCORE)
  score = match[1].to_f if match
  { "status" => status.success? ? "completed" : "failed", "score" => score,
    "output" => output, "error" => error }
end