Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pub sub #62

Draft
wants to merge 3 commits into
base: flaky-exception-details
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/rspecq.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "rspec/core"
require "sentry-raven"
require 'active_support'

module RSpecQ
# If a worker haven't executed an example for more than WORKER_LIVENESS_SEC
Expand All @@ -13,6 +14,8 @@ module RSpecQ
require_relative "rspecq/formatters/job_timing_recorder"
require_relative "rspecq/formatters/worker_heartbeat_recorder"

require_relative "rspecq/integrations"

require_relative "rspecq/queue"
require_relative "rspecq/reporter"
require_relative "rspecq/version"
Expand Down
4 changes: 4 additions & 0 deletions lib/rspecq/formatters/failure_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def message(n)
end

def example_failed(notification)
ActiveSupport::Notifications.instrument('failure.rspec.rspecq', {
notification: notification
})

example = notification.example

presenter = RSpec::Core::Formatters::ExceptionPresenter.new(
Expand Down
1 change: 1 addition & 0 deletions lib/rspecq/integrations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative 'integrations/dummy'
5 changes: 5 additions & 0 deletions lib/rspecq/integrations/dummy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ActiveSupport::Notifications.subscribe %r{.rspec.rspecq} do |*args|
ActiveSupport::Notifications.subscribe "failure.rspec.rspecq" do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
puts "FRAGOU #{event.payload[:notification].example.location_rerun_argument}"
end
11 changes: 10 additions & 1 deletion lib/rspecq/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@ def work
end

opts = RSpec::Core::ConfigurationOptions.new(["--format", "progress", job])
_result = RSpec::Core::Runner.new(opts).run($stderr, $stdout)

data = {
job: job,
opts: opts,
seed: seed,
worker_id: @worker_id
}
ActiveSupport::Notifications.instrument('run.rspec.rspecq', data) do
RSpec::Core::Runner.new(opts).run($stderr, $stdout)
end

queue.acknowledge_job(job)
end
Expand Down
1 change: 1 addition & 0 deletions rspecq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Gem::Specification.new do |s|

s.add_dependency "redis"
s.add_dependency "sentry-raven"
s.add_dependency "activesupport", "~> 6.0"

s.add_development_dependency "minitest"
s.add_development_dependency "pry-byebug"
Expand Down