2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
$:.unshift File.expand_path("..", __FILE__)
|
|
|
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
|
|
|
|
|
|
require "bundler/psyched_yaml"
|
|
|
|
require "bundler/vendored_fileutils"
|
|
|
|
require "uri"
|
|
|
|
require "digest"
|
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
|
2018-11-02 19:07:56 -04:00
|
|
|
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
|
|
|
|
end
|
|
|
|
|
|
|
|
require "bundler"
|
2019-04-14 02:02:47 -04:00
|
|
|
require "rspec"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
Dir["#{File.expand_path("../support", __FILE__)}/*.rb"].each do |file|
|
|
|
|
file = file.gsub(%r{\A#{Regexp.escape File.expand_path("..", __FILE__)}/}, "")
|
|
|
|
require file unless file.end_with?("hax.rb")
|
|
|
|
end
|
|
|
|
|
|
|
|
$debug = false
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
Spec::Manpages.setup unless Gem.win_platform?
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
config.fail_fast ||= 25 if ENV["CI"]
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
config.bisect_runner = :shell
|
|
|
|
|
2018-11-02 19:07:56 -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
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
config.filter_run_excluding :ruby => RequirementChecker.against(RUBY_VERSION)
|
|
|
|
config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION)
|
2019-06-01 05:49:40 -04:00
|
|
|
config.filter_run_excluding :git => RequirementChecker.against(git_version)
|
2019-04-14 02:01:35 -04:00
|
|
|
config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
|
2018-11-02 19:07:56 -04:00
|
|
|
config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
|
2019-05-24 14:32:45 -04:00
|
|
|
config.filter_run_excluding :non_windows => Gem.win_platform?
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
config.filter_run_when_matching :focus unless ENV["CI"]
|
|
|
|
|
|
|
|
original_wd = Dir.pwd
|
2019-07-23 02:14:02 -04:00
|
|
|
original_env = ENV.to_hash
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
c.syntax = :expect
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
config.mock_with :rspec do |mocks|
|
|
|
|
mocks.allow_message_expectations_on_nil = false
|
|
|
|
end
|
|
|
|
|
2018-11-16 18:27:37 -05:00
|
|
|
config.around :each do |example|
|
2018-11-02 19:07:56 -04:00
|
|
|
if ENV["BUNDLE_RUBY"]
|
2018-11-16 18:27:37 -05:00
|
|
|
orig_ruby = Gem.ruby
|
2018-11-02 19:07:56 -04:00
|
|
|
Gem.ruby = ENV["BUNDLE_RUBY"]
|
|
|
|
end
|
2018-11-16 18:27:37 -05:00
|
|
|
example.run
|
|
|
|
Gem.ruby = orig_ruby if ENV["BUNDLE_RUBY"]
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2018-11-24 20:20:00 -05:00
|
|
|
config.before :suite do
|
2019-06-01 05:49:40 -04:00
|
|
|
Spec::Rubygems.setup
|
2019-07-22 12:21:59 -04:00
|
|
|
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
|
|
|
|
ENV["BUNDLE_SPEC_RUN"] = "true"
|
2019-06-01 05:49:40 -04:00
|
|
|
|
|
|
|
# Don't wrap output in tests
|
|
|
|
ENV["THOR_COLUMNS"] = "10000"
|
|
|
|
|
2019-07-23 02:14:02 -04:00
|
|
|
original_env = ENV.to_hash
|
2019-06-01 05:49:40 -04:00
|
|
|
|
2018-11-24 20:20:00 -05:00
|
|
|
if ENV["BUNDLE_RUBY"]
|
|
|
|
FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
config.before :all do
|
|
|
|
build_repo1
|
|
|
|
end
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
config.around :each do |example|
|
|
|
|
ENV.replace(original_env)
|
2018-11-02 19:07:56 -04:00
|
|
|
reset!
|
|
|
|
system_gems []
|
|
|
|
in_app_root
|
|
|
|
@command_executions = []
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
example.run
|
|
|
|
|
2018-11-02 19:07:56 -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}"
|
|
|
|
(class << example.exception; self; end).send(:define_method, :message) do
|
|
|
|
message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(original_wd)
|
|
|
|
end
|
2018-11-24 20:20:00 -05:00
|
|
|
|
|
|
|
config.after :suite do
|
|
|
|
if ENV["BUNDLE_RUBY"]
|
|
|
|
FileUtils.rm_rf File.join(Spec::Path.root, "lib", "exe")
|
|
|
|
end
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|