2017-09-08 04:45:41 -04:00
|
|
|
# frozen_string_literal: true
|
2017-11-01 19:29:38 -04:00
|
|
|
|
2017-09-08 04:45:41 -04:00
|
|
|
$:.unshift File.expand_path("..", __FILE__)
|
|
|
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
|
|
|
2017-11-01 19:29:38 -04:00
|
|
|
require "rubygems"
|
2017-09-08 04:45:41 -04:00
|
|
|
require "bundler/psyched_yaml"
|
2017-11-01 19:29:38 -04:00
|
|
|
require "bundler/vendored_fileutils"
|
2017-09-08 04:45:41 -04:00
|
|
|
require "uri"
|
2017-11-01 19:29:38 -04:00
|
|
|
require "digest"
|
2017-09-08 04:45:41 -04:00
|
|
|
require File.expand_path("../support/path.rb", __FILE__)
|
|
|
|
|
|
|
|
begin
|
|
|
|
spec = Gem::Specification.load(Spec::Path.gemspec.to_s)
|
|
|
|
rspec = spec.dependencies.find {|d| d.name == "rspec" }
|
|
|
|
gem "rspec", rspec.requirement.to_s
|
|
|
|
require "rspec"
|
2017-11-01 19:29:38 -04:00
|
|
|
require "diff/lcs"
|
2017-09-08 04:45:41 -04:00
|
|
|
rescue LoadError
|
|
|
|
abort "Run rake spec:deps to install development dependencies"
|
|
|
|
end
|
|
|
|
|
2017-11-02 00:28:30 -04:00
|
|
|
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
|
2017-09-08 04:45:41 -04:00
|
|
|
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
|
|
|
|
end
|
|
|
|
|
|
|
|
require "bundler"
|
|
|
|
|
2017-11-02 00:28:30 -04:00
|
|
|
require "open3"
|
2017-09-08 04:45:41 -04:00
|
|
|
|
|
|
|
Dir["#{File.expand_path("../support", __FILE__)}/*.rb"].each do |file|
|
2017-11-01 19:29:38 -04:00
|
|
|
file = file.gsub(%r{\A#{Regexp.escape File.expand_path("..", __FILE__)}/}, "")
|
2017-09-08 04:45:41 -04:00
|
|
|
require file unless file.end_with?("hax.rb")
|
|
|
|
end
|
|
|
|
|
|
|
|
$debug = false
|
|
|
|
|
2017-11-01 19:29:38 -04:00
|
|
|
Spec::Manpages.setup
|
2017-09-08 04:45:41 -04:00
|
|
|
Spec::Rubygems.setup
|
|
|
|
FileUtils.rm_rf(Spec::Path.gem_repo1)
|
|
|
|
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
|
|
|
|
ENV["BUNDLE_SPEC_RUN"] = "true"
|
|
|
|
|
|
|
|
# Don't wrap output in tests
|
|
|
|
ENV["THOR_COLUMNS"] = "10000"
|
|
|
|
|
|
|
|
Spec::CodeClimate.setup
|
|
|
|
|
|
|
|
module Gem
|
|
|
|
def self.ruby= ruby
|
|
|
|
@ruby = ruby
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
config.include Spec::Builders
|
|
|
|
config.include Spec::Helpers
|
|
|
|
config.include Spec::Indexes
|
|
|
|
config.include Spec::Matchers
|
|
|
|
config.include Spec::Path
|
|
|
|
config.include Spec::Rubygems
|
|
|
|
config.include Spec::Platforms
|
|
|
|
config.include Spec::Sudo
|
|
|
|
config.include Spec::Permissions
|
|
|
|
|
|
|
|
# Enable flags like --only-failures and --next-failure
|
|
|
|
config.example_status_persistence_file_path = ".rspec_status"
|
|
|
|
|
|
|
|
config.disable_monkey_patching!
|
|
|
|
|
|
|
|
# Since failures cause us to keep a bunch of long strings in memory, stop
|
|
|
|
# once we have a large number of failures (indicative of core pieces of
|
|
|
|
# bundler being broken) so that running the full test suite doesn't take
|
|
|
|
# forever due to memory constraints
|
2017-11-01 19:29:38 -04:00
|
|
|
config.fail_fast ||= 25 if ENV["CI"]
|
2017-09-08 04:45:41 -04:00
|
|
|
|
|
|
|
if ENV["BUNDLER_SUDO_TESTS"] && Spec::Sudo.present?
|
|
|
|
config.filter_run :sudo => true
|
|
|
|
else
|
|
|
|
config.filter_run_excluding :sudo => true
|
|
|
|
end
|
|
|
|
|
|
|
|
if ENV["BUNDLER_REALWORLD_TESTS"]
|
|
|
|
config.filter_run :realworld => true
|
|
|
|
else
|
|
|
|
config.filter_run_excluding :realworld => true
|
|
|
|
end
|
|
|
|
|
|
|
|
git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
|
|
|
|
|
|
|
|
config.filter_run_excluding :ruby => LessThanProc.with(RUBY_VERSION)
|
|
|
|
config.filter_run_excluding :rubygems => LessThanProc.with(Gem::VERSION)
|
|
|
|
config.filter_run_excluding :git => LessThanProc.with(git_version)
|
|
|
|
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
|
2017-11-01 19:29:38 -04:00
|
|
|
config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join("."))
|
2017-09-08 04:45:41 -04:00
|
|
|
config.filter_run_excluding :ruby_repo => !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
|
|
|
|
|
|
|
|
config.filter_run_when_matching :focus unless ENV["CI"]
|
|
|
|
|
|
|
|
original_wd = Dir.pwd
|
2017-11-01 19:29:38 -04:00
|
|
|
original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }
|
2017-12-12 01:15:44 -05:00
|
|
|
original_default_specs = Dir[File.join(Gem.default_dir, "specifications", "default", "bundler*")]
|
|
|
|
original_site_ruby_dirs = $LOAD_PATH.select {|path| path =~ /site_ruby/ }.map {|path| File.join(path, "bundler*") }.compact.map {|path| Dir[path] }.flatten
|
2017-09-08 04:45:41 -04:00
|
|
|
|
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
c.syntax = :expect
|
|
|
|
end
|
|
|
|
|
|
|
|
config.before :suite do
|
2017-11-01 19:29:38 -04:00
|
|
|
if ENV['BUNDLE_RUBY']
|
|
|
|
@orig_ruby = Gem.ruby
|
|
|
|
Gem.ruby = ENV['BUNDLE_RUBY']
|
|
|
|
end
|
2017-09-08 04:45:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
config.before :all do
|
|
|
|
build_repo1
|
2017-12-12 01:15:44 -05:00
|
|
|
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s, s + ".org") }
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after :all do
|
|
|
|
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s + ".org", s) if File.exist?(s + ".org") }
|
2017-09-08 04:45:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
config.before :each do
|
|
|
|
reset!
|
|
|
|
system_gems []
|
|
|
|
in_app_root
|
2017-11-01 19:29:38 -04:00
|
|
|
@command_executions = []
|
2017-09-08 04:45:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
config.after :each do |example|
|
2017-11-01 19:29:38 -04:00
|
|
|
all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
|
|
|
|
if example.exception && !all_output.empty?
|
|
|
|
warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
|
|
|
|
message = example.exception.message + "\n\nCommands:\n#{all_output}"
|
2017-09-08 04:45:41 -04:00
|
|
|
(class << example.exception; self; end).send(:define_method, :message) do
|
|
|
|
message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(original_wd)
|
|
|
|
ENV.replace(original_env)
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after :suite do
|
2017-11-01 19:29:38 -04:00
|
|
|
if ENV['BUNDLE_RUBY']
|
|
|
|
Gem.ruby = @orig_ruby
|
|
|
|
end
|
2017-09-08 04:45:41 -04:00
|
|
|
end
|
|
|
|
end
|