summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--Rakefile2
-rwxr-xr-xbin/parallel_rspec6
-rwxr-xr-xbin/rake6
-rwxr-xr-xbin/ronn6
-rwxr-xr-xbin/rspec6
-rwxr-xr-xbin/rubocop6
-rw-r--r--spec/spec_helper.rb23
-rw-r--r--spec/support/command_execution.rb5
-rw-r--r--spec/support/filters.rb45
-rw-r--r--spec/support/helpers.rb4
-rw-r--r--spec/support/matchers.rb5
-rw-r--r--spec/support/requirement_checker.rb19
-rw-r--r--spec/support/rubygems_ext.rb37
-rw-r--r--spec/support/the_bundle.rb4
15 files changed, 79 insertions, 97 deletions
diff --git a/.travis.yml b/.travis.yml
index 03d8d4eb98..f2291c7f5c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@ language: ruby
dist: bionic
script: rake spec:travis
before_script:
- - travis_retry rake -E 'module ::Bundler; VERSION = "0.0.0"; end' override_version
+ - rake override_version
- travis_retry rake spec:travis:deps
- rake man:check
diff --git a/Rakefile b/Rakefile
index d4f0cba928..c41a6e9665 100644
--- a/Rakefile
+++ b/Rakefile
@@ -21,7 +21,7 @@ end
desc "Run specs"
task :spec do
- sh("bin/rspec")
+ sh("bin/rspec --format progress")
end
namespace :spec do
diff --git a/bin/parallel_rspec b/bin/parallel_rspec
index 26402aee7c..9783533198 100755
--- a/bin/parallel_rspec
+++ b/bin/parallel_rspec
@@ -5,8 +5,4 @@ load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require_relative "../spec/support/rubygems_ext"
-begin
- Spec::Rubygems.gem_load("parallel_tests", "parallel_rspec")
-rescue Gem::LoadError => e
- warn "We couln't activate parallel_tests (#{e.requirement}). Run `gem install parallel_tests:'#{e.requirement}'`"
-end
+Spec::Rubygems.gem_load("parallel_tests", "parallel_rspec")
diff --git a/bin/rake b/bin/rake
index f9a28e88c2..2fb69d19f3 100755
--- a/bin/rake
+++ b/bin/rake
@@ -5,8 +5,4 @@ load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require_relative "../spec/support/rubygems_ext"
-begin
- Spec::Rubygems.gem_load("rake", "rake")
-rescue Gem::LoadError => e
- warn "We couln't activate rake (#{e.requirement}). Run `gem install rake:'#{e.requirement}'`"
-end
+Spec::Rubygems.gem_load("rake", "rake")
diff --git a/bin/ronn b/bin/ronn
index 4501d03af3..e47fb518a4 100755
--- a/bin/ronn
+++ b/bin/ronn
@@ -5,8 +5,4 @@ load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require_relative "../spec/support/rubygems_ext"
-begin
- Spec::Rubygems.gem_load("ronn", "ronn")
-rescue Gem::LoadError => e
- warn "We couln't activate ronn (#{e.requirement}). Run `gem install ronn:'#{e.requirement}'`"
-end
+Spec::Rubygems.gem_load("ronn", "ronn")
diff --git a/bin/rspec b/bin/rspec
index 7d6c53cda4..4c139156f9 100755
--- a/bin/rspec
+++ b/bin/rspec
@@ -5,8 +5,4 @@ load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require_relative "../spec/support/rubygems_ext"
-begin
- Spec::Rubygems.gem_load("rspec-core", "rspec")
-rescue Gem::LoadError => e
- warn "We couln't activate rspec (#{e.requirement}). Run `gem install rspec:'#{e.requirement}'`"
-end
+Spec::Rubygems.gem_load("rspec-core", "rspec")
diff --git a/bin/rubocop b/bin/rubocop
index f700d073ca..818aaf7a9d 100755
--- a/bin/rubocop
+++ b/bin/rubocop
@@ -5,8 +5,4 @@ load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require_relative "../spec/support/rubygems_ext"
-begin
- Spec::Rubygems.gem_load("rubocop", "rubocop")
-rescue Gem::LoadError => e
- warn "We couln't activate rubocop (#{e.requirement}). Run `gem install rubocop:'#{e.requirement}'`"
-end
+Spec::Rubygems.gem_load("rubocop", "rubocop")
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 58d498e070..970d350dca 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -34,7 +34,6 @@ RSpec.configure do |config|
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
@@ -52,28 +51,6 @@ RSpec.configure do |config|
config.bisect_runner = :shell
- 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 :rubygems => RequirementChecker.against(Gem::VERSION)
- config.filter_run_excluding :git => RequirementChecker.against(git_version)
- config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
- config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil?
- config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
-
- config.filter_run_when_matching :focus unless ENV["CI"]
-
original_wd = Dir.pwd
original_env = ENV.to_hash
diff --git a/spec/support/command_execution.rb b/spec/support/command_execution.rb
index cec531d6c3..b3c289979f 100644
--- a/spec/support/command_execution.rb
+++ b/spec/support/command_execution.rb
@@ -1,12 +1,7 @@
# frozen_string_literal: true
-require "support/helpers"
-require "support/path"
-
module Spec
CommandExecution = Struct.new(:command, :working_directory, :exitstatus, :stdout, :stderr) do
- include RSpec::Matchers::Composable
-
def to_s
c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) }
c = c.reduce("") do |acc, elem|
diff --git a/spec/support/filters.rb b/spec/support/filters.rb
new file mode 100644
index 0000000000..4ce6648cdc
--- /dev/null
+++ b/spec/support/filters.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require_relative "sudo"
+
+class RequirementChecker < Proc
+ def self.against(present)
+ provided = Gem::Version.new(present)
+
+ new do |required|
+ !Gem::Requirement.new(required).satisfied_by?(provided)
+ end.tap do |checker|
+ checker.provided = provided
+ end
+ end
+
+ attr_accessor :provided
+
+ def inspect
+ "\"!= #{provided}\""
+ end
+end
+
+RSpec.configure do |config|
+ 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 :rubygems => RequirementChecker.against(Gem::VERSION)
+ config.filter_run_excluding :git => RequirementChecker.against(git_version)
+ config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
+ config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil?
+ config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
+
+ config.filter_run_when_matching :focus unless ENV["CI"]
+end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 0c05789946..b5617d399f 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -513,10 +513,6 @@ module Spec
Dir.chdir(path) { `git rev-parse HEAD`.strip }
end
- def capture_output
- capture(:stdout)
- end
-
def with_read_only(pattern)
chmod = lambda do |dirmode, filemode|
lambda do |f|
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index b0493801e8..69d3be4a3d 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
require "forwardable"
-require "support/the_bundle"
+require_relative "the_bundle"
+
module Spec
module Matchers
extend RSpec::Matchers
@@ -170,7 +171,7 @@ module Spec
end
R
rescue StandardError => e
- next "checking for #{name} failed:\n#{e}"
+ next "checking for #{name} failed:\n#{e}\n#{e.backtrace.join("\n")}"
end
next if out == "WIN"
next "expected #{name} to not be installed, but it was" if version.nil?
diff --git a/spec/support/requirement_checker.rb b/spec/support/requirement_checker.rb
deleted file mode 100644
index e6bd0eb50d..0000000000
--- a/spec/support/requirement_checker.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class RequirementChecker < Proc
- def self.against(present)
- provided = Gem::Version.new(present)
-
- new do |required|
- !Gem::Requirement.new(required).satisfied_by?(provided)
- end.tap do |checker|
- checker.provided = provided
- end
- end
-
- attr_accessor :provided
-
- def inspect
- "\"!= #{provided}\""
- end
-end
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index faa44b0944..22374d9f39 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "rubygems/user_interaction"
require_relative "path"
require "fileutils"
@@ -29,7 +28,9 @@ module Spec
"ruby-graphviz" => ">= 0.a",
}.freeze
- def self.dev_setup
+ extend self
+
+ def dev_setup
deps = DEV_DEPS
# JRuby can't build ronn, so we skip that
@@ -38,22 +39,16 @@ module Spec
install_gems(deps)
end
- def self.gem_load(gem_name, bin_container)
- gem_activate(gem_name)
- load Gem.bin_path(gem_name, bin_container)
- end
-
- def self.gem_activate(gem_name)
- gem_requirement = DEV_DEPS[gem_name]
- gem gem_name, gem_requirement
+ def gem_load(gem_name, bin_container)
+ gem_load_and_activate(gem_name, bin_container)
end
- def self.gem_require(gem_name)
+ def gem_require(gem_name)
gem_activate(gem_name)
require gem_name
end
- def self.setup
+ def setup
Gem.clear_paths
ENV["BUNDLE_PATH"] = nil
@@ -74,17 +69,31 @@ module Spec
ENV["HOME"] = Path.home.to_s
ENV["TMPDIR"] = Path.tmpdir.to_s
+ require "rubygems/user_interaction"
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end
- def self.install_gems(gems)
+ private
+
+ def gem_load_and_activate(gem_name, bin_container)
+ gem_activate(gem_name)
+ load Gem.bin_path(gem_name, bin_container)
+ rescue Gem::LoadError => e
+ abort "We couln't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
+ end
+
+ def gem_activate(gem_name)
+ gem_requirement = DEV_DEPS[gem_name]
+ gem gem_name, gem_requirement
+ end
+
+ def install_gems(gems)
reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
no_reqs.map!(&:first)
reqs.map! {|name, req| "'#{name}:#{req}'" }
deps = reqs.concat(no_reqs).join(" ")
gem = Path.gem_bin
cmd = "#{gem} install #{deps} --no-document --conservative"
- puts cmd
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
end
end
diff --git a/spec/support/the_bundle.rb b/spec/support/the_bundle.rb
index c994eaae78..f252a4515b 100644
--- a/spec/support/the_bundle.rb
+++ b/spec/support/the_bundle.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require "support/helpers"
-require "support/path"
+require_relative "path"
module Spec
class TheBundle
- include Spec::Helpers
include Spec::Path
attr_accessor :bundle_dir