Class: Rgot::M
- Inherits:
-
Object
- Object
- Rgot::M
- Defined in:
- lib/rgot/m.rb
Defined Under Namespace
Classes: Options
Instance Method Summary collapse
-
#initialize(tests:, benchmarks:, examples:, fuzz_targets: nil, test_module: nil, opts: Options.new) ⇒ M
constructor
A new instance of M.
- #run ⇒ Object
Constructor Details
#initialize(tests:, benchmarks:, examples:, fuzz_targets: nil, test_module: nil, opts: Options.new) ⇒ M
Returns a new instance of M.
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 |
# File 'lib/rgot/m.rb', line 19 def initialize(tests:, benchmarks:, examples:, fuzz_targets: nil, test_module: nil, opts: Options.new) unless fuzz_targets raise "Require `fuzz_targets` keyword" if Gem::Version.new("2.0") <= Gem::Version.new(Rgot::VERSION) warn "`Rgot::M#initialize` will require the `fuzz_targets` keyword in the next major version." end unless test_module raise "Require `test_module` keyword" if Gem::Version.new("2.0") <= Gem::Version.new(Rgot::VERSION) warn "`Rgot::M#initialize` will require the `test_module` keyword in the next major version." end @tests = tests @benchmarks = benchmarks @examples = examples @fuzz_targets = fuzz_targets || [] @test_module = test_module @opts = opts @cpu_list = [] @thread_list = [] @fs = @fuzz_targets.map do |fuzz_target| F.new( fuzz_target: fuzz_target, opts: F::Options.new( fuzz: opts.fuzz, fuzztime: opts.fuzztime, ) ) end end |
Instance Method Details
#run ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rgot/m.rb', line 49 def run duration = Rgot.now test_ok = false fuzz_targets_ok = false example_ok = false if @tests.empty? && @benchmarks.empty? && @examples.empty? && @fuzz_targets.empty? warn "rgot: warning: no tests to run" end begin parse_option rescue Rgot::OptionError puts sprintf("%s\t%s\t%.3fs", "FAIL", @test_module, Rgot.now - duration) raise end Timeout.timeout(@opts.timeout.to_f) do test_ok = run_tests fuzz_targets_ok = run_fuzz_tests example_ok = run_examples end if !test_ok || !example_ok || !fuzz_targets_ok puts "FAIL" puts "exit status 1" puts sprintf("%s\t%s\t%.3fs", "FAIL", @test_module, Rgot.now - duration) return 1 end if !run_fuzzing() puts "FAIL" puts "exit status 1" puts sprintf("%s\t%s\t%.3fs", "FAIL", @test_module, Rgot.now - duration) return 1 end puts "PASS" run_benchmarks puts sprintf("%s\t%s\t%.3fs", "ok ", @test_module, Rgot.now - duration) 0 end |