-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wip display failures backtrace grouped by exception
- Loading branch information
Showing
9 changed files
with
108 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,7 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
|
||
# log files | ||
exceptions_log_*.yml | ||
failures_log_*.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module FailingSpecDetector | ||
# a simplified Failure class allow us to store only the needed information | ||
class Failure | ||
attr_accessor :exception, :backtrace | ||
|
||
def initialize(exception, backtrace) | ||
@exception = exception | ||
@backtrace = backtrace | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'yaml' | ||
require_relative '../../failing_spec_detector/failure' | ||
|
||
namespace :failing_specs_detector do | ||
desc 'Print all logs in console' | ||
task :print_log do | ||
puts "Failing specs detector:\n" | ||
log_file_paths = Dir['failing_specs_detector_log_*.txt'] | ||
log_file_paths.each do |file_path| | ||
file = File.open(file_path, 'r') | ||
file_data = file.read | ||
puts file_data | ||
puts "Failing specs detector:\n\n\n" | ||
failures = [] | ||
exceptions = [] | ||
failures_file_paths = Dir['failures_log_*.yml'] | ||
exceptions_file_paths = Dir['exceptions_log_*.yml'] | ||
failures_file_paths.each do |file_path| | ||
failures.concat(YAML.load_file(file_path)) | ||
File.delete(file_path) | ||
end | ||
exceptions_file_paths.each do |file_path| | ||
exceptions.concat(YAML.load_file(file_path)) | ||
File.delete(file_path) | ||
end | ||
|
||
exceptions.each do |exception| | ||
puts "#{exception}:\n\n" | ||
related_examples = failures.select { |failure| failure.exception == exception } | ||
next if related_examples.empty? | ||
|
||
related_examples.each do |failure| | ||
puts "#{failure.backtrace}:\n" | ||
end | ||
puts "\n\n\n" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- Test Error 1 | ||
- Test Error 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- !ruby/object:FailingSpecDetector::Failure | ||
exception: Test Error 1 | ||
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'" | ||
- !ruby/object:FailingSpecDetector::Failure | ||
exception: Test Error 2 | ||
backtrace: "/spec/three_spec.rb:4:in `some_method'" |
This file was deleted.
Oops, something went wrong.