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(exception, execution_time, recoverable) ⇒ Object private
- #handle_hooks_execution(hooks, currentExecutionInfo, should_filter = true) ⇒ Object private
- #handle_pass(execution_time) ⇒ Object private
- #take_screenshot ⇒ 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.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/processors/execution_handler.rb', line 77 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.
57 58 59 60 61 |
# File 'lib/processors/execution_handler.rb', line 57 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.
30 31 32 33 |
# File 'lib/processors/execution_handler.rb', line 30 def get_filepath(stacktrace) toptrace = stacktrace.split("\n").first MethodCache.relative_filepath toptrace end |
#handle_failure(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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/processors/execution_handler.rb', line 35 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_file = take_screenshot if screenshot_file execution_status_response.executionResult.failureScreenshotFile = screenshot_file end execution_status_response.executionResult.screenshotFiles += Gauge::GaugeScreenshot.instance.pending_screenshot execution_status_response.executionResult. += Gauge::GaugeMessages.instance. execution_status_response end |
#handle_hooks_execution(hooks, 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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/processors/execution_handler.rb', line 13 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(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.
23 24 25 26 27 28 |
# File 'lib/processors/execution_handler.rb', line 23 def handle_pass(execution_time) execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => execution_time)) execution_status_response.executionResult.screenshotFiles += Gauge::GaugeScreenshot.instance.pending_screenshot execution_status_response.executionResult. += Gauge::GaugeMessages.instance. execution_status_response end |
#take_screenshot ⇒ 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.
63 64 65 66 67 68 69 70 71 |
# File 'lib/processors/execution_handler.rb', line 63 def take_screenshot return nil if (ENV['screenshot_on_failure'] || "").downcase == "false" || (which("gauge_screenshot").nil? && !Configuration.instance.custom_screengrabber?) begin GaugeScreenshot.instance.capture_to_file rescue Exception => e GaugeLog.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.
73 74 75 |
# File 'lib/processors/execution_handler.rb', line 73 def time_elapsed_since(start_time) ((Time.now-start_time) * 1000).round end |