right_develop 2.1.3 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -14,6 +14,27 @@ To use our CI harness, just add the following to your Rakefile (or into lib/task
14
14
  require 'right_develop'
15
15
  RightDevelop::CI::RakeTask.new
16
16
 
17
+ ==== Integrating CI with Rails
18
+
19
+ For stateful apps, it is generally necessary to run some sort of database setup step prior to running tests.
20
+ Rails accomplishes this with the reusable "db:test:prepare" task which is declared as a dependency to the "spec"
21
+ task, ensuring that the DB is prepared before running tests.
22
+
23
+ RightDevelop has a similar hook; the ci:prep task is executed before running any ci:* task. If you need to perform
24
+ app-specific CI setup, you can hook into it like this:
25
+
26
+ task 'ci:prep' => ['db:my_special_setup_task']
27
+
28
+ Unfortunately, db:test:prepare does some things that aren't so useful in the CI environment, such as verifying
29
+ that the development DB exists and is fully migrated. The development DB is irrelevant when running tests, and if someone
30
+ has failed to commit changes to schema.rb then we _want_ the tests to break. Therefore, to setup a Rails app properly,
31
+ use the following dependency:
32
+
33
+ # Make sure we run the Rails DB-setup stuff before any CI run. Avoid using db:test:prepare
34
+ # because it also checks for pending migrations in the dev database, which is not useful to us.
35
+ task 'ci:prep' => ['db:test:purge', 'db:test:load', 'db:schema:load']
36
+
37
+
17
38
  ==== Customizing your CI Harness
18
39
 
19
40
  You can override various aspects of the CI harness' behavior by passing a block to the constructor which
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.1.5
@@ -60,7 +60,7 @@ module RightDevelop::CI
60
60
  end
61
61
 
62
62
  def classname_for(example)
63
- klass = example.example_group.described_class || example.example_group.top_level_description
63
+ klass = example.example_group.top_level_description || example.example_group.described_class
64
64
  klass = RightDevelop::CI::Util.pseudo_java_class_name(klass.to_s)
65
65
  "rspec.#{klass}"
66
66
  end
@@ -71,8 +71,8 @@ module RightDevelop::CI
71
71
  builder.testsuite :errors => 0, :failures => failure_count, :skipped => pending_count, :tests => example_count, :time => duration, :timestamp => Time.now.iso8601 do
72
72
  builder.properties
73
73
  @test_results.each do |test|
74
- classname = classname_for(test)
75
- full_description = test.full_description
74
+ classname = purify(classname_for(test))
75
+ full_description = purify(test.full_description)
76
76
  time = test.metadata[:execution_result][:run_time]
77
77
 
78
78
  # The full description always begins with the classname, but this is useless info when
@@ -85,7 +85,7 @@ module RightDevelop::CI
85
85
  case test.metadata[:execution_result][:status]
86
86
  when "failed"
87
87
  builder.failure :message => "failed #{full_description}", :type => "failed" do
88
- builder.cdata! failure_details_for test
88
+ builder.cdata! purify(failure_details_for(test))
89
89
  end
90
90
  when "pending" then
91
91
  builder.skipped
@@ -95,6 +95,10 @@ module RightDevelop::CI
95
95
  end
96
96
  output.puts builder.target!
97
97
  end
98
+
99
+ def purify(untrusted)
100
+ RightDevelop::CI::Util.purify(untrusted)
101
+ end
98
102
  end
99
103
  elsif defined?(::Spec::Runner)
100
104
  # RSpec 1.x
@@ -142,8 +146,8 @@ module RightDevelop::CI
142
146
  builder.testsuite :errors => 0, :failures => failure_count, :skipped => pending_count, :tests => example_count, :time => duration, :timestamp => Time.now.iso8601 do
143
147
  builder.properties
144
148
  @test_results.each_pair do |test, result|
145
- classname = classname_for(test)
146
- full_description = test.description
149
+ classname = purify(classname_for(test))
150
+ full_description = purify(test.description)
147
151
 
148
152
  # The full description always begins with the classname, but this is useless info when
149
153
  # generating the XML report.
@@ -155,7 +159,7 @@ module RightDevelop::CI
155
159
  case result
156
160
  when "failed"
157
161
  builder.failure :message => "failed #{full_description}", :type => "failed" do
158
- builder.cdata! failure_details_for(test)
162
+ builder.cdata! purify(failure_details_for(test))
159
163
  end
160
164
  when "pending" then
161
165
  builder.skipped
@@ -189,6 +193,10 @@ module RightDevelop::CI
189
193
  klass = RightDevelop::CI::Util.pseudo_java_class_name(klass)
190
194
  "rspec.#{klass}"
191
195
  end
196
+
197
+ def purify(untrusted)
198
+ RightDevelop::CI::Util.purify(untrusted)
199
+ end
192
200
  end
193
201
  else
194
202
  raise LoadError, "Cannot define RightDevelop::CI::JavaSpecFormatter: unsupported RSpec version"
@@ -1,3 +1,7 @@
1
+ if RUBY_VERSION =~ /^1\.8/
2
+ require 'iconv'
3
+ end
4
+
1
5
  module RightDevelop::CI
2
6
  module Util
3
7
  module_function
@@ -14,6 +18,11 @@ module RightDevelop::CI
14
18
  # Replacement codepoint that looks a bit like a period
15
19
  JAVE_PACKAGE_SEPARATOR_HOMOGLYPH = '·'
16
20
 
21
+ # Regular expression that matches characters that need to be escaped inside CDATA
22
+ # c.f. http://www.w3.org/TR/xml11/#charsets
23
+ # RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]
24
+ INVALID_CDATA_CHARACTER = Regexp.new '[\x01-\x08\x0b-\x0c\x0e-\x1f\x7f-\x84\x86-\x9f]', nil, 'n' # Ruby 1.8-2.1 compatible
25
+
17
26
  # Make a string suitable for parsing by Jenkins JUnit display plugin by escaping any non-valid
18
27
  # Java class name characters as an XML entity. This prevents Jenkins from interpreting "hi1.2"
19
28
  # as a package-and-class name.
@@ -36,5 +45,27 @@ module RightDevelop::CI
36
45
 
37
46
  result
38
47
  end
48
+
49
+ # Strip invalid UTF-8 sequences from a string and entity-escape any character that can't legally
50
+ # appear inside XML CDATA. If test output contains weird data, we could end up generating
51
+ # invalid JUnit XML which will choke Java. Preserve the purity of essence of our precious XML
52
+ # fluids!
53
+ #
54
+ # @return [String] the input with all invalid UTF-8 replaced by the empty string
55
+ # @param [String] untrusted a string (of any encoding) that might contain invalid UTF-8 sequences
56
+ def purify(untrusted)
57
+ # First pass: strip bad UTF-8 characters
58
+ if RUBY_VERSION =~ /^1\.8/
59
+ iconv = Iconv.new('UTF-8//IGNORE', 'UTF-8')
60
+ result = iconv.iconv(untrusted)
61
+ else
62
+ result = untrusted.force_encoding(Encoding::BINARY).encode('UTF-8', :undef=>:replace, :replace=>'')
63
+ end
64
+
65
+ # Second pass: entity escape characters that can't appear in XML CDATA.
66
+ result.gsub(INVALID_CDATA_CHARACTER) do |ch|
67
+ "&#x%s;" % [ch.unpack('H*').first]
68
+ end
69
+ end
39
70
  end
40
71
  end
@@ -113,6 +113,9 @@ module RightDevelop::Parsers
113
113
  end
114
114
  xml_object_node[parent_key] = child_node
115
115
  end
116
+ elsif parent_value.nil? && parent_key.pluralize == parent_key
117
+ #Wrap xml object in an array so it matches JSON format in cases where nothing is contained in parent node
118
+ xml_object_node[parent_key] = []
116
119
  end
117
120
  remove_nesting_node(parent_value)
118
121
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{right_develop}
8
- s.version = "2.1.3"
8
+ s.version = "2.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tony Spataro"]
12
- s.date = %q{2014-03-25}
12
+ s.date = %q{2014-04-14}
13
13
  s.default_executable = %q{right_develop}
14
14
  s.description = %q{A toolkit of development tools created by RightScale.}
15
15
  s.email = %q{support@rightscale.com}
data/right_develop.rconf CHANGED
@@ -10,5 +10,5 @@ ruby do
10
10
  end
11
11
 
12
12
  bundler do
13
- version '1.3.5'
13
+ version '1.5.3'
14
14
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_develop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 3
10
- version: 2.1.3
9
+ - 5
10
+ version: 2.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-03-25 00:00:00 -07:00
18
+ date: 2014-04-14 00:00:00 -07:00
19
19
  default_executable: right_develop
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency