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: nil, benchmarks: nil, examples: nil, opts: Options.new) ⇒ M

Ruby-2.0.0 wants default value of keyword_argument

Raises:

  • (ArgumentError)


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

def initialize(tests: nil, benchmarks: nil, examples: nil, opts: Options.new)
  raise ArgumentError, "missing keyword: tests" unless tests
  raise ArgumentError, "missing keyword: benchmarks" unless benchmarks
  raise ArgumentError, "missing keyword: examples" unless examples
  cpu = opts.cpu || "#{Etc.respond_to?(:nprocessors) ? Etc.nprocessors : "1"}"
  @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



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

def run
  test_ok = false
  example_ok = false

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