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.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/processors/execution_handler.rb', line 76 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.
56 57 58 59 60 |
# File 'lib/processors/execution_handler.rb', line 56 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.
29 30 31 32 |
# File 'lib/processors/execution_handler.rb', line 29 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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/processors/execution_handler.rb', line 34 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.
12 13 14 15 16 17 18 19 20 |
# File 'lib/processors/execution_handler.rb', line 12 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.
22 23 24 25 26 27 |
# File 'lib/processors/execution_handler.rb', line 22 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.
62 63 64 65 66 67 68 69 70 |
# File 'lib/processors/execution_handler.rb', line 62 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.
72 73 74 |
# File 'lib/processors/execution_handler.rb', line 72 def time_elapsed_since(start_time) ((Time.now-start_time) * 1000).round end |