2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
require_relative "support/path"
|
|
|
|
|
|
|
|
$:.unshift Spec::Path.spec_dir.to_s
|
|
|
|
$:.unshift Spec::Path.lib_dir.to_s
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
require "bundler/psyched_yaml"
|
|
|
|
require "bundler/vendored_fileutils"
|
2019-12-14 05:49:16 -05:00
|
|
|
require "bundler/vendored_uri"
|
2018-11-02 19:07:56 -04:00
|
|
|
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
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
require_relative "support/builders"
|
|
|
|
require_relative "support/filters"
|
|
|
|
require_relative "support/helpers"
|
|
|
|
require_relative "support/indexes"
|
|
|
|
require_relative "support/matchers"
|
|
|
|
require_relative "support/parallel"
|
|
|
|
require_relative "support/permissions"
|
|
|
|
require_relative "support/platforms"
|
|
|
|
require_relative "support/sometimes"
|
|
|
|
require_relative "support/sudo"
|
2018-11-02 19:07:56 -04: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"
|
|
|
|
|
|
|
|
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
|
|
|
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|
|
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
|
|
|
if ENV["RUBY"]
|
2018-11-16 18:27:37 -05:00
|
|
|
orig_ruby = Gem.ruby
|
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
|
|
|
Gem.ruby = ENV["RUBY"]
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
2018-11-16 18:27:37 -05:00
|
|
|
example.run
|
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
|
|
|
Gem.ruby = orig_ruby if ENV["RUBY"]
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2018-11-24 20:20:00 -05:00
|
|
|
config.before :suite do
|
2019-11-11 03:57:45 -05:00
|
|
|
require_relative "support/rubygems_ext"
|
2019-06-01 05:49:40 -04:00
|
|
|
Spec::Rubygems.setup
|
2019-12-14 05:49:16 -05:00
|
|
|
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
|
2019-07-22 12:21:59 -04:00
|
|
|
ENV["BUNDLE_SPEC_RUN"] = "true"
|
2019-07-19 04:23:42 -04:00
|
|
|
ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
|
2019-08-02 18:23:58 -04:00
|
|
|
ENV["GEMRC"] = nil
|
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
|
|
|
|
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
|
|
|
if ENV["RUBY"]
|
2018-11-24 20:20:00 -05:00
|
|
|
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-11-11 03:57:45 -05:00
|
|
|
Bundler.ui.silence { example.run }
|
2019-06-01 05:49:40 -04:00
|
|
|
|
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
|
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
|
|
|
if ENV["RUBY"]
|
2018-11-24 20:20:00 -05:00
|
|
|
FileUtils.rm_rf File.join(Spec::Path.root, "lib", "exe")
|
|
|
|
end
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|