parallel_calabash 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e707fea978908c069d5ee8b7ed755c61b923f15
4
- data.tar.gz: 78ae4ba1f33793908c81fa7e64d1d07fe4fef9a0
3
+ metadata.gz: c5e86fb602e2958bb44e857ec0cb81c1755904e1
4
+ data.tar.gz: 79a70e5354ac574d03691b929e8025d1c8e0106a
5
5
  SHA512:
6
- metadata.gz: aba39d6219d67792d46963955bf44760de1f44192c8542c82d9d182b13bcc0fed255fe5fd673a6c735613632bac6ead9fc4aa06da1119e7f19760a569f28f130
7
- data.tar.gz: 2fd7b19d29b811ca11c89a005009771cc8508e4d52e27dffdd70111832808ba125c95b8a831e9084d88edf09dbb1fcaa3b9b3d203ef3bec7c1827ad3f28518d5
6
+ metadata.gz: d26a69315b401ecc609ab9c8a3a934754276f1fb037b7d711da7ac5e165e7f809d533b71708879f6ae5b60de31c10973a37a000c0ced03ccc13d1ab82a1c65ea
7
+ data.tar.gz: 24bf3870f338d3a75664d33da1e607a5f08cc53642159956b54142a8ae335a48f8442b5c524fd27228617c49f6ba7e1562327647a4233745a9a8c440948ecd18
data/README.md CHANGED
@@ -36,10 +36,23 @@ Example: parallel_calabash -a my.apk -o 'cucumber_opts_like_tags_profile_etc_her
36
36
  -v, --version Show version
37
37
  -a, --apk apk_path apk file path
38
38
  -o, --cucumber_opts '[OPTIONS]' execute with those cucumber options
39
+ -f, --filter Filter devices to run tests against using partial device id or model name matching. Multiple filters seperated by ','
39
40
  --serialize-stdout Serialize stdout output, nothing will be written until everything is done
40
41
  --group-by-scenarios Distribute equally as per scenarios. This uses cucumber dry run
41
42
  --concurrent Run tests concurrently. Each test will run once on each device.
42
43
 
44
+
45
+ ## FILTERING
46
+ Filters are partial matches on the device id, or model name.
47
+ > adb devices -l
48
+ List of devices attached
49
+ 4100142545f271b5 device usb:14200000 product:sltexx model:SM_G850F device:slte
50
+ 4366432135f271c6 device usb:14200000 product:sltexx model:SM_G9901 device:slte
51
+ emulator-5554 device product:sdk_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64
52
+
53
+ To run against just the emulator: -f emulator
54
+ To run against a device id list: -f 4100142545f271b5,4366432135f271c6
55
+
43
56
  ## REPROTING
44
57
 
45
58
  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.
@@ -29,6 +29,10 @@ def parse_arguments(arguments)
29
29
  options[:distribution_tag] = distribution_tag
30
30
  end
31
31
 
32
+ opts.on("-f", "--filter filter", "Filter devices to run tests against using partial device id or model name matching. Multiple filters seperated by ','") do |filter_opts|
33
+ options[:filter] = filter_opts.split(",")
34
+ end
35
+
32
36
  opts.on("-o", "--cucumber_opts '[OPTIONS]'", "execute with those cucumber options") do |cucumber_opts|
33
37
  options[:cucumber_options] = cucumber_opts
34
38
  end
@@ -12,8 +12,8 @@ module ParallelCalabash
12
12
  WINDOWS = (RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
13
13
  class << self
14
14
 
15
- def number_of_processes_to_start
16
- number_of_processes = AdbHelper.number_of_connected_devices
15
+ def number_of_processes_to_start options
16
+ number_of_processes = AdbHelper.number_of_connected_devices(options[:filter])
17
17
  raise "\n**** NO DEVICE FOUND ****\n" if number_of_processes==0
18
18
  puts "*******************************"
19
19
  puts " #{number_of_processes} DEVICES FOUND"
@@ -22,7 +22,7 @@ module ParallelCalabash
22
22
  end
23
23
 
24
24
  def run_tests_in_parallel(options)
25
- number_of_processes = number_of_processes_to_start
25
+ number_of_processes = number_of_processes_to_start(options)
26
26
 
27
27
  test_results = nil
28
28
  report_time_taken do
@@ -2,17 +2,22 @@ module ParallelCalabash
2
2
  module AdbHelper
3
3
  class << self
4
4
 
5
- def device_for_process process_num
6
- connected_devices_with_model_info[process_num]
5
+ def device_for_process process_num, filter=[]
6
+ connected_devices_with_model_info(filter)[process_num]
7
7
  end
8
8
 
9
- def number_of_connected_devices
10
- connected_devices_with_model_info.size
9
+ def number_of_connected_devices filter=[]
10
+ connected_devices_with_model_info(filter).size
11
11
  end
12
12
 
13
- def connected_devices_with_model_info
13
+ def connected_devices_with_model_info filter
14
14
  begin
15
- `adb devices -l`.split("\n").collect{|line| device_id_and_model(line)}.compact
15
+ list =
16
+ `adb devices -l`.split("\n").collect do |line|
17
+ device = device_id_and_model(line)
18
+ filter_device(device, filter)
19
+ end
20
+ list.compact
16
21
  rescue
17
22
  []
18
23
  end
@@ -24,6 +29,14 @@ module ParallelCalabash
24
29
  end
25
30
  end
26
31
 
32
+ def filter_device device, filter
33
+ if filter && !filter.empty? && device
34
+ device unless filter.collect{|f| device[0].match(f) || device[1].match(f) }.compact.empty?
35
+ else
36
+ device
37
+ end
38
+ end
39
+
27
40
  end
28
41
 
29
42
  end
@@ -66,6 +66,9 @@ module ParallelCalabash
66
66
  if File.directory?(feature_dir.first)
67
67
  files = Dir[File.join(feature_dir, "**{,/*/**}/*")].uniq
68
68
  files.grep(/\.feature$/)
69
+ elsif File.file?(feature_dir.first)
70
+ scenarios = File.open(feature_dir.first).collect{ |line| line.split(' ') }
71
+ scenarios.flatten
69
72
  end
70
73
  end
71
74
 
@@ -105,4 +108,4 @@ module ParallelCalabash
105
108
  end
106
109
 
107
110
  end
108
- end
111
+ end
@@ -7,11 +7,11 @@ module ParallelCalabash
7
7
 
8
8
  def run_tests(test_files, process_number, options)
9
9
  cmd = [base_command, options[:apk_path], options[:cucumber_options], *test_files].compact*' '
10
- execute_command_for_process(process_number, cmd, options[:mute_output])
10
+ execute_command_for_process(process_number, cmd, options[:mute_output], options[:filter])
11
11
  end
12
12
 
13
- def execute_command_for_process(process_number, cmd, silence)
14
- command_for_current_process = command_for_process(process_number, cmd)
13
+ def execute_command_for_process(process_number, cmd, silence, filter)
14
+ command_for_current_process = command_for_process(process_number, cmd, filter)
15
15
  output = open("|#{command_for_current_process}", "r") { |output| show_output(output, silence) }
16
16
  exitstatus = $?.exitstatus
17
17
 
@@ -23,9 +23,9 @@ module ParallelCalabash
23
23
  {:stdout => output, :exit_status => exitstatus}
24
24
  end
25
25
 
26
- def command_for_process process_number, cmd
26
+ def command_for_process(process_number, cmd, filter)
27
27
  env = {}
28
- device_id, device_info = ParallelCalabash::AdbHelper.device_for_process process_number
28
+ device_id, device_info = ParallelCalabash::AdbHelper.device_for_process process_number, filter
29
29
  env = env.merge({'AUTOTEST' => '1', 'ADB_DEVICE_ARG' => device_id, 'DEVICE_INFO' => device_info, "TEST_PROCESS_NUMBER" => (process_number+1).to_s})
30
30
  separator = (WINDOWS ? ' & ' : ';')
31
31
  exports = env.map { |k, v| WINDOWS ? "(SET \"#{k}=#{v}\")" : "#{k}=#{v};export #{k}" }.join(separator)
@@ -1,3 +1,3 @@
1
1
  module ParallelCalabash
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -9,7 +9,7 @@ describe ParallelCalabash::AdbHelper do
9
9
  end
10
10
 
11
11
  it 'should match devices if there is a space after the word device' do
12
- expect(ParallelCalabash::AdbHelper.device_id_and_model("emulator-5554 device ")).to eq \
12
+ expect(ParallelCalabash::AdbHelper.device_id_and_model("emulator-5554 device ")).to eq \
13
13
  ["emulator-5554", nil]
14
14
  end
15
15
 
@@ -27,4 +27,27 @@ describe ParallelCalabash::AdbHelper do
27
27
  expect(ParallelCalabash::AdbHelper.device_id_and_model(output)).to eq ["192.168.56.101:5555", "device1"]
28
28
  end
29
29
  end
30
+
31
+ describe :filter_device do
32
+ it 'should return devices if no filter is specified' do
33
+ device = ["192.168.56.101:5555", "device1"]
34
+ expect(ParallelCalabash::AdbHelper.filter_device(device, [])).to eq device
35
+ end
36
+
37
+ it 'should match devices that match the filter' do
38
+ device = ["192.168.56.101:5555", "device1"]
39
+ expect(ParallelCalabash::AdbHelper.filter_device(device, ["device1"])).to eq device
40
+ end
41
+
42
+ it 'should not return devices that do not match the filter' do
43
+ device = ["192.168.56.101:5555", "device1"]
44
+ expect(ParallelCalabash::AdbHelper.filter_device(device, ["notmatching"])).to eq nil
45
+ end
46
+
47
+ it 'can also match on ip address' do
48
+ device = ["192.168.56.101:5555", "device1"]
49
+ expect(ParallelCalabash::AdbHelper.filter_device(device, ["192.168.56.101"])).to eq device
50
+ end
51
+ end
52
+
30
53
  end
@@ -9,6 +9,11 @@ describe ParallelCalabash::FeatureGrouper do
9
9
  expect(ParallelCalabash::FeatureGrouper.feature_files_in_folder ['spec/test_data/features']).to eq \
10
10
  ["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"]
11
11
  end
12
+
13
+ it 'should find all the feature files in a rerun text file' do
14
+ expect(ParallelCalabash::FeatureGrouper.feature_files_in_folder ['spec/test_data/rerun.txt']).to eq \
15
+ ["features/aaa.feature:3", "features/aaa.feature:6", "features/aaa.feature:9", "features/bbb.feature:3", "features/bbb.feature:6", "features/bbb.feature:9"]
16
+ end
12
17
  end
13
18
 
14
19
  describe :feature_groups do
@@ -115,4 +120,4 @@ describe ParallelCalabash::FeatureGrouper do
115
120
  end
116
121
 
117
122
 
118
- end
123
+ end
@@ -4,8 +4,8 @@ require 'parallel_calabash'
4
4
  describe ParallelCalabash::Runner do
5
5
  describe :command_for_process do
6
6
  it 'should return command with env variables' do
7
- ParallelCalabash::AdbHelper.should_receive(:device_for_process).with(0).and_return(["4d00fa3cb814c03f", "GT_N7100"])
8
- expect(ParallelCalabash::Runner.command_for_process(0, 'base_command')).to eq \
7
+ ParallelCalabash::AdbHelper.should_receive(:device_for_process).with(0,nil).and_return(["4d00fa3cb814c03f", "GT_N7100"])
8
+ expect(ParallelCalabash::Runner.command_for_process(0, 'base_command', nil)).to eq \
9
9
  "AUTOTEST=1;export AUTOTEST;ADB_DEVICE_ARG=4d00fa3cb814c03f;export ADB_DEVICE_ARG;DEVICE_INFO=GT_N7100;export DEVICE_INFO;TEST_PROCESS_NUMBER=1;export TEST_PROCESS_NUMBER;base_command"
10
10
  end
11
11
  end
@@ -13,12 +13,12 @@ describe ParallelCalabash::Runner do
13
13
 
14
14
  describe :execute_command_for_process do
15
15
  it 'should execute the command with correct env variables set and return exit status 0 when command gets executed successfully' do
16
- ParallelCalabash::AdbHelper.should_receive(:device_for_process).with(3).and_return("DEVICE3")
17
- expect(ParallelCalabash::Runner.execute_command_for_process(3,'echo $ADB_DEVICE_ARG;echo $TEST_PROCESS_NUMBER',true)).to eq ({:stdout=>"DEVICE3\n4\n", :exit_status=>0})
16
+ ParallelCalabash::AdbHelper.should_receive(:device_for_process).with(3,nil).and_return("DEVICE3")
17
+ expect(ParallelCalabash::Runner.execute_command_for_process(3,'echo $ADB_DEVICE_ARG;echo $TEST_PROCESS_NUMBER',true,nil)).to eq ({:stdout=>"DEVICE3\n4\n", :exit_status=>0})
18
18
  end
19
19
 
20
20
  it 'should return exit status of 1' do
21
- expect(ParallelCalabash::Runner.execute_command_for_process(3,"ruby -e 'exit(1)'",true)).to eq ({:stdout=>"", :exit_status=>1})
21
+ expect(ParallelCalabash::Runner.execute_command_for_process(3,"ruby -e 'exit(1)'",true,nil)).to eq ({:stdout=>"", :exit_status=>1})
22
22
  end
23
23
  end
24
24
 
@@ -0,0 +1 @@
1
+ features/aaa.feature:3 features/aaa.feature:6 features/aaa.feature:9 features/bbb.feature:3 features/bbb.feature:6 features/bbb.feature:9
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajdeep
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - spec/test_data/features/ddd.feature
87
87
  - spec/test_data/features/eee.feature
88
88
  - spec/test_data/features/fff.feature
89
+ - spec/test_data/rerun.txt
89
90
  homepage: https://github.com/rajdeepv/parallel_calabash
90
91
  licenses:
91
92
  - MIT
@@ -121,3 +122,4 @@ test_files:
121
122
  - spec/test_data/features/ddd.feature
122
123
  - spec/test_data/features/eee.feature
123
124
  - spec/test_data/features/fff.feature
125
+ - spec/test_data/rerun.txt