lib/parallel_tests/tasks.rb in parallel_tests-3.9.1 vs lib/parallel_tests/tasks.rb in parallel_tests-3.10.0

- old
+ new

@@ -7,18 +7,10 @@ class << self def rails_env 'test' end - def rake_bin - # Prevent 'Exec format error' Errno::ENOEXEC on Windows - return "rake" if RUBY_PLATFORM =~ /mswin|mingw|cygwin/ - binstub_path = File.join('bin', 'rake') - return binstub_path if File.exist?(binstub_path) - "rake" - end - def load_lib $LOAD_PATH << File.expand_path('..', __dir__) require "parallel_tests" end @@ -124,27 +116,27 @@ end namespace :parallel do desc "Setup test databases via db:setup --> parallel:setup[num_cpus]" task :setup, :count do |_, args| - command = [ParallelTests::Tasks.rake_bin, "db:setup", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"] + command = [$0, "db:setup", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"] ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args) end desc "Create test databases via db:create --> parallel:create[num_cpus]" task :create, :count do |_, args| ParallelTests::Tasks.run_in_parallel( - [ParallelTests::Tasks.rake_bin, "db:create", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], + [$0, "db:create", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], args ) end desc "Drop test databases via db:drop --> parallel:drop[num_cpus]" task :drop, :count do |_, args| ParallelTests::Tasks.run_in_parallel( [ - ParallelTests::Tasks.rake_bin, + $0, "db:drop", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}", "DISABLE_DATABASE_ENVIRONMENT_CHECK=1" ], args @@ -167,37 +159,37 @@ Rake::Task["parallel:load_#{type}"].invoke(args[:count]) else # slow: dump and load in in serial args = args.to_hash.merge(non_parallel: true) # normal merge returns nil task_name = Rake::Task.task_defined?('db:test:prepare') ? 'db:test:prepare' : 'app:db:test:prepare' - ParallelTests::Tasks.run_in_parallel([ParallelTests::Tasks.rake_bin, task_name], args) + ParallelTests::Tasks.run_in_parallel([$0, task_name], args) next end end # when dumping/resetting takes too long desc "Update test databases via db:migrate --> parallel:migrate[num_cpus]" task :migrate, :count do |_, args| ParallelTests::Tasks.run_in_parallel( - [ParallelTests::Tasks.rake_bin, "db:migrate", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], + [$0, "db:migrate", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], args ) end desc "Rollback test databases via db:rollback --> parallel:rollback[num_cpus]" task :rollback, :count do |_, args| ParallelTests::Tasks.run_in_parallel( - [ParallelTests::Tasks.rake_bin, "db:rollback", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], + [$0, "db:rollback", "RAILS_ENV=#{ParallelTests::Tasks.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 |_, args| command = [ - ParallelTests::Tasks.rake_bin, + $0, ParallelTests::Tasks.purge_before_load, "db:schema:load", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}", "DISABLE_DATABASE_ENVIRONMENT_CHECK=1" ] @@ -208,11 +200,11 @@ # (faster for rails < 6.1, deprecated after and only configured by `ActiveRecord::Base.schema_format`) desc "Load structure for test databases via db:schema:load --> parallel:load_structure[num_cpus]" task :load_structure, :count do |_, args| ParallelTests::Tasks.run_in_parallel( [ - ParallelTests::Tasks.rake_bin, + $0, ParallelTests::Tasks.purge_before_load, "db:structure:load", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}", "DISABLE_DATABASE_ENVIRONMENT_CHECK=1" ], @@ -222,21 +214,21 @@ desc "Load the seed data from db/seeds.rb via db:seed --> parallel:seed[num_cpus]" task :seed, :count do |_, args| ParallelTests::Tasks.run_in_parallel( [ - ParallelTests::Tasks.rake_bin, + $0, "db:seed", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}" ], args ) end desc "Launch given rake command in parallel" task :rake, :command, :count do |_, args| ParallelTests::Tasks.run_in_parallel( - [ParallelTests::Tasks.rake_bin, args.command, "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], + [$0, args.command, "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"], args ) end ['test', 'spec', 'features', 'features-spinach'].each do |type|