[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
This commit is contained in:
David Rodriguez 2024-01-30 21:35:48 +01:00 коммит произвёл git
Родитель c70052e5d9
Коммит a322b2faa4
2 изменённых файлов: 13 добавлений и 31 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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