Skip to content

Commit

Permalink
fix: start simplecov before library code is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
zvkemp committed Jan 24, 2025
1 parent f1ec3e7 commit 6faa684
Show file tree
Hide file tree
Showing 59 changed files with 73 additions and 39 deletions.
15 changes: 15 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'digest'

digest = Digest::MD5.new
digest.update('test')
digest.update(ENV.fetch('BUNDLE_GEMFILE', 'gemfile')) if ENV['APPRAISAL_INITIALIZED']

ENV['ENABLE_COVERAGE'] ||= 1

if ENV['ENABLE_COVERAGE'].to_i.positive?
SimpleCov.command_name(digest.hexdigest)
SimpleCov.minimum_coverage(85)
SimpleCov.start do
add_filter %r{^/test/}
end
end
1 change: 1 addition & 0 deletions helpers/mysql/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_mailer/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_pack/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_job/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0
ENV['OTEL_LOG_LEVEL'] ||= 'fatal'

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_record/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_support/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/all/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/aws_lambda/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
4 changes: 1 addition & 3 deletions instrumentation/base/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

SimpleCov.start
SimpleCov.minimum_coverage 85

require 'opentelemetry-instrumentation-base'
require 'minitest/autorun'

Expand Down
1 change: 1 addition & 0 deletions instrumentation/bunny/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/concurrent_ruby/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/dalli/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/delayed_job/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/ethon/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/excon/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/faraday/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/grape/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/graphql/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/grpc/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/gruf/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'opentelemetry/sdk'
require 'minitest/autorun'
require 'webmock/minitest'
Expand Down
1 change: 1 addition & 0 deletions instrumentation/http/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/http_client/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/httpx/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/koala/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/lmdb/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/mongo/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/mysql2/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/net_http/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'net/http'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/pg/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/que/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/racecar/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/rack/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
require 'rack/events'
Expand Down
6 changes: 5 additions & 1 deletion instrumentation/rails/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ namespace :test do
t.libs << 'test/railtie'
t.test_files = FileList['test/railtie/**/*_test.rb']
end

task :start_coverage do |t|
require 'simplecov'
end
end

desc 'Run all tests'
task test: %i[test:instrumentation test:railtie]
task test: %i[test:start_coverage test:instrumentation test:railtie]

YARD::Rake::YardocTask.new do |t|
t.stats_options = ['--list-undoc']
Expand Down
4 changes: 0 additions & 4 deletions instrumentation/rails/test/instrumentation/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

require 'logger'

require 'simplecov'
SimpleCov.command_name(:instrumentation_tests) # custom name required to merge with the 'railtie' tests
SimpleCov.start

require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
3 changes: 0 additions & 3 deletions instrumentation/rails/test/railtie/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
ENV['RAILS_ENV'] = 'test'

require 'logger'

require 'simplecov'
SimpleCov.command_name(:railtie_tests) # custom name required to merge with the 'instrumentation' tests
SimpleCov.start

require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/rake/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/rdkafka/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/redis/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/resque/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/restclient/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
3 changes: 2 additions & 1 deletion instrumentation/rspec/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#
# SPDX-License-Identifier: Apache-2.0

# This gem does not use Bundler to require gems because it is testing confilicting features between rspec and minitest.
# This gem does not use Bundler to require gems because it is testing conflicting features between rspec and minitest.
require 'simplecov'
require 'opentelemetry/sdk'
require 'opentelemetry-test-helpers'

Expand Down
1 change: 1 addition & 0 deletions instrumentation/ruby_kafka/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Loading

0 comments on commit 6faa684

Please sign in to comment.