Skip to content

Commit 12e6e13

Browse files
committed
Use YAML class
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
1 parent fd92ce5 commit 12e6e13

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'yaml'
2+
13
class YamlFormatter
24
def print_context(*) ; end
35

@@ -10,20 +12,20 @@ def print_failure(*); end
1012
def print_skipped(*); end
1113

1214
def print_finish(test_count, failures, errors, skipped)
13-
print "---\n"
15+
struct = {
16+
'examples' => test_count,
17+
'failures' => failures.size,
18+
'errors' => errors.size,
19+
}
1420
if failures.any? || errors.any?
15-
print "exceptions:\n"
16-
(errors + failures).each do |failure|
21+
outcomes = (errors + failures).map do |failure|
1722
context, test, error = failure
1823
outcome = error.is_a?(SpecFailedException) ? 'FAILED' : 'ERROR'
1924
str = "#{test} #{outcome}\n"
2025
str << error.message << "\n" << error.backtrace.to_s
21-
print '- ', str.inspect, "\n"
2226
end
27+
struct['exception'] = outcomes
2328
end
24-
25-
print 'examples: ', test_count, "\n"
26-
print 'failures: ', failures.size, "\n"
27-
print 'errors: ', errors.size, "\n"
29+
print struct.to_yaml
2830
end
2931
end

0 commit comments

Comments
 (0)