Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/support/json_formatter.rb')
-rw-r--r--qa/qa/support/json_formatter.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/qa/qa/support/json_formatter.rb b/qa/qa/support/json_formatter.rb
new file mode 100644
index 00000000000..5d2a3e7b75f
--- /dev/null
+++ b/qa/qa/support/json_formatter.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+require 'rspec/core/formatters'
+
+module QA
+ module Support
+ class JsonFormatter < RSpec::Core::Formatters::JsonFormatter
+ RSpec::Core::Formatters.register self, :message, :dump_summary, :stop, :seed, :close
+
+ def dump_profile(profile)
+ # We don't currently use the profile info. This overrides the base
+ # implementation so that it's not included.
+ end
+
+ def stop(notification)
+ # Based on https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/formatters/json_formatter.rb#L35
+ # But modified to include full details of multiple exceptions
+ @output_hash[:examples] = notification.examples.map do |example|
+ format_example(example).tap do |hash|
+ e = example.exception
+ if e
+ exceptions = e.respond_to?(:all_exceptions) ? e.all_exceptions : [e]
+ hash[:exceptions] = exceptions.map do |exception|
+ {
+ class: exception.class.name,
+ message: exception.message,
+ backtrace: exception.backtrace
+ }
+ end
+ end
+ end
+ end
+ end
+
+ private
+
+ def format_example(example)
+ {
+ id: example.id,
+ description: example.description,
+ full_description: example.full_description,
+ status: example.execution_result.status.to_s,
+ file_path: example.metadata[:file_path],
+ line_number: example.metadata[:line_number],
+ run_time: example.execution_result.run_time,
+ pending_message: example.execution_result.pending_message,
+ status_issue: example.metadata[:status_issue],
+ quarantine: example.metadata[:quarantine],
+ screenshot: example.metadata[:screenshot]
+ }
+ end
+ end
+ end
+end