-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helper.rb
38 lines (30 loc) · 971 Bytes
/
test_helper.rb
1
2
3
4
5
6
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
# Based on the rspec-github formatter: https://github.com/Drieam/rspec-github
# Original copyright (c) 2020 Stef Schenkelaars
require "minitest/reporters"
class GithubReporter < Minitest::Reporters::DefaultReporter
# See https://github.community/t/set-output-truncates-multiline-strings/16852/3.
ESCAPE_MAP = {
"%" => "%25",
"\n" => "%0A",
"\r" => "%0D"
}.freeze
def report
super
tests.each do |test|
next if test.passed?
file, line = test.source_location
if test.skipped?
annotation = escape_annotation("Skipped: #{test.failure}")
puts "\n::warning file=#{file},line=#{line}::#{annotation}"
elsif test.failure
annotation = escape_annotation(test.failure.error.to_s)
puts "\n::error file=#{file},line=#{line}::#{annotation}"
end
end
end
private
def escape_annotation(msg)
msg.gsub(Regexp.union(ESCAPE_MAP.keys), ESCAPE_MAP)
end
end
Minitest::Reporters.use!