Permalink
Browse files

change parallel size.

  • Loading branch information...
1 parent 2854fe1 commit 16796d7b75063871e290e5b9007847ca3dd31913 @saberma committed Aug 1, 2012
Showing with 29 additions and 30 deletions.
  1. +1 −1 .travis.yml
  2. +0 −29 Rakefile
  3. +28 −0 lib/tasks/travis.rake
View
@@ -17,7 +17,7 @@ script:
env:
- UNIT_TEST=1 # 单元测试1
- - UNIT_TEST=2 # 单元测试2
- INTEGRATE_TEST=1 # 集成测试1
- INTEGRATE_TEST=2 # 集成测试2
- INTEGRATE_TEST=3 # 集成测试3
+ - INTEGRATE_TEST=4 # 集成测试4
View
@@ -10,33 +10,4 @@ task "resque:setup" => :environment do
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } # 第二次执行resque任务时失败 PGError: ERROR: prepared statement "a3" already exists 参考 http://j.mp/rpVqhc http://j.mp/rqj9CQ ;Rails已经打了补丁,未发布版本 http://j.mp/ntPQMr
end
-namespace :travis do
-
- desc "Run travis in parallel"
- task :parallel do
- unit_parallel_size = 2
- integrate_parallel_size = 3
- unit_test = ENV['UNIT_TEST']
- integrate_test = ENV['INTEGRATE_TEST']
- all_files = Dir.chdir(Rails.root) { Dir["spec/**/*_spec.rb"]}.sort
- integrate_files = Dir.chdir(Rails.root) { Dir["spec/requests/**/*_spec.rb"]}.sort
- unit_files = all_files - integrate_files
- %w(shop/shops_searches_spec.rb lookup_spec.rb).each do |searchable_spec|
- integrate_files.delete "spec/requests/#{searchable_spec}" # 需要solr才能运行
- end
- files = if unit_test # 2个并发
- unit_files.in_groups(unit_parallel_size)[unit_test.to_i-1].join(' ')
- elsif integrate_test # 3个并发
- integrate_files.in_groups(integrate_parallel_size)[integrate_test.to_i-1].join(' ')
- end
-
- cmd = "rspec #{files}"
- #cmd = "rspec spec/requests/shop/shop_orders_spec.rb spec/requests/shop/shop_customers_spec.rb" # selenium-webdriver 2.14未清空session,按此顺序运行,第二个用例失败
- puts "Starting to run #{cmd}..."
- system("export DISPLAY=:99.0 && bundle exec #{cmd}")
- raise "#{cmd} failed!" unless $?.exitstatus == 0
- end
-
-end
-
Shopqi::Application.load_tasks
View
@@ -0,0 +1,28 @@
+namespace :travis do
+
+ desc "Run travis in parallel"
+ task :parallel do
+ unit_parallel_size = 1
+ integrate_parallel_size = 4
+ unit_test = ENV['UNIT_TEST']
+ integrate_test = ENV['INTEGRATE_TEST']
+ all_files = Dir.chdir(Rails.root) { Dir["spec/**/*_spec.rb"]}.sort
+ integrate_files = Dir.chdir(Rails.root) { Dir["spec/requests/**/*_spec.rb"]}.sort
+ unit_files = all_files - integrate_files
+ %w(shop/shops_searches_spec.rb lookup_spec.rb).each do |searchable_spec|
+ integrate_files.delete "spec/requests/#{searchable_spec}" # 需要solr才能运行
+ end
+ files = if unit_test # 1个并发
+ unit_files.in_groups(unit_parallel_size)[unit_test.to_i-1].join(' ')
+ elsif integrate_test # 4个并发
+ integrate_files.in_groups(integrate_parallel_size)[integrate_test.to_i-1].join(' ')
+ end
+
+ cmd = "rspec #{files}"
+ #cmd = "rspec spec/requests/shop/shop_orders_spec.rb spec/requests/shop/shop_customers_spec.rb" # selenium-webdriver 2.14未清空session,按此顺序运行,第二个用例失败
+ puts "Starting to run #{cmd}..."
+ system("export DISPLAY=:99.0 && bundle exec #{cmd}")
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
+ end
+
+end

0 comments on commit 16796d7

Please sign in to comment.