Skip to content
Snippets Groups Projects
Commit 4d8dcb1d authored by Markus Reiter's avatar Markus Reiter
Browse files

Add RSpec formatter for Github Actions.

parent d0e1595f
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,8 @@ module Homebrew
--out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
]
bundle_args << "--format" << "RSpec::Github::Formatter" if ENV["GITHUB_ACTIONS"]
unless OS.mac?
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
......
......@@ -2,7 +2,7 @@
require "sandbox"
describe Sandbox do
describe Sandbox, :needs_macos do
define_negated_matcher :not_matching, :matching
let(:dir) { mktmpdir }
......
......@@ -36,6 +36,7 @@ $LOAD_PATH.push(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/suppo
require_relative "../global"
require "test/support/no_seed_progress_formatter"
require "test/support/github_formatter"
require "test/support/helper/cask"
require "test/support/helper/fixtures"
require "test/support/helper/formula"
......
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment