Skip to content

Commit

Permalink
Merge pull request #212 from pat/optional-activesupport
Browse files Browse the repository at this point in the history
Remove ActiveSupport from being a primary dependency.
  • Loading branch information
niceking authored Feb 20, 2024
2 parents 6875b65 + 5530fd1 commit 19134d1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PATH
remote: .
specs:
buildkite-test_collector (2.4.0)
activesupport (>= 4.2)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -38,6 +37,7 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 4.2)
buildkite-test_collector!
rake (~> 13.0)
rspec (~> 3.0)
Expand Down
3 changes: 1 addition & 2 deletions buildkite-test_collector.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")

spec.add_dependency "activesupport", ">= 4.2"

spec.add_development_dependency "activesupport", ">= 4.2"
spec.add_development_dependency "rspec-core", '~> 3.10'
spec.add_development_dependency "rspec-expectations", '~> 3.10'
end
9 changes: 5 additions & 4 deletions lib/buildkite/test_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ module TestCollector
require "json"
require "logger"
require "net/http"
require "openssl"
require "time"
require "timeout"
require "tmpdir"

require "active_support/core_ext/object/blank"
require "active_support/core_ext/hash/indifferent_access"
require "active_support/notifications"

require_relative "test_collector/version"
require_relative "test_collector/error"
require_relative "test_collector/ci"
Expand Down Expand Up @@ -72,6 +69,10 @@ def self.enable_tracing!
Buildkite::TestCollector::Network.configure
Buildkite::TestCollector::Object.configure

return unless defined?(ActiveSupport)

require "active_support/notifications"

ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
end
Expand Down
2 changes: 1 addition & 1 deletion lib/buildkite/test_collector/minitest_plugin/trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def as_hash
failure_reason: failure_reason,
failure_expanded: failure_expanded,
history: history,
).with_indifferent_access.select { |_, value| !value.nil? }
).select { |_, value| !value.nil? }
end

private
Expand Down
8 changes: 6 additions & 2 deletions lib/buildkite/test_collector/rspec_plugin/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def dump_summary(_notification)
RSpec::Core::MultipleExceptionError
]

def blank?(string)
string.nil? || string.strip.empty?
end

def failure_info(notification)
failure_expanded = []

Expand Down Expand Up @@ -73,9 +77,9 @@ def failure_info(notification)
def format_message_lines(message_lines)
message_lines.map! { |l| strip_diff_colors(l) }
# the first line is sometimes blank, depending on the error reported
message_lines.shift if message_lines.first.blank?
message_lines.shift if blank?(message_lines.first)
# the last line is sometimes blank, depending on the error reported
message_lines.pop if message_lines.last.blank?
message_lines.pop if blank?(message_lines.last)
message_lines
end

Expand Down
4 changes: 2 additions & 2 deletions lib/buildkite/test_collector/rspec_plugin/trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def as_hash
failure_reason: failure_reason,
failure_expanded: failure_expanded,
history: history,
).with_indifferent_access.select { |_, value| !value.nil? }
).select { |_, value| !value.nil? }
end

private
Expand Down Expand Up @@ -60,7 +60,7 @@ def file_name
end

def shared_example?
example.metadata[:shared_group_inclusion_backtrace].any?
!example.metadata[:shared_group_inclusion_backtrace].empty?
end

def shared_example_call_location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(output)

def dump_failures(notification)
# Do not display summary if no failed examples
return unless notification.failed_examples.present?
return if notification.failed_examples.empty?

# Check if a Test Analytics token is set
return unless Buildkite::TestCollector.api_token
Expand Down
2 changes: 1 addition & 1 deletion lib/buildkite/test_collector/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def as_hash
duration: end_at - start_at,
detail: detail,
children: children.map(&:as_hash),
}.with_indifferent_access
}
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "buildkite/test_collector"
require "active_support/notifications"

Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }

Expand Down

0 comments on commit 19134d1

Please sign in to comment.