Skip to content

Commit

Permalink
distinguish between requeued passed and requeued failed
Browse files Browse the repository at this point in the history
distinguish between passed and failed requeued to remove from the
junit report. Add example_passed in the formatter registration.
  • Loading branch information
jbutte committed Nov 11, 2021
1 parent 70942f7 commit baeb5c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/rspecq/formatters/junit_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def initialize(queue, job, max_requeues, job_index, path)
@queue = queue
@job = job
@max_requeues = max_requeues
@requeued_examples = []
@requeued_passed_examples = []
@requeued_failed_examples = []
path = path.gsub(/{{TEST_ENV_NUMBER}}/,ENV["TEST_ENV_NUMBER"].to_s)
path = path.gsub(/{{JOB_INDEX}}/, job_index.to_s)
RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(path))
Expand All @@ -20,30 +21,31 @@ def initialize(queue, job, max_requeues, job_index, path)
def example_passed(notification)
# if it is a requeued run, store the notification
if !ENV["ERROR_CONTEXT_BASE_PATH"].nil?
@requeued_examples << notification.example
@requeued_passed_examples << notification.example
end
end

def example_failed(notification)
# if it is a requeued run, store the notification
if !ENV["ERROR_CONTEXT_BASE_PATH"].nil?
@requeued_examples << notification.example
@requeued_failed_examples << notification.example
end
end

private

def example_count
@summary_notification.example_count - @requeued_examples.size
@summary_notification.example_count - (@requeued_passed_examples.size + @requeued_failed_examples.size)
end

def failure_count
@summary_notification.failure_count - @requeued_examples.size
@summary_notification.failure_count - @requeued_failed_examples.size
end

def examples
ignore_examples = @requeued_failed_examples.union(@requeued_passed_examples)
@examples_notification.notifications.reject do |example_notification|
@requeued_examples.map(&:id).include?(example_notification.example.id)
ignore_examples.map(&:id).include?(example_notification.example.id)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspecq/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def initialize(build_id:, worker_id:, redis_opts:)
RSpec::Core::Formatters.register(Formatters::ExampleCountRecorder, :dump_summary)
RSpec::Core::Formatters.register(Formatters::FailureRecorder, :example_failed, :message)
RSpec::Core::Formatters.register(Formatters::WorkerHeartbeatRecorder, :example_finished)
RSpec::Core::Formatters.register(Formatters::JUnitFormatter, :example_failed, :start, :stop, :dump_summary)
RSpec::Core::Formatters.register(Formatters::JUnitFormatter, :example_passed, :example_failed, :start, :stop, :dump_summary)
end

def work
Expand Down

0 comments on commit baeb5c6

Please sign in to comment.