2017-03-07 12:07:13 +00:00
|
|
|
module RspecProfilingExt
|
|
|
|
module PSQL
|
|
|
|
def establish_connection
|
2017-05-07 22:35:20 +00:00
|
|
|
::RspecProfiling::Collectors::PSQL::Result.establish_connection(ENV['RSPEC_PROFILING_POSTGRES_URL'])
|
2017-03-07 12:07:13 +00:00
|
|
|
end
|
2017-01-26 21:31:43 +00:00
|
|
|
end
|
|
|
|
|
2017-03-07 12:07:13 +00:00
|
|
|
module Git
|
|
|
|
def branch
|
2017-03-24 18:57:27 +00:00
|
|
|
if ENV['CI_COMMIT_REF_NAME']
|
|
|
|
"#{defined?(Gitlab::License) ? 'ee' : 'ce'}:#{ENV['CI_COMMIT_REF_NAME']}"
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
2017-03-07 12:07:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Run
|
|
|
|
def example_finished(*args)
|
|
|
|
super
|
|
|
|
rescue => err
|
2017-11-17 12:27:16 +00:00
|
|
|
return if @already_logged_example_finished_error # rubocop:disable Cop/ModuleWithInstanceVariables
|
2017-03-07 12:07:13 +00:00
|
|
|
|
|
|
|
$stderr.puts "rspec_profiling couldn't collect an example: #{err}. Further warnings suppressed."
|
2017-11-17 12:27:16 +00:00
|
|
|
@already_logged_example_finished_error = true # rubocop:disable Cop/ModuleWithInstanceVariables
|
2017-03-07 12:07:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :example_passed, :example_finished
|
|
|
|
alias_method :example_failed, :example_finished
|
2017-02-10 13:31:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 21:31:43 +00:00
|
|
|
if Rails.env.test?
|
|
|
|
RspecProfiling.configure do |config|
|
2017-05-19 10:15:49 +00:00
|
|
|
if ENV['RSPEC_PROFILING_POSTGRES_URL'].present?
|
2017-03-07 12:07:13 +00:00
|
|
|
RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL)
|
2017-01-26 21:31:43 +00:00
|
|
|
config.collector = RspecProfiling::Collectors::PSQL
|
|
|
|
end
|
2017-02-10 13:31:06 +00:00
|
|
|
|
2017-04-28 18:05:39 +00:00
|
|
|
if ENV.key?('CI')
|
|
|
|
RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git)
|
|
|
|
RspecProfiling::Run.prepend(RspecProfilingExt::Run)
|
|
|
|
end
|
2017-03-07 12:07:13 +00:00
|
|
|
end
|
2017-01-26 21:31:43 +00:00
|
|
|
end
|