7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/ruby_ci/runner_prepend.rb', line 7
def run_specs(example_groups)
@rspec_started_at = Time.now
json_events = {
build_id: RubyCI.configuration.orig_build_id,
compressed_data: Base64.strict_encode64(Zlib::Deflate.deflate(JSON.fast_generate([['RSPEC_RUN', { started_at: @rspec_started_at, test_env_number: ENV["TEST_ENV_NUMBER"] }]]), 9)),
}
RubyCI.send_events(json_events)
examples_count = @world.example_count(example_groups)
example_groups = example_groups.reduce({}) do |acc, ex_group|
if acc[ex_group.file_path]
acc[ex_group.file_path] << ex_group
else
acc[ex_group.file_path] = [ex_group]
end
acc
end
RubyCI.configure { |c| c.run_key = "rspec" }
RubyCI.rspec_ws.on(:enq_request) do
example_groups.reduce({}) do |example_group_descriptions, (file, example_groups)|
example_groups.each do |example_group|
data = RubyCI::ExtractDescriptions.new.call(example_group, count: true)
next if data[:test_count] == 0
if example_group_descriptions[file]
example_group_descriptions[file].merge!(data) do |k, v1, v2|
v1 + v2
end
else
example_group_descriptions[file] = data
end
end
example_group_descriptions
end
end
examples_passed = @configuration.reporter.report(examples_count) do |reporter|
@configuration.with_suite_hooks do
if examples_count == 0 && @configuration.fail_if_no_examples
return @configuration.failure_exit_code
end
formatter = RubyCI::RspecFormatter.new(STDOUT)
reporter.register_listener(formatter, :example_finished)
if ENV['RBCI_REMOTE_TESTS'] == 'true'
reporter.register_listener(formatter, :start)
reporter.register_listener(formatter, :example_group_started)
reporter.register_listener(formatter, :example_started)
reporter.register_listener(formatter, :example_passed)
reporter.register_listener(formatter, :example_failed)
reporter.register_listener(formatter, :example_pending)
reporter.register_listener(formatter, :example_group_finished)
reporter.register_listener(formatter, :close)
end
RubyCI.rspec_ws.on(:deq) do |tests|
tests.each do |test|
file, scoped_id = test.split(":", 2)
Thread.current[:rubyci_scoped_ids] = scoped_id
example_groups[file].each do |file_group|
formatter.current_test_key = test
file_group.run(reporter)
end
end
formatter.dump_and_reset
end
RubyCI.rspec_await
formatter.passed?
end
end
exit_code(examples_passed)
end
|