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

46 lines
1.2 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
2017-01-29 17:23:05 +00:00
cask_root = Pathname.new(__FILE__).realpath.parent.parent
cask_root.cd do
2016-08-18 22:11:42 +03:00
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
if ARGV.flag?("--coverage")
ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
2017-01-29 17:23:05 +00:00
upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"]
end
2016-09-20 00:02:04 +01:00
2017-02-09 04:39:53 +01:00
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
]
2016-09-20 13:16:11 +01:00
2017-02-09 04:39:53 +01:00
unless $CHILD_STATUS.success?
Homebrew.failed = true
2016-09-20 13:16:11 +01:00
end
2016-09-20 00:02:04 +01:00
2017-01-29 17:23:05 +00:00
if upload_coverage
puts "Submitting Codecov coverage..."
2017-02-09 04:39:53 +01:00
system "bundle", "exec", "spec/upload_coverage.rb"
2017-01-29 17:23:05 +00:00
end
2016-08-18 22:11:42 +03:00
end