/
ruby_base.rb
47 lines (38 loc) · 1011 Bytes
/
ruby_base.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'cerberus/builder/base'
class Cerberus::Builder::RubyBase
attr_reader :output
def initialize(config, name, cmd = name)
@config = config
@cmd = cmd
@name = name
end
def run
@output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @name.to_sym, :task]} 2>&1`
successful?
end
def successful?
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
end
def brokeness
if @output =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
return $1.to_i + $2.to_i
end
end
private
def choose_exec
ext = ['']
if os() == :windows
ext << '.bat' << '.cmd'
end
silence_stream(STDERR) {
ext.each do |e|
begin
out = `#{@config[:bin_path]}#{@cmd}#{e} --version 2>&1`
return "#{@cmd}#{e}" if out =~ /#{@cmd}/
rescue
end
end
}
raise "#{@cmd} builder did not find. Make sure that such script exists and have executable permissions."
end
end