Skip to content

Commit 8ae0632

Browse files
committed
[CI] Updates Test Coverage
- Updates calling simplecov - Removes simplecov-rcov dependency: Gem is no longer maintained and not currently relevant. - Clarifies READMEs for using COVERAGE - Simplifies defaults for `elasticsearch` tests
1 parent 6629215 commit 8ae0632

File tree

11 files changed

+29
-37
lines changed

11 files changed

+29
-37
lines changed

Diff for: Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ gem 'rake'
2929
gem 'rubocop'
3030
gem 'shoulda-context'
3131
gem 'simplecov'
32-
gem 'simplecov-rcov'
3332
gem 'test-unit', '~> 2'
3433
gem 'yard'
3534
unless defined?(JRUBY_VERSION) || defined?(Rubinius)

Diff for: elasticsearch-api/elasticsearch-api.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Gem::Specification.new do |s|
6868
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
6969
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
7070
s.add_development_dependency 'simplecov'
71-
s.add_development_dependency 'simplecov-rcov'
7271

7372
s.add_development_dependency 'test-unit', '~> 2'
7473

Diff for: elasticsearch-api/spec/spec_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
if ENV['COVERAGE'] && ENV['CI'].nil?
18+
require 'simplecov'
19+
SimpleCov.start { add_filter %r{^/test|spec/} }
20+
end
1721

1822
if defined?(JRUBY_VERSION)
1923
require 'pry-nav'

Diff for: elasticsearch-transport/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,14 @@ Github's pull requests and issues are used to communicate, send bug reports and
621621
To work on the code, clone and bootstrap the main repository first --
622622
please see instructions in the main [README](../README.md#development).
623623

624-
To run tests, launch a testing cluster -- again, see instructions
625-
in the main [README](../README.md#development) -- and use the Rake tasks:
624+
To run tests, launch a testing cluster and use the Rake tasks:
626625

627626
```bash
628627
time rake test:unit
629628
time rake test:integration
630629
```
631630

632-
Unit tests have to use Ruby 1.8 compatible syntax, integration tests
633-
can use Ruby 2.x syntax and features.
631+
Use `COVERAGE=true` before running a test task to check coverage with Simplecov.
634632

635633
## License
636634

Diff for: elasticsearch-transport/elasticsearch-transport.gemspec

+2-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
5353
s.add_development_dependency 'curb' unless defined? JRUBY_VERSION
5454
s.add_development_dependency 'hashie'
5555
s.add_development_dependency 'httpclient'
56-
s.add_development_dependency 'manticore', '~> 0.6' if defined? JRUBY_VERSION
56+
s.add_development_dependency 'manticore' if defined? JRUBY_VERSION
5757
s.add_development_dependency 'minitest'
5858
s.add_development_dependency 'minitest-reporters'
5959
s.add_development_dependency 'mocha'
@@ -64,8 +64,7 @@ Gem::Specification.new do |s|
6464
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
6565
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
6666
s.add_development_dependency 'shoulda-context'
67-
s.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
68-
s.add_development_dependency 'simplecov-rcov'
67+
s.add_development_dependency 'simplecov'
6968
s.add_development_dependency 'test-unit', '~> 2'
7069
s.add_development_dependency 'typhoeus', '~> 1.4'
7170
s.add_development_dependency 'yard'

Diff for: elasticsearch-transport/spec/spec_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
if ENV['COVERAGE'] && ENV['CI'].nil?
18+
require 'simplecov'
19+
SimpleCov.start { add_filter %r{^/test|spec/} }
20+
end
1721

1822
require 'elasticsearch'
1923
require 'elasticsearch-transport'

Diff for: elasticsearch-transport/test/test_helper.rb

+2-9
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,9 @@
2828

2929
JRUBY = defined?(JRUBY_VERSION)
3030

31-
if ENV['COVERAGE'] && ENV['CI'].nil?
31+
if ENV['COVERAGE']
3232
require 'simplecov'
33-
SimpleCov.start { add_filter "/test|test_/" }
34-
end
35-
36-
if ENV['CI']
37-
require 'simplecov'
38-
require 'simplecov-rcov'
39-
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
40-
SimpleCov.start { add_filter "/test|test_" }
33+
SimpleCov.start { add_filter %r{^/test/} }
4134
end
4235

4336
require 'minitest/autorun'

Diff for: elasticsearch/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ Please refer to the specific library documentation for details:
8686
[[README]](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-api/README.md)
8787
[[Documentation]](http://rubydoc.info/gems/elasticsearch-api/file/README.markdown)
8888

89+
## Development
90+
91+
You can run `rake -T` to check the test tasks. Use `COVERAGE=true` before running a test task to check the coverage with Simplecov.
92+
8993
## License
9094

9195
This software is licensed under the [Apache 2 license](./LICENSE).

Diff for: elasticsearch/elasticsearch.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ Gem::Specification.new do |s|
6161
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
6262
s.add_development_dependency 'shoulda-context'
6363
s.add_development_dependency 'simplecov'
64-
s.add_development_dependency 'simplecov-rcov'
6564
s.add_development_dependency 'test-unit', '~> 2'
6665
s.add_development_dependency 'yard'
6766

Diff for: elasticsearch/test/integration/client_integration_test.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Test
2424
class ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
2525
context "Elasticsearch client" do
2626
setup do
27-
system "curl -X DELETE http://#{TEST_HOST}:#{TEST_PORT}/_all > /dev/null 2>&1"
27+
system "curl -X DELETE http://#{ELASTICSEARCH_URL}/_all > /dev/null 2>&1"
2828

2929
@logger = Logger.new(STDERR)
3030
@logger.formatter = proc do |severity, datetime, progname, msg|
@@ -37,14 +37,17 @@ class ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
3737
ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
3838
end
3939

40-
@client = Elasticsearch::Client.new host: "#{TEST_HOST}:#{TEST_PORT}", logger: (ENV['QUIET'] ? nil : @logger)
40+
@client = Elasticsearch::Client.new(
41+
host: ELASTICSEARCH_URL,
42+
logger: (ENV['QUIET'] ? nil : @logger)
43+
)
4144
end
4245

4346
should "perform the API methods" do
4447
assert_nothing_raised do
4548
# Index a document
4649
#
47-
@client.index index: 'test-index', id: '1', body: { title: 'Test', type: 'test-type' }
50+
@client.index(index: 'test-index', id: '1', body: { title: 'Test', type: 'test-type' })
4851

4952
# Refresh the index
5053
#

Diff for: elasticsearch/test/test_helper.rb

+5-15
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,16 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
require 'uri'
1718

18-
ELASTICSEARCH_HOSTS = if (hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS'])
19-
hosts.split(',').map do |host|
20-
/(http\:\/\/)?(\S+)/.match(host)[2]
21-
end
22-
end.freeze
23-
24-
TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
19+
ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] ||
20+
"http://localhost:#{(ENV['PORT'] || 9200)}"
21+
raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
2522

2623
JRUBY = defined?(JRUBY_VERSION)
2724

28-
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
29-
require 'simplecov'
30-
SimpleCov.start { add_filter "/test|test_/" }
31-
end
32-
33-
if ENV['CI']
25+
if ENV['COVERAGE']
3426
require 'simplecov'
35-
require 'simplecov-rcov'
36-
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
3727
SimpleCov.start { add_filter "/test|test_" }
3828
end
3929

0 commit comments

Comments
 (0)