Class: Rgot::M

Inherits:
Object
  • Object
show all
Defined in:
lib/rgot/m.rb

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Constructor Details

#initialize(tests:, benchmarks:, examples:, opts: Options.new) ⇒ M



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rgot/m.rb', line 15

def initialize(tests:, benchmarks:, examples:, opts: Options.new)
  cpu = opts.cpu || (Etc.respond_to?(:nprocessors) ? Etc.nprocessors : '1').to_s
  @cpu_list = cpu.split(',').map { |i|
    j = i.to_i
    raise Rgot::OptionError, "invalid value #{i.inspect} for --cpu" unless 0 < j
    j
  }
  @thread_list = (opts.thread || "1").split(',').map { |i|
    j = i.to_i
    raise Rgot::OptionError, "invalid value #{i.inspect} for --thread" unless 0 < j
    j
  }
  @tests = tests
  @benchmarks = benchmarks
  @examples = examples
  @opts = opts
end

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rgot/m.rb', line 33

def run
  test_ok = false
  example_ok = false

  Timeout.timeout(@opts.timeout.to_f) do
    test_ok = run_tests
    example_ok = run_examples
  end
  if !test_ok || !example_ok
    puts "FAIL"
    return 1
  end
  puts "PASS"
  run_benchmarks
  0
end