parallel_calabash 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efbbc2a68f8afdd17130f1ca786be9471178900f
4
- data.tar.gz: 0dbf0e57b693485d8bed88144d53df1d1e06d243
3
+ metadata.gz: 4c1de47f617c12e793aa8b98f2d22bcab741cc0f
4
+ data.tar.gz: 593c627f3f37adb741ce2b9ea943c86e39c40e96
5
5
  SHA512:
6
- metadata.gz: b91350856d0c29d57e82a5103b3b53bfd8ed5517a219ad1cadf2bba34590b3b685de1f2b05ee832ae415ae0bb90b39c8b46810071a0c5f500072f684e84d8d65
7
- data.tar.gz: 1c3c11ac5b97a6672db65a6cfe3d69cdeb459a54e9187c40299e2077b75e2b0eef5c87131921c7bc575ff7f1ac6903850b2cbfc956d31c589e680348d9c08f65
6
+ metadata.gz: c1ebe0e759e48292b1588d3983fd11aeb601cde950e96f9d586d687e4876b0648db8083757ace0e40c966b2bacbfc3c5bf296d0ac95701700f63f6b67af7260e
7
+ data.tar.gz: 4317dc8ed774b7026e414ad90e73a89ea3d529201c7afdc0a780829b9a321f47d9a4941f3a08e0eafcceb69d7363314abcfcfb325e707e7b0f83ef309588f10a
data/README.md CHANGED
@@ -40,8 +40,9 @@ Example: parallel_calabash -a my.apk -o 'cucumber_opts_like_tags_profile_etc_her
40
40
  -d, --distribution-tag tag divide features into groups as per occurrence of given tag
41
41
  -o, --cucumber_opts '[OPTIONS]' execute with those cucumber options
42
42
  --serialize-stdout Serialize stdout output, nothing will be written until everything is done
43
+ --group-by-scenarios Distribute equally as per scenarios. This uses cucumber dry run
43
44
  --concurrent Run tests concurrently. Each test will run once on each device.
44
-
45
+
45
46
  ## REPROTING
46
47
 
47
48
  use ENV['TEST_PROCESS_NUMBER'] environment variable in your ruby scripts to find out the process number. you can use this for reporting purpose OR process specific action.
@@ -41,6 +41,10 @@ def parse_arguments(arguments)
41
41
  options[:concurrent] = true
42
42
  end
43
43
 
44
+ opts.on("--group-by-scenarios", "Distribute equally as per scenarios. This uses cucumber dry run") do
45
+ options[:group_by_scenarios] = true
46
+ end
47
+
44
48
  end
45
49
 
46
50
  opt_parser.parse!(arguments)
@@ -26,7 +26,7 @@ module ParallelCalabash
26
26
 
27
27
  test_results = nil
28
28
  report_time_taken do
29
- groups = FeatureGrouper.feature_groups(options[:feature_folder], number_of_processes, options[:distribution_tag], options[:concurrent])
29
+ groups = FeatureGrouper.feature_groups(options, number_of_processes)
30
30
  threads = groups.size
31
31
 
32
32
  test_results = Parallel.map_with_index(groups, :in_threads => threads) do |group, index|
@@ -1,14 +1,14 @@
1
+ require 'json'
1
2
  module ParallelCalabash
2
3
  class FeatureGrouper
3
4
 
4
5
  class << self
5
6
 
6
- def feature_groups(feature_folder, group_size,weighing_factor = nil, concurrent = nil)
7
- if concurrent.nil?
8
- weighing_factor.nil? ? feature_groups_by_feature_files(feature_folder, group_size) : feature_groups_by_weight(feature_folder, group_size,weighing_factor)
9
- else
10
- concurrent_feature_groups(feature_folder, group_size)
11
- end
7
+ def feature_groups(options, group_size)
8
+ return concurrent_feature_groups(options[:feature_folder], group_size) if options[:concurrent]
9
+ return scenario_groups group_size, options if options[:group_by_scenarios]
10
+ return feature_groups_by_weight(options[:feature_folder], group_size,options[:distribution_tag]) if options[:distribution_tag]
11
+ feature_groups_by_feature_files(options[:feature_folder], group_size)
12
12
  end
13
13
 
14
14
  def concurrent_feature_groups(feature_folder, number_of_groups)
@@ -19,6 +19,11 @@ module ParallelCalabash
19
19
 
20
20
  def feature_groups_by_feature_files(feature_folder, group_size)
21
21
  files = feature_files_in_folder feature_folder
22
+ groups = group_creator group_size,files
23
+ groups.reject(&:empty?)
24
+ end
25
+
26
+ def group_creator group_size, files
22
27
  min_number_files_per_group = files.size/group_size
23
28
  remaining_number_of_files = files.size % group_size
24
29
  groups = Array.new(group_size) { [] }
@@ -30,7 +35,19 @@ module ParallelCalabash
30
35
  group << files.delete_at(0)
31
36
  end
32
37
  end
33
- groups.reject(&:empty?)
38
+ groups
39
+ end
40
+
41
+ def scenario_groups group_size, options
42
+ generate_dry_run_report options
43
+ raise "Can not create dry run for scenario distribution" unless File.exists?("parallel_calabash_dry_run.json")
44
+ distribution_data = JSON.parse(File.read("parallel_calabash_dry_run.json"))
45
+ all_runnable_scenarios = distribution_data.map { |feature| feature["elements"].map { |scenario| "#{feature["uri"]}:#{scenario["line"]}" } }.flatten
46
+ groups = group_creator group_size,all_runnable_scenarios
47
+ end
48
+
49
+ def generate_dry_run_report options
50
+ `cucumber #{options[:cucumber_options]} -f usage --dry-run -f json --out parallel_calabash_dry_run.json #{options[:feature_folder].first}`
34
51
  end
35
52
 
36
53
  def feature_files_in_folder(feature_dir)
@@ -1,3 +1,3 @@
1
1
  module ParallelCalabash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -14,37 +14,37 @@ describe ParallelCalabash::FeatureGrouper do
14
14
  describe :feature_groups do
15
15
 
16
16
  it 'should group all features in only one group' do
17
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 1)).to eq \
17
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 1)).to eq \
18
18
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
19
19
  end
20
20
 
21
21
  it 'should divide features in 2 groups' do
22
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 2)).to eq \
22
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 2)).to eq \
23
23
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
24
24
  end
25
25
 
26
26
  it 'should divide features in 3 groups' do
27
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 3)).to eq \
27
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 3)).to eq \
28
28
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
29
29
  end
30
30
 
31
31
  it 'should divide features in 4 groups' do
32
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 4)).to eq \
32
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 4)).to eq \
33
33
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/eee.feature"], ["spec/test_data/features/bbb.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"]]
34
34
  end
35
35
 
36
36
  it 'should divide features in 5 groups' do
37
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 5)).to eq \
37
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 5)).to eq \
38
38
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature"]]
39
39
  end
40
40
 
41
41
  it 'should create 1 group for concurrent 1 process' do
42
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 1, nil, true)).to eq \
42
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 1)).to eq \
43
43
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
44
44
  end
45
45
 
46
46
  it 'should create 2 group for concurrent 2 processes' do
47
- expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 2, nil, true)).to eq \
47
+ expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 2)).to eq \
48
48
  [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"],
49
49
  ["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
50
50
  end
@@ -96,5 +96,23 @@ describe ParallelCalabash::FeatureGrouper do
96
96
  end
97
97
  end
98
98
 
99
+ describe :scenario_groups do
100
+ it 'should groups all @runnable scenario equally into 2 groups' do
101
+ expect(ParallelCalabash::FeatureGrouper.scenario_groups(2,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
102
+ [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11", "spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]]
103
+ end
104
+
105
+ it 'should groups all @runnable scenario equally into 2 groups' do
106
+ expect(ParallelCalabash::FeatureGrouper.scenario_groups(3,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
107
+ [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/ddd.feature:7"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13", "spec/test_data/features/ddd.feature:10"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"]]
108
+ end
109
+
110
+ it 'should groups all @runnable scenario equally into 2 groups' do
111
+ expect(ParallelCalabash::FeatureGrouper.scenario_groups(4,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
112
+ [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"], ["spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]]
113
+ end
114
+
115
+ end
116
+
99
117
 
100
118
  end
@@ -6,16 +6,16 @@ Feature: aaa feature
6
6
  @tag1
7
7
  Scenario:
8
8
 
9
- @tag1
9
+ @tag1 @runnable
10
10
  Scenario:
11
11
 
12
12
  @tag1
13
13
  Scenario:
14
14
 
15
- @tag1
15
+ @tag1 @runnable
16
16
  Scenario:
17
17
 
18
- @tag1
18
+ @tag1 @runnable
19
19
  Scenario:
20
20
 
21
21
  @tag1
@@ -9,10 +9,10 @@ Feature: bbb.feature
9
9
  @tag12
10
10
  Scenario:
11
11
 
12
- @tag1
12
+ @tag1 @runnable
13
13
  Scenario:
14
14
 
15
- @tag1
15
+ @tag1 @runnable
16
16
  Scenario:
17
17
 
18
18
  @tag1
@@ -7,7 +7,7 @@ Feature: ccc.feature
7
7
  @tag1
8
8
  Scenario:
9
9
 
10
- @tag1
10
+ @tag1 @runnable
11
11
  Scenario:
12
12
 
13
13
  @tag1
@@ -3,8 +3,8 @@ Feature: ddd.feature
3
3
  @tag1
4
4
  Scenario:
5
5
 
6
- @tag1
6
+ @tag1 @runnable
7
7
  Scenario:
8
8
 
9
- @tag1
9
+ @tag1 @runnable
10
10
  Scenario:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_calabash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajdeep
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler