Skip to content

Commit 46d35eb

Browse files
committed
Updated main Rakefile (adapted from elasticsearch-ruby)
1 parent 80da449 commit 46d35eb

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

Rakefile

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require 'pathname'
22

33
subprojects = %w| elasticsearch-model elasticsearch-rails |
4+
45
__current__ = Pathname( File.expand_path('..', __FILE__) )
56

67
task :default do
78
system "rake --tasks"
89
end
910

10-
desc "List all subprojects"
1111
task :subprojects do
1212
puts '-'*80
1313
subprojects.each do |project|
@@ -17,31 +17,53 @@ task :subprojects do
1717
end
1818
end
1919

20-
namespace :test do
20+
desc "Alias for `bundle:install`"
21+
task :bundle => 'bundle:install'
22+
23+
namespace :bundle do
2124
desc "Run `bundle install` in all subprojects"
22-
task :bundle do
25+
task :install do
26+
puts '-'*80
27+
sh "bundle install --gemfile #{__current__}/Gemfile"
28+
puts
2329
subprojects.each do |project|
24-
sh "bundle install --gemfile #{__current__.join(project)}/Gemfile"
2530
puts '-'*80
31+
sh "bundle install --gemfile #{__current__.join(project)}/Gemfile"
32+
puts
2633
end
2734
end
2835

36+
desc "Remove Gemfile.lock in all subprojects"
37+
task :clean do
38+
sh "rm -f Gemfile.lock"
39+
subprojects.each do |project|
40+
sh "rm -f #{__current__.join(project)}/Gemfile.lock"
41+
end
42+
end
43+
end
44+
45+
namespace :test do
46+
task :bundle => 'bundle:install'
47+
2948
desc "Run unit tests in all subprojects"
3049
task :unit do
3150
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
3251
subprojects.each do |project|
33-
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:unit"
3452
puts '-'*80
53+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:unit"
54+
puts "\n"
3555
end
3656
Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
3757
end
3858

3959
desc "Run integration tests in all subprojects"
4060
task :integration do
61+
Rake::Task['elasticsearch:update'].invoke
4162
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
4263
subprojects.each do |project|
43-
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:integration"
4464
puts '-'*80
65+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:integration"
66+
puts "\n"
4567
end
4668
Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
4769
end
@@ -50,8 +72,9 @@ namespace :test do
5072
task :all do
5173
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
5274
subprojects.each do |project|
53-
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:all"
5475
puts '-'*80
76+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:all"
77+
puts "\n"
5578
end
5679
end
5780

@@ -72,7 +95,7 @@ namespace :test do
7295
end
7396
end
7497

75-
namespace :server do
98+
namespace :cluster do
7699
desc "Start Elasticsearch nodes for tests"
77100
task :start do
78101
require 'elasticsearch/extensions/test/cluster'
@@ -84,6 +107,12 @@ namespace :test do
84107
require 'elasticsearch/extensions/test/cluster'
85108
Elasticsearch::Extensions::Test::Cluster.stop
86109
end
110+
111+
task :status do
112+
require 'elasticsearch/extensions/test/cluster'
113+
(puts "\e[31m[!] Test cluster not running\e[0m"; exit(1)) unless Elasticsearch::Extensions::Test::Cluster.running?
114+
Elasticsearch::Extensions::Test::Cluster.__print_cluster_info(ENV['TEST_CLUSTER_PORT'] || 9250)
115+
end
87116
end
88117
end
89118

0 commit comments

Comments
 (0)