Add RSpec formatter for Github Actions.
This commit is contained in:
parent
d0e1595fcf
commit
4d8dcb1d81
@ -118,6 +118,8 @@ module Homebrew
|
|||||||
--out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
|
--out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
|
||||||
]
|
]
|
||||||
|
|
||||||
|
bundle_args << "--format" << "RSpec::Github::Formatter" if ENV["GITHUB_ACTIONS"]
|
||||||
|
|
||||||
unless OS.mac?
|
unless OS.mac?
|
||||||
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
|
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
|
||||||
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
|
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require "sandbox"
|
require "sandbox"
|
||||||
|
|
||||||
describe Sandbox do
|
describe Sandbox, :needs_macos do
|
||||||
define_negated_matcher :not_matching, :matching
|
define_negated_matcher :not_matching, :matching
|
||||||
|
|
||||||
let(:dir) { mktmpdir }
|
let(:dir) { mktmpdir }
|
||||||
|
|||||||
@ -36,6 +36,7 @@ $LOAD_PATH.push(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/suppo
|
|||||||
require_relative "../global"
|
require_relative "../global"
|
||||||
|
|
||||||
require "test/support/no_seed_progress_formatter"
|
require "test/support/no_seed_progress_formatter"
|
||||||
|
require "test/support/github_formatter"
|
||||||
require "test/support/helper/cask"
|
require "test/support/helper/cask"
|
||||||
require "test/support/helper/fixtures"
|
require "test/support/helper/fixtures"
|
||||||
require "test/support/helper/formula"
|
require "test/support/helper/formula"
|
||||||
|
|||||||
36
Library/Homebrew/test/support/github_formatter.rb
Normal file
36
Library/Homebrew/test/support/github_formatter.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "rspec/core"
|
||||||
|
require "rspec/core/formatters/base_formatter"
|
||||||
|
|
||||||
|
# TODO: Replace with `rspec-github` when https://github.com/Drieam/rspec-github/pull/4 is merged.
|
||||||
|
module RSpec
|
||||||
|
module Github
|
||||||
|
class Formatter < RSpec::Core::Formatters::BaseFormatter
|
||||||
|
RSpec::Core::Formatters.register self, :example_failed, :example_pending
|
||||||
|
|
||||||
|
def self.relative_path(path)
|
||||||
|
if (workspace = ENV["GITHUB_WORKSPACE"])
|
||||||
|
workspace = "#{File.realpath(workspace)}#{File::SEPARATOR}"
|
||||||
|
absolute_path = File.realpath(path)
|
||||||
|
|
||||||
|
return absolute_path.delete_prefix(workspace) if absolute_path.start_with?(workspace)
|
||||||
|
end
|
||||||
|
|
||||||
|
path
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_failed(failure)
|
||||||
|
file, line = failure.example.location.split(":")
|
||||||
|
file = self.class.relative_path(file)
|
||||||
|
output.puts "\n::error file=#{file},line=#{line}::#{failure.message_lines.join("%0A")}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_pending(pending)
|
||||||
|
file, line = pending.example.location.split(":")
|
||||||
|
file = self.class.relative_path(file)
|
||||||
|
output.puts "\n::warning file=#{file},line=#{line}::#{pending.example.full_description}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user