2018-11-03 02:07:56 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-28 04:32:28 +03:00
|
|
|
require "psych"
|
2018-11-03 02:07:56 +03:00
|
|
|
require "bundler/vendored_fileutils"
|
2019-12-14 13:49:16 +03:00
|
|
|
require "bundler/vendored_uri"
|
2018-11-03 02:07:56 +03:00
|
|
|
require "digest"
|
|
|
|
|
2019-01-04 16:10:58 +03:00
|
|
|
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
|
2018-11-03 02:07:56 +03:00
|
|
|
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
|
|
|
|
end
|
|
|
|
|
|
|
|
require "bundler"
|
2020-05-08 08:19:04 +03:00
|
|
|
require "rspec/core"
|
|
|
|
require "rspec/expectations"
|
|
|
|
require "rspec/mocks"
|
2021-07-07 08:07:29 +03:00
|
|
|
require "rspec/support/differ"
|
2018-11-03 02:07:56 +03:00
|
|
|
|
2019-11-11 11:57:45 +03:00
|
|
|
require_relative "support/builders"
|
2020-10-15 07:20:25 +03:00
|
|
|
require_relative "support/build_metadata"
|
2019-11-11 11:57:45 +03:00
|
|
|
require_relative "support/filters"
|
|
|
|
require_relative "support/helpers"
|
|
|
|
require_relative "support/indexes"
|
|
|
|
require_relative "support/matchers"
|
|
|
|
require_relative "support/permissions"
|
|
|
|
require_relative "support/platforms"
|
|
|
|
require_relative "support/sudo"
|
2018-11-03 02:07:56 +03:00
|
|
|
|
|
|
|
$debug = false
|
|
|
|
|
|
|
|
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::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"
|
|
|
|
|
2020-05-08 08:19:04 +03:00
|
|
|
config.silence_filter_announcements = !ENV["TEST_ENV_NUMBER"].nil?
|
|
|
|
|
2018-11-03 02:07:56 +03:00
|
|
|
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 12:49:40 +03:00
|
|
|
config.bisect_runner = :shell
|
|
|
|
|
2018-11-03 02:07:56 +03:00
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
c.syntax = :expect
|
|
|
|
end
|
|
|
|
|
2019-04-14 09:01:35 +03:00
|
|
|
config.mock_with :rspec do |mocks|
|
|
|
|
mocks.allow_message_expectations_on_nil = false
|
|
|
|
end
|
|
|
|
|
2018-11-25 04:20:00 +03:00
|
|
|
config.before :suite do
|
2021-04-15 06:47:04 +03:00
|
|
|
Gem.ruby = ENV["RUBY"] if ENV["RUBY"]
|
|
|
|
|
2019-11-11 11:57:45 +03:00
|
|
|
require_relative "support/rubygems_ext"
|
2020-05-08 08:19:04 +03:00
|
|
|
Spec::Rubygems.test_setup
|
2021-12-20 00:36:15 +03:00
|
|
|
ENV["BUNDLER_SPEC_RUN"] = "true"
|
2021-12-19 22:55:48 +03:00
|
|
|
ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"] = "true"
|
2019-07-19 11:23:42 +03:00
|
|
|
ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
|
2021-08-06 12:18:41 +03:00
|
|
|
ENV["RUBYGEMS_GEMDEPS"] = nil
|
2021-04-21 14:54:29 +03:00
|
|
|
ENV["XDG_CONFIG_HOME"] = nil
|
2019-08-03 01:23:58 +03:00
|
|
|
ENV["GEMRC"] = nil
|
2019-06-01 12:49:40 +03:00
|
|
|
|
2022-05-20 16:04:04 +03:00
|
|
|
extend(Spec::Helpers)
|
|
|
|
|
|
|
|
# Ruby-core needs RUBYLIB set, leave any "internal" RUBYLIB entries to avoid
|
|
|
|
# resetting that, but reset anything else to avoid external stuff like asdf
|
|
|
|
# hooks from interfering with our specs
|
|
|
|
|
|
|
|
rubylib = ENV["RUBYLIB"]
|
|
|
|
rubylib = rubylib.split(File::PATH_SEPARATOR).select {|p| p.start_with?(git_root.to_s) }.join(File::PATH_SEPARATOR) if rubylib
|
|
|
|
ENV["RUBYLIB"] = rubylib
|
|
|
|
|
2019-06-01 12:49:40 +03:00
|
|
|
# Don't wrap output in tests
|
|
|
|
ENV["THOR_COLUMNS"] = "10000"
|
|
|
|
|
2020-05-15 15:31:12 +03:00
|
|
|
system_gems :bundler, :path => pristine_system_gem_path
|
2018-11-25 04:20:00 +03:00
|
|
|
end
|
|
|
|
|
2018-11-03 02:07:56 +03:00
|
|
|
config.before :all do
|
2021-04-15 06:47:04 +03:00
|
|
|
check_test_gems!
|
|
|
|
|
2018-11-03 02:07:56 +03:00
|
|
|
build_repo1
|
2020-05-15 15:31:12 +03:00
|
|
|
|
|
|
|
reset_paths!
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
2019-06-01 12:49:40 +03:00
|
|
|
config.around :each do |example|
|
2020-05-15 15:31:12 +03:00
|
|
|
begin
|
|
|
|
FileUtils.cp_r pristine_system_gem_path, system_gem_path
|
|
|
|
|
|
|
|
with_gem_path_as(system_gem_path) do
|
|
|
|
Bundler.ui.silence { example.run }
|
|
|
|
|
2020-07-01 21:22:40 +03:00
|
|
|
all_output = all_commands_output
|
2020-05-15 15:31:12 +03:00
|
|
|
if example.exception && !all_output.empty?
|
2021-02-01 18:17:16 +03:00
|
|
|
message = all_output + "\n" + example.exception.message
|
2020-05-15 15:31:12 +03:00
|
|
|
(class << example.exception; self; end).send(:define_method, :message) do
|
|
|
|
message
|
|
|
|
end
|
|
|
|
end
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
2020-05-15 15:31:12 +03:00
|
|
|
ensure
|
|
|
|
reset!
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
end
|
2018-11-25 04:20:00 +03:00
|
|
|
|
2022-05-20 11:15:15 +03:00
|
|
|
config.before :each, :sudo => true do
|
|
|
|
Spec::Sudo.write_safe_config
|
|
|
|
end
|
|
|
|
|
2018-11-25 04:20:00 +03:00
|
|
|
config.after :suite do
|
2020-05-15 15:31:12 +03:00
|
|
|
FileUtils.rm_r Spec::Path.pristine_system_gem_path
|
2018-11-25 04:20:00 +03:00
|
|
|
end
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|