Merge pull request #2260 from reitermarkus/spec-cask
Move Cask specs into `brew tests`.
This commit is contained in:
commit
1fbd720e35
@ -11,8 +11,6 @@ SimpleCov.start do
|
||||
# tests to be dropped. This causes random fluctuations in test coverage.
|
||||
merge_timeout 86400
|
||||
|
||||
add_filter "/Homebrew/cask/spec/"
|
||||
add_filter "/Homebrew/cask/test/"
|
||||
add_filter "/Homebrew/compat/"
|
||||
add_filter "/Homebrew/dev-cmd/tests.rb"
|
||||
add_filter "/Homebrew/test/"
|
||||
|
||||
@ -1 +0,0 @@
|
||||
../.simplecov
|
||||
@ -1,11 +0,0 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "parallel_tests"
|
||||
gem "rspec"
|
||||
gem "rspec-its", require: false
|
||||
gem "rspec-wait", require: false
|
||||
|
||||
group :coverage do
|
||||
gem "simplecov", require: false
|
||||
gem "codecov", require: false
|
||||
end
|
||||
@ -1,51 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
codecov (0.1.9)
|
||||
json
|
||||
simplecov
|
||||
url
|
||||
diff-lcs (1.3)
|
||||
docile (1.1.5)
|
||||
json (2.0.3)
|
||||
parallel (1.10.0)
|
||||
parallel_tests (2.13.0)
|
||||
parallel
|
||||
rspec (3.5.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
rspec-mocks (~> 3.5.0)
|
||||
rspec-core (3.5.4)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-expectations (3.5.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-its (1.2.0)
|
||||
rspec-core (>= 3.0.0)
|
||||
rspec-expectations (>= 3.0.0)
|
||||
rspec-mocks (3.5.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-support (3.5.0)
|
||||
rspec-wait (0.0.9)
|
||||
rspec (>= 3, < 4)
|
||||
simplecov (0.13.0)
|
||||
docile (~> 1.1.0)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.0)
|
||||
url (0.3.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
codecov
|
||||
parallel_tests
|
||||
rspec
|
||||
rspec-its
|
||||
rspec-wait
|
||||
simplecov
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.5
|
||||
@ -1,45 +0,0 @@
|
||||
require "English"
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/cask/Gemfile"
|
||||
ENV["BUNDLE_PATH"] = "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle"
|
||||
|
||||
def run_tests(executable, files, args = [])
|
||||
opts = []
|
||||
opts << "--serialize-stdout" if ENV["CI"]
|
||||
|
||||
system "bundle", "exec", executable, *opts, "--", *args, "--", *files
|
||||
end
|
||||
|
||||
cask_root = Pathname.new(__FILE__).realpath.parent.parent
|
||||
cask_root.cd do
|
||||
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
|
||||
ENV["HOMEBREW_NO_EMOJI"] = "1"
|
||||
ENV.delete("HOMEBREW_CASK_OPTS")
|
||||
|
||||
Homebrew.install_gem_setup_path! "bundler"
|
||||
unless quiet_system("bundle", "check")
|
||||
system "bundle", "install"
|
||||
end
|
||||
|
||||
if ARGV.flag?("--coverage")
|
||||
ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
|
||||
upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"]
|
||||
end
|
||||
|
||||
run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[
|
||||
--color
|
||||
--require spec_helper
|
||||
--format progress
|
||||
--format ParallelTests::RSpec::RuntimeLogger
|
||||
--out tmp/parallel_runtime_rspec.log
|
||||
]
|
||||
|
||||
unless $CHILD_STATUS.success?
|
||||
Homebrew.failed = true
|
||||
end
|
||||
|
||||
if upload_coverage
|
||||
puts "Submitting Codecov coverage..."
|
||||
system "bundle", "exec", "spec/upload_coverage.rb"
|
||||
end
|
||||
end
|
||||
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require "simplecov"
|
||||
require "codecov"
|
||||
|
||||
formatter = SimpleCov::Formatter::Codecov.new
|
||||
formatter.format SimpleCov::ResultMerger.merged_result
|
||||
@ -6,6 +6,11 @@ require "set"
|
||||
|
||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||
require "simplecov"
|
||||
|
||||
if ENV["CODECOV_TOKEN"] || ENV["TRAVIS"]
|
||||
require "codecov"
|
||||
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
||||
end
|
||||
end
|
||||
|
||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
|
||||
@ -18,6 +23,8 @@ require "test/support/helper/shutup"
|
||||
require "test/support/helper/fixtures"
|
||||
require "test/support/helper/formula"
|
||||
require "test/support/helper/mktmpdir"
|
||||
|
||||
require "test/support/helper/spec/shared_context/homebrew_cask" if OS.mac?
|
||||
require "test/support/helper/spec/shared_context/integration_test"
|
||||
|
||||
TEST_DIRECTORIES = [
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||
require "test/spec_helper"
|
||||
|
||||
# add Homebrew-Cask to load path
|
||||
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
|
||||
|
||||
require "hbc"
|
||||
@ -20,18 +16,17 @@ HOMEBREW_CASK_DIRS = [
|
||||
:binarydir,
|
||||
].freeze
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.around(:each) do |example|
|
||||
RSpec.shared_context "Homebrew-Cask" do
|
||||
around(:each) do |example|
|
||||
begin
|
||||
dirs = HOMEBREW_CASK_DIRS.map { |dir|
|
||||
Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap { |path|
|
||||
dirs = HOMEBREW_CASK_DIRS.map do |dir|
|
||||
Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap do |path|
|
||||
path.mkpath
|
||||
Hbc.public_send("#{dir}=", path)
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
|
||||
# link test casks
|
||||
FileUtils.mkdir_p tap.path.dirname
|
||||
FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path
|
||||
end
|
||||
@ -39,6 +34,12 @@ RSpec.configure do |config|
|
||||
example.run
|
||||
ensure
|
||||
FileUtils.rm_rf dirs
|
||||
Hbc.default_tap.path.unlink
|
||||
FileUtils.rm_rf Hbc.default_tap.path.parent
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include_context "Homebrew-Cask", :cask
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user