brew/Library/Homebrew/cask/cmd/brew-cask-tests.rb

53 lines
1.3 KiB
Ruby
Raw Normal View History

2016-08-18 22:11:42 +03:00
require "English"
ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/cask/Gemfile"
ENV["BUNDLE_PATH"] = "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle"
2016-09-20 00:02:04 +01:00
def run_tests(executable, files, args = [])
opts = []
opts << "--serialize-stdout" if ENV["CI"]
system "bundle", "exec", executable, *opts, "--", *args, "--", *files
2016-09-20 00:02:04 +01:00
end
repo_root = Pathname.new(__FILE__).realpath.parent.parent
2016-08-18 22:11:42 +03:00
repo_root.cd do
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_NO_EMOJI"] = "1"
ENV.delete("HOMEBREW_CASK_OPTS")
2016-08-18 22:11:42 +03:00
Homebrew.install_gem_setup_path! "bundler"
unless quiet_system("bundle", "check")
system "bundle", "install"
2016-08-18 22:11:42 +03:00
end
2016-09-20 00:02:04 +01:00
rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest")
minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec")
ENV["HOMEBREW_TESTS_COVERAGE"] = "1" if ARGV.flag?("--coverage")
failed = false
2016-09-20 13:16:11 +01:00
if rspec
run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[
2016-10-19 22:27:14 +02:00
--color
--require spec_helper
2016-09-20 13:16:11 +01:00
--format progress
--format ParallelTests::RSpec::RuntimeLogger
--out tmp/parallel_runtime_rspec.log
]
failed ||= !$CHILD_STATUS.success?
2016-09-20 13:16:11 +01:00
end
if minitest
run_tests "parallel_test", Dir["test/**/*_test.rb"]
failed ||= !$CHILD_STATUS.success?
2016-09-20 13:16:11 +01:00
end
2016-09-20 00:02:04 +01:00
Homebrew.failed = failed
2016-09-20 00:02:04 +01:00
if ENV["CODECOV_TOKEN"]
2016-09-20 16:39:16 +01:00
system "bundle", "exec", "rake", "test:coverage:upload"
2016-08-18 22:11:42 +03:00
end
end