Skip to content

Commit 59baea8

Browse files
committed
Reverts "[CI] Removes log formatter for RSpec in API"
Brings back the log formatter for test name results in Buildkite This reverts commit 5570fe7.
1 parent f61c0ad commit 59baea8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
class RSpecCustomFormatter < RSpec::Core::Formatters::JsonFormatter
19+
RSpec::Core::Formatters.register self
20+
21+
LOGFILE = File.new("tmp/rspec-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}.log", 'w')
22+
23+
def close(_notification)
24+
@output_hash[:examples].map do |example|
25+
regexp = /\S+\/\S+/
26+
filename = example[:full_description].match(/\S+\/\S+/)[0]
27+
log ="#{filename} | #{example[:status]} | #{example[:run_time]} | #{example[:full_description]}\n"
28+
File.write(LOGFILE, log, mode: 'a')
29+
end
30+
end
31+
end

elasticsearch-api/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def self.included(context)
6464
else
6565
config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}.html")
6666
end
67+
if ENV['BUILDKITE']
68+
require_relative "./rspec_formatter.rb"
69+
config.add_formatter('RSpecCustomFormatter')
70+
end
6771
config.color_mode = :on
6872
end
6973

0 commit comments

Comments
 (0)