Module: Gauge::Processors::ExecutionHandler Private

Included in:
Gauge::Processors
Defined in:
lib/processors/execution_handler.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#create_param_values(parameters) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/processors/execution_handler.rb', line 65

def create_param_values parameters
  params = []
  parameters.each do |param|
    if ((param.parameterType == Messages::Parameter::ParameterType::Table) ||(param.parameterType == Messages::Parameter::ParameterType::Special_Table))
      gtable = Gauge::Table.new(param.table)
      params.push gtable
    else
      params.push param.value
    end
  end
  return params
end

#handle_failure(message, exception, execution_time) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/processors/execution_handler.rb', line 39

def handle_failure(message, exception, execution_time)
  execution_status_response = 
    Messages::ExecutionStatusResponse.new(
      :executionResult => Messages::ProtoExecutionResult.new(:failed => true,
       :recoverableError => false,
       :errorMessage => exception.message,
       :stackTrace => exception.backtrace.join("\n")+"\n",
       :executionTime => execution_time,
       :screenShot => screenshot_bytes))
  Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse,
    :messageId => message.messageId, :executionStatusResponse => execution_status_response)
end

#handle_hooks_execution(hooks, message, currentExecutionInfo) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
# File 'lib/processors/execution_handler.rb', line 24

def handle_hooks_execution(hooks, message, currentExecutionInfo)
  start_time= Time.now
  execution_error = Executor.execute_hooks(hooks, currentExecutionInfo)
  if execution_error == nil
    return handle_pass message, time_elapsed_since(start_time)
  else
    return handle_failure message, execution_error, time_elapsed_since(start_time)
  end
end

#handle_pass(message, execution_time) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
# File 'lib/processors/execution_handler.rb', line 34

def handle_pass(message, execution_time)
  execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => execution_time))
  Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse, :messageId => message.messageId, :executionStatusResponse => execution_status_response)
end

#screenshot_bytesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
56
57
58
59
# File 'lib/processors/execution_handler.rb', line 52

def screenshot_bytes
  return nil if (ENV['screenshot_enabled'] || "").downcase == "false" || which("gauge_screenshot").nil?
  file = File.open("#{Dir.tmpdir}/screenshot.png", "w+")
  `gauge_screenshot #{file.path}`
  file_content = File.binread(file.path)
  File.delete file
  return file_content
end

#time_elapsed_since(start_time) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



61
62
63
# File 'lib/processors/execution_handler.rb', line 61

def time_elapsed_since(start_time)
  ((Time.now-start_time) * 1000).round
end