Class: Cyrun::Runner

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cyrun/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#error, #info

Constructor Details

#initialize(base_directory, pattern, screenshots_pattern, screenshots_directory, group_size, npm_task_name, max_retries: nil, iterations: nil) ⇒ Runner

Returns a new instance of Runner.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cyrun/runner.rb', line 12

def initialize(base_directory, pattern, screenshots_pattern, screenshots_directory, group_size, npm_task_name, max_retries: nil, iterations: nil)
  @collector = SpecCollector.new(base_directory, npm_task_name, [pattern])
  @group_builder = GroupBuilder.new(group_size)
  @task_runner = TaskRunner.new(screenshots_pattern)

  @overall_results = SpecGroupExecutionResult.create_empty
  @max_retries = max_retries
  @iterations = iterations
  @screenshots_directory = screenshots_directory
  @success = true
end

Instance Attribute Details

#collectorObject (readonly)

Returns the value of attribute collector.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def collector
  @collector
end

#group_builderObject (readonly)

Returns the value of attribute group_builder.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def group_builder
  @group_builder
end

#iterationsObject (readonly)

Returns the value of attribute iterations.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def iterations
  @iterations
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def max_retries
  @max_retries
end

#overall_resultsObject (readonly)

Returns the value of attribute overall_results.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def overall_results
  @overall_results
end

#screenshots_directoryObject (readonly)

Returns the value of attribute screenshots_directory.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def screenshots_directory
  @screenshots_directory
end

#successObject (readonly)

Returns the value of attribute success.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def success
  @success
end

#task_runnerObject (readonly)

Returns the value of attribute task_runner.



9
10
11
# File 'lib/cyrun/runner.rb', line 9

def task_runner
  @task_runner
end

Instance Method Details

#runObject



24
25
26
27
28
29
# File 'lib/cyrun/runner.rb', line 24

def run
  collect_specs
  run_next_group while group_builder.any?

  overall_results
end

#store_results(results_directory) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/cyrun/runner.rb', line 31

def store_results(results_directory)
  latest_results = overall_results.latest_results
  invalid_results = latest_results.select { |result| result.result_filename.nil? }
  valid_results = latest_results - invalid_results

  copy_result_files valid_results, results_directory

  invalid_results.empty?
end