Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
safafa committed Jan 25, 2024
1 parent 819e3a5 commit 8d1b05f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ jobs:
name: Exceptions
- name: Run print_log task
run: bundle exec rake failing_specs_detector:print_log
- name: File Reader
id: read_file
uses: juliangruber/[email protected]
with:
path: "failing_specs_detector_log.txt"
- name: File contents
run: echo "${{ steps.read_file.outputs.content }}"

12 changes: 8 additions & 4 deletions lib/failing_spec_detector/combiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ class Combiner
def initialize(exceptions, failures)
@exceptions = exceptions
@failures = failures
@filename = 'failing_specs_detector_log.txt'
end

def combine
puts "Failing specs detector:\n\n\n"
File.write(@filename, "Failing spec detector:\n\n\n")
return if @exceptions.empty?

@exceptions.uniq.each do |exception|
puts "#{exception}:\n\n"
File.write(@filename, "#{exception}:\n\n", mode: 'a')
related_examples = @failures.select { |failure| failure.exception == exception }
next if related_examples.empty?

related_examples.each do |failure|
puts "#{failure.backtrace}:\n"
File.write(@filename, "#{failure.backtrace}:\n", mode: 'a')
end
puts "\n\n\n"
File.write(@filename, "\n\n\n", mode: 'a')
end
File.write(@filename, '----------------------------------------------------------------', mode: 'a')
end
end
end
2 changes: 1 addition & 1 deletion lib/failing_spec_detector/failing_spec_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def example_failed(failure)

@exceptions << exception unless @exceptions.include?(exception)

failure = Failure.new(exception, failure.formatted_backtrace.join("\n"))
failure = Failure.new(exception, failure.formatted_backtrace.join("\n").tr(%q("'`), ' '))

@failures << failure
end
Expand Down
6 changes: 3 additions & 3 deletions spec/support/expected_failures_log_.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- !ruby/object:FailingSpecDetector::Failure
exception: Test Error 1
backtrace: "/spec/one_spec.rb:11:in `some_method'"
backtrace: "/spec/one_spec.rb:11:in some_method "
- !ruby/object:FailingSpecDetector::Failure
exception: Test Error 1
backtrace: "/spec/two_spec.rb:20:in `some_method'"
backtrace: "/spec/two_spec.rb:20:in some_method "
- !ruby/object:FailingSpecDetector::Failure
exception: Test Error 2
backtrace: "/spec/three_spec.rb:4:in `some_method'"
backtrace: "/spec/three_spec.rb:4:in some_method "

0 comments on commit 8d1b05f

Please sign in to comment.