rspec_junit_formatter 0.3.0.pre5 → 0.3.0.pre6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca1245d6a6ab72821ed12421f83f5d19e160e150
4
- data.tar.gz: 8adb046de7cfa63694143046bedbcff68e496637
3
+ metadata.gz: be30b335dd3130df8c78a8d441d353ebf8dfa763
4
+ data.tar.gz: 518e4ec66af2bfb1a453832d76febc9840b2c8f0
5
5
  SHA512:
6
- metadata.gz: 27bf67f53a85bb7a352d0b2885e9a96f169cd28be692870a24848f04e1572ef3b7c0d0a53928b2a7ec8a709b79bbbc20c79c41090003579cfb2490d9c202a57b
7
- data.tar.gz: bb2cdff147bacaa458925108244595bae509b1d26398a20b741d6057720d9759f479e8cefedff4e7bb9e80210126efa43e8f269bed5d3b8b1d4632eb1f953361
6
+ metadata.gz: 603786fbf12485e4eeca039736ad85f36b2fdfadb77c22506a0b3a749be3150a4e6df8f059bebe2ccbf7f016945a4bfe81c64e27bb12aadfc4e609f5dc793d5d
7
+ data.tar.gz: a779567c3fea19f86de5289bd72a2b21e604322b91804813812bcf318940c82a5dd1753399fd2389229708a4dac1ce6b33f1ab4ee54eeac2550eaa04b503ad0f
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -58,6 +58,13 @@ For use with `parallel_tests`, add `$TEST_ENV_NUMBER` in the output file option
58
58
 
59
59
  The formatter includes `$TEST_ENV_NUMBER` in the test suite name within the XML, too.
60
60
 
61
+ ## Caveats
62
+
63
+ * XML can only represent a [limited subset of characters][xml-charsets] which
64
+ excludes null bytes and most control characters. This gem will use character
65
+ entities where possible and fall back to replacing invalid characters with
66
+ Ruby-like escape codes otherwise. For example, the null byte becomes `\0`.
67
+
61
68
  ## Roadmap
62
69
 
63
70
  * It would be nice to split things up into individual test suites, although
@@ -78,3 +85,4 @@ The MIT License, see [LICENSE][license].
78
85
  [bundler]: http://gembundler.com/
79
86
  [fuubar]: http://jeffkreeftmeijer.com/2010/fuubar-the-instafailing-rspec-progress-bar-formatter/
80
87
  [license]: https://github.com/sj26/rspec-junit-formatter/blob/master/LICENSE
88
+ [xml-charsets]: https://www.w3.org/TR/xml/#charsets
@@ -1,3 +1,4 @@
1
+ require "socket"
1
2
  require "time"
2
3
 
3
4
  require "rspec/core"
@@ -15,10 +16,12 @@ private
15
16
  output << %{<testsuite}
16
17
  output << %{ name="rspec#{escape(ENV["TEST_ENV_NUMBER"].to_s)}"}
17
18
  output << %{ tests="#{example_count}"}
19
+ output << %{ skipped="#{pending_count}"}
18
20
  output << %{ failures="#{failure_count}"}
19
21
  output << %{ errors="0"}
20
22
  output << %{ time="#{escape("%.6f" % duration)}"}
21
23
  output << %{ timestamp="#{escape(started.iso8601)}"}
24
+ output << %{ hostname="#{escape(Socket.gethostname)}"}
22
25
  output << %{>\n}
23
26
  output << %{<properties>\n}
24
27
  output << %{<property}
@@ -32,14 +35,17 @@ private
32
35
 
33
36
  def xml_dump_examples
34
37
  examples.each do |example|
35
- send :"xml_dump_#{result_of(example)}", example
38
+ case result_of(example)
39
+ when :pending
40
+ xml_dump_pending(example)
41
+ when :failed
42
+ xml_dump_failed(example)
43
+ else
44
+ xml_dump_example(example)
45
+ end
36
46
  end
37
47
  end
38
48
 
39
- def xml_dump_passed(example)
40
- xml_dump_example(example)
41
- end
42
-
43
49
  def xml_dump_pending(example)
44
50
  xml_dump_example(example) do
45
51
  output << %{<skipped/>}
@@ -51,8 +57,8 @@ private
51
57
 
52
58
  xml_dump_example(example) do
53
59
  output << %{<failure}
54
- output << %{ message="#{escape(exception.to_s)}"}
55
- output << %{ type="#{escape(exception.class.name)}"}
60
+ output << %{ message="#{escape(failure_message_for(example))}"}
61
+ output << %{ type="#{escape(failure_type_for(example))}"}
56
62
  output << %{>}
57
63
  output << escape(failure_for(example))
58
64
  output << %{</failure>}
@@ -14,7 +14,7 @@ class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
14
14
  private
15
15
 
16
16
  def result_of(example)
17
- example.execution_result[:status]
17
+ example.execution_result[:status].to_sym
18
18
  end
19
19
 
20
20
  def example_group_file_path_for(example)
@@ -42,6 +42,14 @@ private
42
42
  example.execution_result[:exception]
43
43
  end
44
44
 
45
+ def failure_type_for(example)
46
+ exception_for(example).class.name
47
+ end
48
+
49
+ def failure_message_for(example)
50
+ exception_for(example).to_s
51
+ end
52
+
45
53
  def failure_for(example)
46
54
  exception = exception_for(example)
47
55
  backtrace = format_backtrace(exception.backtrace, example)
@@ -24,11 +24,15 @@ private
24
24
  attr_reader :started
25
25
 
26
26
  def example_count
27
- @summary_notification.examples.count
27
+ @summary_notification.example_count
28
+ end
29
+
30
+ def pending_count
31
+ @summary_notification.pending_count
28
32
  end
29
33
 
30
34
  def failure_count
31
- @summary_notification.failed_examples.count
35
+ @summary_notification.failure_count
32
36
  end
33
37
 
34
38
  def duration
@@ -64,13 +68,37 @@ private
64
68
  notification.example.full_description
65
69
  end
66
70
 
71
+ def failure_type_for(example)
72
+ exception_for(example).class.name
73
+ end
74
+
75
+ def failure_message_for(example)
76
+ strip_diff_colors(exception_for(example).to_s)
77
+ end
78
+
67
79
  def failure_for(notification)
68
- notification.message_lines.join("\n") << "\n" << notification.formatted_backtrace.join("\n")
80
+ strip_diff_colors(notification.message_lines.join("\n")) << "\n" << notification.formatted_backtrace.join("\n")
69
81
  end
70
82
 
71
83
  def exception_for(notification)
72
84
  notification.example.execution_result.exception
73
85
  end
86
+
87
+ STRIP_DIFF_COLORS_BLOCK_REGEXP = /^ ( [ ]* ) Diff: \e\[0m (?: \n \1 \e\[0m .* )* /x
88
+ STRIP_DIFF_COLORS_CODES_REGEXP = /\e\[\d+m/
89
+
90
+ def strip_diff_colors(string)
91
+ # XXX: RSpec diffs are appended to the message lines fairly early and will
92
+ # contain ANSI escape codes for colorizing terminal output if the global
93
+ # rspec configuration is turned on, regardless of which notification lines
94
+ # we ask for. We need to strip the codes from the diff part of the message
95
+ # for XML output here.
96
+ #
97
+ # We also only want to target the diff hunks because the failure message
98
+ # itself might legitimately contain ansi escape codes.
99
+ #
100
+ string.sub(STRIP_DIFF_COLORS_BLOCK_REGEXP) { |match| match.gsub(STRIP_DIFF_COLORS_CODES_REGEXP, "".freeze) }
101
+ end
74
102
  end
75
103
 
76
104
  # rspec-core 3.0.x forgot to mark this as a module function which causes:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_junit_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre5
4
+ version: 0.3.0.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran
@@ -28,7 +28,7 @@ cert_chain:
28
28
  bn56+Lu22lsUMYD62lUEdAPyYn1/JLPfq47UEuV1p5gy/f++aTxknsAYE/z/bfmO
29
29
  EkIxoeESVQ0Kqhp754GWYv3Sfmtyk8UbGo5XCZHzvC6h2G7mplPzh6o+Edw=
30
30
  -----END CERTIFICATE-----
31
- date: 2017-06-14 00:00:00.000000000 Z
31
+ date: 2017-06-23 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-core
metadata.gz.sig CHANGED
Binary file