Sha256: 0d5cb669aa0d8b773bfbd8ee7613e01a756a31a2c9a336b1141e60e3b6edb253

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Rgot
  class M
    # Ruby-2.0.0 wants default value of keyword_argument
    def initialize(tests: [], benchmarks: [], opts: {})
      @tests = tests
      @benchmarks = benchmarks
      @opts = opts
    end

    def run
      test_ok = run_tests
      benchmark_ok = run_benchmarks
      if !test_ok || !benchmark_ok
        puts "FAIL"
        1
      else
        puts "PASS"
        0
      end
    end

    private

    def run_tests
      ok = true
      @tests.each do |test|
        t = T.new(test.module, test.name.to_sym, @opts)
        if @opts[:verbose]
          puts "=== RUN #{test.name}\n"
        end
        t.run
        t.report
        if t.failed?
          ok = false
        end
      end
      ok
    end

    def run_benchmarks
      ok = true
      return ok unless @opts[:bench]
      @benchmarks.each do |bench|
        next unless /#{@opts[:bench]}/ =~ bench.name

        b = B.new(bench.module, bench.name.to_sym, @opts)
        b.run
        b.report
        if b.failed?
          ok = false
        end
      end
      ok
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rgot-0.0.2 lib/rgot/m.rb