Skip to content

Commit

Permalink
Use YAML class
Browse files Browse the repository at this point in the history
This results in a double free, which does not happen in GDB. Time to get
out the core dumps.

To create a core file:

    bin/natalie -c dump spec/core/string/dump_spec.rb
    ulimit -c unlimited
    ./dump -f yaml
    gdb dump core
  • Loading branch information
herwinw committed Feb 26, 2024
1 parent 2caeb43 commit 93da6b9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/support/formatters/yaml_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'yaml'

class YamlFormatter
def print_context(*) ; end

Expand All @@ -10,20 +12,20 @@ def print_failure(*); end
def print_skipped(*); end

def print_finish(test_count, failures, errors, skipped)
print "---\n"
struct = {
'examples' => test_count,
'failures' => failures.size,
'errors' => errors.size,
}
if failures.any? || errors.any?
print "exceptions:\n"
(errors + failures).each do |failure|
outcomes = (errors + failures).map do |failure|
context, test, error = failure
outcome = error.is_a?(SpecFailedException) ? 'FAILED' : 'ERROR'
str = "#{test} #{outcome}\n"
str << error.message << "\n" << error.backtrace.to_s
print '- ', str.inspect, "\n"
end
struct['exception'] = outcomes
end

print 'examples: ', test_count, "\n"
print 'failures: ', failures.size, "\n"
print 'errors: ', errors.size, "\n"
print struct.to_yaml
end
end

0 comments on commit 93da6b9

Please sign in to comment.