-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/setup" | ||
require "bundler/gem_tasks" | ||
require "rake/testtask" | ||
require 'bundler/setup' | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
|
||
# The extras that override the built-in methods need to be tested in isolation in order | ||
# to prevent them to change also the behavior and the result of the built-in tests. | ||
# We exclude them from the :test_main task and create a new task for them, then added to the :default task | ||
|
||
Rake::TestTask.new(:test_main) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList.new.include("test/**/*_test.rb") | ||
.exclude('test/**/items_and_countless_test.rb', | ||
'test/**/items_and_elasticsearch_test.rb', | ||
'test/**/headers_test.rb', | ||
'test/**/i18n_test.rb', | ||
'test/**/overflow_test.rb', | ||
'test/**/trim_test.rb', | ||
'test/**/elasticsearch_rails_test.rb', | ||
'test/**/searchkick_test.rb', | ||
'test/**/support_test.rb', | ||
'test/**/shared_test.rb', | ||
'test/**/shared_combo_test.rb') | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_items_and_countless) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/items_and_countless_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_items_and_elasticsearch) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/items_and_elasticsearch_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_headers) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/headers_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_i18n) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/i18n_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_overflow) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/overflow_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_trim) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/trim_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_extra_elasticsearch) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/elasticsearch_rails_test.rb', 'test/**/searchkick_test.rb'] | ||
end | ||
|
||
Rake::TestTask.new(:test_support) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/support_test.rb'] | ||
# We create a single task for each of them | ||
@test_tasks = {} | ||
|
||
def define_test_task(name, *files) | ||
@test_tasks[name] = files | ||
Rake::TestTask.new(name) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList[*files] | ||
end | ||
end | ||
|
||
Rake::TestTask.new(:test_shared) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/shared_test.rb'] | ||
end | ||
define_test_task :test_extra_items_and_countless, 'test/**/items_and_countless_test.rb' | ||
define_test_task :test_extra_items_and_elasticsearch, 'test/**/items_and_elasticsearch_test.rb' | ||
define_test_task :test_extra_headers, 'test/**/headers_test.rb' | ||
define_test_task :test_extra_i18n, 'test/**/i18n_test.rb' | ||
define_test_task :test_extra_overflow, 'test/**/overflow_test.rb' | ||
define_test_task :test_extra_trim, 'test/**/trim_test.rb' | ||
define_test_task :test_extra_elasticsearch, 'test/**/elasticsearch_rails_test.rb', 'test/**/searchkick_test.rb' | ||
define_test_task :test_support, 'test/**/support_test.rb' | ||
define_test_task :test_shared,'test/**/shared_test.rb' | ||
define_test_task :test_shared_combo, 'test/**/shared_combo_test.rb' | ||
|
||
Rake::TestTask.new(:test_shared_combo) do |t| | ||
# We exclude the files of the other tasks from the :test_main task | ||
Rake::TestTask.new(:test_main) do |t| | ||
t.libs += %w[test lib] | ||
t.test_files = FileList['test/**/shared_combo_test.rb'] | ||
t.test_files = FileList.new | ||
.include('test/**/*_test.rb') | ||
.exclude(@test_tasks.values.flatten) | ||
end | ||
|
||
desc 'Run all the individual test tasks' | ||
task test: [:test_main, *@test_tasks.keys] | ||
|
||
task :test => [ :test_main, | ||
:test_extra_items_and_countless, | ||
:test_extra_items_and_elasticsearch, | ||
:test_extra_headers, | ||
:test_extra_i18n, | ||
:test_extra_overflow, | ||
:test_extra_trim, | ||
:test_extra_elasticsearch, | ||
:test_support, | ||
:test_shared, | ||
:test_shared_combo ] | ||
|
||
if ENV['RUN_RUBOCOP'] == 'true' | ||
require "rubocop/rake_task" | ||
RuboCop::RakeTask.new(:rubocop) do |t| | ||
t.options = `git ls-files | grep -E '\\.rb$'`.split("\n") # limit rubocop to the files in the repo | ||
end | ||
task :default => [:test, :rubocop] | ||
else | ||
task :default => [:test] | ||
end | ||
task default: (if ENV['RUN_RUBOCOP'] == 'true' | ||
require 'rubocop/rake_task' | ||
RuboCop::RakeTask.new(:rubocop) do |t| | ||
t.options = `git ls-files | grep -E '\\.rb$'`.split("\n") # limit rubocop to the files in the repo | ||
end | ||
%i[test rubocop] | ||
else | ||
[:test] | ||
end) |