Skip to content
This repository
Browse code

change parallel size.

  • Loading branch information...
commit 16796d7b75063871e290e5b9007847ca3dd31913 1 parent 2854fe1
authored August 01, 2012
2  .travis.yml
@@ -17,7 +17,7 @@ script:
17 17
 
18 18
 env:
19 19
  - UNIT_TEST=1      # 单元测试1
20  
- - UNIT_TEST=2      # 单元测试2
21 20
  - INTEGRATE_TEST=1 # 集成测试1
22 21
  - INTEGRATE_TEST=2 # 集成测试2
23 22
  - INTEGRATE_TEST=3 # 集成测试3
  23
+ - INTEGRATE_TEST=4 # 集成测试4
29  Rakefile
@@ -10,33 +10,4 @@ task "resque:setup" => :environment do
10 10
   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
11 11
 end
12 12
 
13  
-namespace :travis do
14  
-
15  
-  desc "Run travis in parallel"
16  
-  task :parallel do
17  
-    unit_parallel_size = 2
18  
-    integrate_parallel_size = 3
19  
-    unit_test = ENV['UNIT_TEST']
20  
-    integrate_test = ENV['INTEGRATE_TEST']
21  
-    all_files = Dir.chdir(Rails.root) { Dir["spec/**/*_spec.rb"]}.sort
22  
-    integrate_files = Dir.chdir(Rails.root) { Dir["spec/requests/**/*_spec.rb"]}.sort
23  
-    unit_files = all_files - integrate_files
24  
-    %w(shop/shops_searches_spec.rb lookup_spec.rb).each do |searchable_spec|
25  
-      integrate_files.delete "spec/requests/#{searchable_spec}" # 需要solr才能运行
26  
-    end
27  
-    files = if unit_test # 2个并发
28  
-            unit_files.in_groups(unit_parallel_size)[unit_test.to_i-1].join(' ')
29  
-          elsif integrate_test # 3个并发
30  
-            integrate_files.in_groups(integrate_parallel_size)[integrate_test.to_i-1].join(' ')
31  
-          end
32  
-
33  
-    cmd = "rspec #{files}"
34  
-    #cmd = "rspec spec/requests/shop/shop_orders_spec.rb spec/requests/shop/shop_customers_spec.rb" # selenium-webdriver 2.14未清空session,按此顺序运行,第二个用例失败
35  
-    puts "Starting to run #{cmd}..."
36  
-    system("export DISPLAY=:99.0 && bundle exec #{cmd}")
37  
-    raise "#{cmd} failed!" unless $?.exitstatus == 0
38  
-  end
39  
-
40  
-end
41  
-
42 13
 Shopqi::Application.load_tasks
28  lib/tasks/travis.rake
... ...
@@ -0,0 +1,28 @@
  1
+namespace :travis do
  2
+
  3
+  desc "Run travis in parallel"
  4
+  task :parallel do
  5
+    unit_parallel_size = 1
  6
+    integrate_parallel_size = 4
  7
+    unit_test = ENV['UNIT_TEST']
  8
+    integrate_test = ENV['INTEGRATE_TEST']
  9
+    all_files = Dir.chdir(Rails.root) { Dir["spec/**/*_spec.rb"]}.sort
  10
+    integrate_files = Dir.chdir(Rails.root) { Dir["spec/requests/**/*_spec.rb"]}.sort
  11
+    unit_files = all_files - integrate_files
  12
+    %w(shop/shops_searches_spec.rb lookup_spec.rb).each do |searchable_spec|
  13
+      integrate_files.delete "spec/requests/#{searchable_spec}" # 需要solr才能运行
  14
+    end
  15
+    files = if unit_test # 1个并发
  16
+            unit_files.in_groups(unit_parallel_size)[unit_test.to_i-1].join(' ')
  17
+          elsif integrate_test # 4个并发
  18
+            integrate_files.in_groups(integrate_parallel_size)[integrate_test.to_i-1].join(' ')
  19
+          end
  20
+
  21
+    cmd = "rspec #{files}"
  22
+    #cmd = "rspec spec/requests/shop/shop_orders_spec.rb spec/requests/shop/shop_customers_spec.rb" # selenium-webdriver 2.14未清空session,按此顺序运行,第二个用例失败
  23
+    puts "Starting to run #{cmd}..."
  24
+    system("export DISPLAY=:99.0 && bundle exec #{cmd}")
  25
+    raise "#{cmd} failed!" unless $?.exitstatus == 0
  26
+  end
  27
+
  28
+end

0 notes on commit 16796d7

Please sign in to comment.
Something went wrong with that request. Please try again.