Class: FuzzBert::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzbert/executor.rb

Defined Under Namespace

Classes: DataProducer

Constant Summary collapse

DEFAULT_POOL_SIZE =
4
DEFAULT_LIMIT =
-1
DEFAULT_HANDLER =
FuzzBert::Handler::FileOutput
DEFAULT_SLEEP_DELAY =
1
DEFAULT_ARGS =
{
  pool_size: DEFAULT_POOL_SIZE,
  limit: DEFAULT_LIMIT,
  handler: DEFAULT_HANDLER.new,
  sleep_delay: DEFAULT_SLEEP_DELAY
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(suites, args = DEFAULT_ARGS) ⇒ Executor

Returns a new instance of Executor.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fuzzbert/executor.rb', line 17

def initialize(suites, args = DEFAULT_ARGS)
  raise ArgumentError.new("No test cases were passed") unless suites

  args ||= DEFAULT_ARGS
  @pool_size = args[:pool_size] || DEFAULT_POOL_SIZE
  @limit = args[:limit] || DEFAULT_LIMIT
  @handler = args[:handler] || DEFAULT_HANDLER.new
  @sleep_delay = args[:sleep_delay] || DEFAULT_SLEEP_DELAY
  @data_cache = {}
  @n = 0
  @exiting = false
  @producer = DataProducer.new(suites)
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



3
4
5
# File 'lib/fuzzbert/executor.rb', line 3

def handler
  @handler
end

#limitObject (readonly)

Returns the value of attribute limit.



3
4
5
# File 'lib/fuzzbert/executor.rb', line 3

def limit
  @limit
end

#pool_sizeObject (readonly)

Returns the value of attribute pool_size.



3
4
5
# File 'lib/fuzzbert/executor.rb', line 3

def pool_size
  @pool_size
end

#sleep_delayObject (readonly)

Returns the value of attribute sleep_delay.



3
4
5
# File 'lib/fuzzbert/executor.rb', line 3

def sleep_delay
  @sleep_delay
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
# File 'lib/fuzzbert/executor.rb', line 31

def run
  trap_child_exit
  trap_interrupt

  @pool_size.times { run_instance(*@producer.next) }
  @running = true
  @limit == -1 ? sleep : conditional_sleep
end