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
- #get_filepath(stacktrace) ⇒ 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.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/processors/execution_handler.rb', line 90 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.
70 71 72 73 74 |
# File 'lib/processors/execution_handler.rb', line 70 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 |
#get_filepath(stacktrace) ⇒ 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.
41 42 43 44 |
# File 'lib/processors/execution_handler.rb', line 41 def get_filepath(stacktrace) toptrace = stacktrace.split("\n").first return MethodCache.relative_filepath toptrace 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.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/processors/execution_handler.rb', line 46 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 = get_filepath(stacktrace) 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 if screenshot execution_status_response.executionResult.screenShot = screenshot execution_status_response.executionResult.failureScreenshot = screenshot end execution_status_response.executionResult.screenshots += Gauge::GaugeScreenshot.instance.pending_screenshot execution_status_response.executionResult. += Gauge::GaugeMessages.instance. 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 38 39 |
# 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)) execution_status_response.executionResult.screenshots += Gauge::GaugeScreenshot.instance.pending_screenshot execution_status_response.executionResult. += Gauge::GaugeMessages.instance. 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.
76 77 78 79 80 81 82 83 84 |
# File 'lib/processors/execution_handler.rb', line 76 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.
86 87 88 |
# File 'lib/processors/execution_handler.rb', line 86 def time_elapsed_since(start_time) ((Time.now-start_time) * 1000).round end |