2019-06-20 21:33:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-06-27 11:41:09 -04:00
|
|
|
require "bundler/setup"
|
|
|
|
|
2019-06-20 20:59:01 -04:00
|
|
|
require "open3"
|
|
|
|
require "fileutils"
|
|
|
|
require "json"
|
|
|
|
require "rspec"
|
|
|
|
require "rails"
|
2019-06-27 11:41:09 -04:00
|
|
|
require File.expand_path("../../config/environment", __FILE__)
|
2019-06-20 20:59:01 -04:00
|
|
|
|
|
|
|
require "parallel_tests"
|
|
|
|
require "parallel_tests/rspec/runner"
|
|
|
|
|
|
|
|
require "./lib/turbo_tests/reporter"
|
|
|
|
require "./lib/turbo_tests/runner"
|
|
|
|
require "./lib/turbo_tests/json_rows_formatter"
|
2023-05-12 05:13:52 -04:00
|
|
|
require "./lib/turbo_tests/documentation_formatter"
|
2019-06-20 20:59:01 -04:00
|
|
|
|
|
|
|
module TurboTests
|
|
|
|
FakeException = Struct.new(:backtrace, :message, :cause)
|
|
|
|
class FakeException
|
|
|
|
def self.from_obj(obj)
|
|
|
|
if obj
|
|
|
|
obj = obj.symbolize_keys
|
2019-06-27 06:43:12 -04:00
|
|
|
|
|
|
|
klass = Class.new(FakeException) { define_singleton_method(:name) { obj[:class_name] } }
|
|
|
|
|
2019-06-27 06:37:23 -04:00
|
|
|
klass.new(obj[:backtrace], obj[:message], FakeException.from_obj(obj[:cause]))
|
2019-06-20 20:59:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-07 14:07:45 -05:00
|
|
|
FakeExecutionResult =
|
|
|
|
Struct.new(
|
|
|
|
:example_skipped?,
|
|
|
|
:pending_message,
|
|
|
|
:status,
|
|
|
|
:pending_fixed?,
|
|
|
|
:exception,
|
|
|
|
:pending_exception,
|
|
|
|
)
|
2019-06-20 20:59:01 -04:00
|
|
|
class FakeExecutionResult
|
|
|
|
def self.from_obj(obj)
|
|
|
|
obj = obj.symbolize_keys
|
|
|
|
new(
|
|
|
|
obj[:example_skipped?],
|
|
|
|
obj[:pending_message],
|
|
|
|
obj[:status].to_sym,
|
|
|
|
obj[:pending_fixed?],
|
2021-12-07 14:07:45 -05:00
|
|
|
FakeException.from_obj(obj[:exception]),
|
|
|
|
FakeException.from_obj(obj[:pending_exception]),
|
2019-06-20 20:59:01 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
FakeExample =
|
2023-05-12 05:13:52 -04:00
|
|
|
Struct.new(
|
|
|
|
:execution_result,
|
|
|
|
:location,
|
|
|
|
:description,
|
|
|
|
:full_description,
|
|
|
|
:metadata,
|
|
|
|
:location_rerun_argument,
|
|
|
|
:process_id,
|
|
|
|
)
|
|
|
|
|
2019-06-20 20:59:01 -04:00
|
|
|
class FakeExample
|
2023-05-12 05:13:52 -04:00
|
|
|
def self.from_obj(obj, process_id)
|
2019-06-20 20:59:01 -04:00
|
|
|
obj = obj.symbolize_keys
|
2019-08-29 07:40:06 -04:00
|
|
|
metadata = obj[:metadata].symbolize_keys
|
|
|
|
|
|
|
|
metadata[:shared_group_inclusion_backtrace].map! do |frame|
|
|
|
|
frame = frame.symbolize_keys
|
|
|
|
RSpec::Core::SharedExampleGroupInclusionStackFrame.new(
|
|
|
|
frame[:shared_group_name],
|
|
|
|
frame[:inclusion_location],
|
|
|
|
)
|
2023-01-09 07:10:19 -05:00
|
|
|
end
|
2019-08-29 07:40:06 -04:00
|
|
|
|
2019-06-20 20:59:01 -04:00
|
|
|
new(
|
|
|
|
FakeExecutionResult.from_obj(obj[:execution_result]),
|
|
|
|
obj[:location],
|
2023-05-12 05:13:52 -04:00
|
|
|
obj[:description],
|
2019-06-20 20:59:01 -04:00
|
|
|
obj[:full_description],
|
2019-08-29 07:40:06 -04:00
|
|
|
metadata,
|
2019-06-20 20:59:01 -04:00
|
|
|
obj[:location_rerun_argument],
|
2023-05-12 05:13:52 -04:00
|
|
|
process_id,
|
2019-06-20 20:59:01 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def notification
|
|
|
|
RSpec::Core::Notifications::ExampleNotification.for(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|