lib/parallel_tests/tasks.rb in parallel_tests-0.8.1 vs lib/parallel_tests/tasks.rb in parallel_tests-0.8.2
- old
+ new
@@ -1,21 +1,23 @@
namespace :parallel do
+ rails_env = ENV['RAILS_ENV'] || 'test'
+
def run_in_parallel(cmd, options)
count = "-n #{options[:count]}" if options[:count]
executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
command = "#{executable} --exec '#{cmd}' #{count} #{'--non-parallel' if options[:non_parallel]}"
abort unless system(command)
end
desc "create test databases via db:create --> parallel:create[num_cpus]"
task :create, :count do |t,args|
- run_in_parallel('rake db:create RAILS_ENV=test', args)
+ run_in_parallel("rake db:create RAILS_ENV=#{rails_env}", args)
end
desc "drop test databases via db:drop --> parallel:drop[num_cpus]"
task :drop, :count do |t,args|
- run_in_parallel('rake db:drop RAILS_ENV=test', args)
+ run_in_parallel("rake db:drop RAILS_ENV=#{rails_env}", args)
end
desc "update test databases by dumping and loading --> parallel:prepare[num_cpus]"
task(:prepare, [:count] => 'db:abort_if_pending_migrations') do |t,args|
if defined?(ActiveRecord) && ActiveRecord::Base.schema_format == :ruby
@@ -30,21 +32,21 @@
end
# when dumping/resetting takes too long
desc "update test databases via db:migrate --> parallel:migrate[num_cpus]"
task :migrate, :count do |t,args|
- run_in_parallel('rake db:migrate RAILS_ENV=test', args)
+ run_in_parallel("rake db:migrate RAILS_ENV=#{rails_env}", args)
end
# just load the schema (good for integration server <-> no development db)
desc "load dumped schema for test databases via db:schema:load --> parallel:load_schema[num_cpus]"
task :load_schema, :count do |t,args|
- run_in_parallel('rake db:test:load', args)
+ run_in_parallel("rake db:schema:load RAILS_ENV=#{rails_env}", args)
end
desc "load the seed data from db/seeds.rb via db:seed --> parallel:seed[num_cpus]"
task :seed, :count do |t,args|
- run_in_parallel('rake db:seed RAILS_ENV=test', args)
+ run_in_parallel("rake db:seed RAILS_ENV=#{rails_env}", args)
end
['test', 'spec', 'features'].each do |type|
desc "run #{type} in parallel with parallel:#{type}[num_cpus]"
task type, [:count, :pattern, :options] => 'db:abort_if_pending_migrations' do |t,args|