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
- #create_param_values(parameters) ⇒ Object private
- #get_code_snippet(filename, number) ⇒ Object private
- #handle_failure(message, exception, execution_time, recoverable) ⇒ Object private
- #handle_hooks_execution(hooks, message, currentExecutionInfo, should_filter = true) ⇒ Object private
- #handle_pass(message, execution_time) ⇒ Object private
- #screenshot_bytes ⇒ Object private
- #time_elapsed_since(start_time) ⇒ Object private
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.
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/processors/execution_handler.rb', line 78 def create_param_values parameters params = [] parameters.each do |param| if ((param.parameterType == :Table) ||(param.parameterType == :Special_Table)) gtable = Gauge::Table.new(param.table) params.push gtable else params.push param.value end end return params end |
#get_code_snippet(filename, number) ⇒ 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.
58 59 60 61 62 |
# File 'lib/processors/execution_handler.rb', line 58 def get_code_snippet(filename, number) return nil if number < 1 line = File.readlines(filename)[number-1] number.to_s + " | " + line.strip + "\n\n" end |
#handle_failure(message, exception, execution_time, recoverable) ⇒ 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 51 52 53 54 55 56 |
# File 'lib/processors/execution_handler.rb', line 39 def handle_failure(, exception, execution_time, recoverable) project_dir = File.basename(Dir.getwd) stacktrace = exception.backtrace.select {|x| x.match(project_dir) && !x.match(File.join(project_dir, "vendor"))}.join("\n")+"\n" filepath = stacktrace.split("\n").first.split(":").first line_number = stacktrace.split("\n").first.split("/").last.split(":")[1] code_snippet = "\n" + '> ' + get_code_snippet(filepath, line_number.to_i) execution_status_response = Messages::ExecutionStatusResponse.new( :executionResult => Messages::ProtoExecutionResult.new(:failed => true, :recoverableError => recoverable, :errorMessage => exception., :stackTrace => code_snippet + stacktrace, :executionTime => execution_time)) screenshot = screenshot_bytes execution_status_response.executionResult.screenShot = screenshot if !screenshot.nil? Messages::Message.new(:messageType => :ExecutionStatusResponse, :messageId => ., :executionStatusResponse => execution_status_response) end |
#handle_hooks_execution(hooks, message, currentExecutionInfo, should_filter = true) ⇒ 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, , currentExecutionInfo, should_filter=true) start_time= Time.now execution_error = Executor.execute_hooks(hooks, currentExecutionInfo, should_filter) if execution_error == nil return handle_pass , time_elapsed_since(start_time) else return handle_failure , execution_error, time_elapsed_since(start_time), false 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(, execution_time) execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => execution_time)) Messages::Message.new(:messageType => :ExecutionStatusResponse, :messageId => ., :executionStatusResponse => execution_status_response) end |
#screenshot_bytes ⇒ 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.
64 65 66 67 68 69 70 71 72 |
# File 'lib/processors/execution_handler.rb', line 64 def screenshot_bytes return nil if (ENV['screenshot_on_failure'] || "").downcase == "false" || (which("gauge_screenshot").nil? && !Configuration.instance.custom_screengrabber) begin Configuration.instance.screengrabber.call rescue Exception => e Gauge::Log.error e return nil end 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.
74 75 76 |
# File 'lib/processors/execution_handler.rb', line 74 def time_elapsed_since(start_time) ((Time.now-start_time) * 1000).round end |