summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodriguez <deivid.rodriguez@riseup.net>2024-01-30 21:35:48 +0100
committergit <svn-admin@ruby-lang.org>2024-01-31 13:22:38 +0000
commita322b2faa40959ffdbe6da077c778131cb1c894f (patch)
tree001e15b7f740560772a4e00d630bcc0a121b0a94 /spec
parentc70052e5d91ee51f80aebbb777f01c5b0920c073 (diff)
[rubygems/rubygems] Make slow perf specs more stable
This seems worse to detect performance regressions, but at least should not have many false positives. https://github.com/rubygems/rubygems/commit/0b28e55415
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/realworld/slow_perf_spec.rb18
-rw-r--r--spec/bundler/support/matchers.rb26
2 files changed, 13 insertions, 31 deletions
diff --git a/spec/bundler/realworld/slow_perf_spec.rb b/spec/bundler/realworld/slow_perf_spec.rb
index be557d3902..32e266ff1b 100644
--- a/spec/bundler/realworld/slow_perf_spec.rb
+++ b/spec/bundler/realworld/slow_perf_spec.rb
@@ -11,7 +11,8 @@ RSpec.describe "bundle install with complex dependencies", realworld: true do
gem "mongoid", ">= 0.10.2"
G
- expect { bundle "lock" }.to take_less_than(18) # seconds
+ bundle "lock", env: { "DEBUG_RESOLVER" => "1" }
+ expect(out).to include("Solution found after 1 attempts")
end
it "resolves quickly (case 2)" do
@@ -28,7 +29,8 @@ RSpec.describe "bundle install with complex dependencies", realworld: true do
gem 'rspec-rails'
G
- expect { bundle "lock" }.to take_less_than(30) # seconds
+ bundle "lock", env: { "DEBUG_RESOLVER" => "1" }
+ expect(out).to include("Solution found after 1 attempts")
end
it "resolves big gemfile quickly" do
@@ -129,8 +131,14 @@ RSpec.describe "bundle install with complex dependencies", realworld: true do
end
G
- expect do
- bundle "lock", env: { "DEBUG_RESOLVER" => "1" }, raise_on_error: !Bundler.feature_flag.bundler_3_mode?
- end.to take_less_than(30) # seconds
+ if Bundler.feature_flag.bundler_3_mode?
+ bundle "lock", env: { "DEBUG_RESOLVER" => "1" }, raise_on_error: false
+
+ expect(out).to include("backtracking").exactly(26).times
+ else
+ bundle "lock", env: { "DEBUG_RESOLVER" => "1" }
+
+ expect(out).to include("Solution found after 10 attempts")
+ end
end
end
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
index 9d604bec25..0f027dcf04 100644
--- a/spec/bundler/support/matchers.rb
+++ b/spec/bundler/support/matchers.rb
@@ -97,32 +97,6 @@ module Spec
end
end
- RSpec::Matchers.define :take_less_than do |seconds|
- match do |actual|
- start_time = Time.now
-
- actual.call
-
- actual_time = (Time.now - start_time).to_f
-
- acceptable = actual_time < seconds
-
- @errors = ["took #{actual_time} seconds"] unless acceptable
-
- acceptable
- end
-
- failure_message do
- super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
- end
-
- failure_message_when_negated do
- super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
- end
-
- supports_block_expectations
- end
-
define_compound_matcher :read_as, [exist] do |file_contents|
diffable