lib/parallel_tests/tasks.rb in parallel_tests-0.4.11 vs lib/parallel_tests/tasks.rb in parallel_tests-0.4.12
- old
+ new
@@ -1,10 +1,10 @@
namespace :parallel do
def run_in_parallel(cmd, options)
count = (options[:count] ? options[:count].to_i : nil)
executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
- command = "#{executable} --exec '#{cmd}' -n #{count}"
+ command = "#{executable} --exec '#{cmd}' -n #{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|
@@ -21,12 +21,13 @@
if ActiveRecord::Base.schema_format == :ruby
# dump then load in parallel
Rake::Task['db:schema:dump'].invoke
Rake::Task['parallel:load_schema'].invoke(args[:count])
else
- # there is no separate dump / load for schema_format :sql, schema file can get corrupted
- run_in_parallel('rake db:test:prepare', args)
+ # there is no separate dump / load for schema_format :sql -> do it safe and slow
+ args = args.to_hash.merge(:non_parallel => true) # normal merge returns nil
+ run_in_parallel('rake db:test:prepare --trace', args)
end
end
# when dumping/resetting takes too long
desc "update test databases via db:mgrate --> parallel:migrate[num_cpus]"
@@ -35,10 +36,9 @@
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|
- puts args.inspect
run_in_parallel('rake db:test:load', args)
end
['test', 'spec', 'features'].each do |type|
desc "run #{type} in parallel with parallel:#{type}[num_cpus]"