semaphore_test_boosters 1.7.2 → 1.7.3

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: 57dd8bd888bd5a630d3485e7b8b9db556a37df58
4
- data.tar.gz: 4ed23a8ecf0d1bcf75fe34cf7debf021f46eb63d
3
+ metadata.gz: 55ecf357e070533847ba7fc22764a026d0ec2918
4
+ data.tar.gz: 52e0d4afb19f129f079378600b871bb0c47e9d4f
5
5
  SHA512:
6
- metadata.gz: e40d9816e4ae51156325c0d182ff0c8356176353f8cb4689ef797eee30fc9810fa19ede74a9e4f51700a13f751f467d18846e44995701a9780045004cc310c61
7
- data.tar.gz: 3a9f94e95adfd8976bebdcf4178cb90df532344a1cb2ffed0a85e19defcac26ee19825ceba75d5045267b18d7e77d1f5565534bc7d203ce8cd72a4ac26984c73
6
+ metadata.gz: ecb7d0fb08e4a94de4bc17d9adefe2b2694185666b0c16fa0b4c0fcee4483c5f2de5b484646ea8f83448a5647b38b89e074648080fba0bec43e2160630541e31
7
+ data.tar.gz: 866a3b4b308094b0f3ffb1d9593f6595ed74ba5683c191178f8738915f00fddccd21e41c30fcfa7f55955a35e0de38cead7218eb14420d5d886d9d1eb9bd3270
data/config.reek CHANGED
@@ -2,61 +2,14 @@
2
2
  IrresponsibleModule:
3
3
  enabled: false
4
4
 
5
- NestedIterators:
6
- exclude:
7
- - TestBoosters::CliParser#parse
8
- - TestBoosters::LeftoverFiles#select
9
-
10
- TooManyStatements:
11
- exclude:
12
- - initialize
13
- - TestBoosters::CliParser#parse
14
- - TestBoosters::CucumberBooster#run
15
- - TestBoosters::CucumberBooster#select
16
- - TestBoosters::CucumberBooster#with_fallback
17
- - TestBoosters::LeftoverFiles#select
18
- - TestBoosters::RspecBooster#run
19
- - TestBoosters::RspecBooster#run_command
20
- - TestBoosters::RspecBooster#select
21
- - TestBoosters::RspecBooster#with_fallback
22
-
23
- UncommunicativeVariableName:
24
- exclude:
25
- - TestBoosters::CucumberBooster#with_fallback
26
- - TestBoosters::LeftoverFiles#select
27
- - TestBoosters::LeftoverFiles#sort_descending_by_size
28
- - TestBoosters::RspecBooster#run
29
- - TestBoosters::RspecBooster#with_fallback
30
-
31
5
  FeatureEnvy:
32
6
  enabled: false
33
7
 
34
8
  ControlParameter:
35
9
  enabled: false
36
10
 
37
- NilCheck:
38
- exclude:
39
- - TestBoosters::LeftoverFiles#select
40
-
41
- UncommunicativeMethodName:
42
- exclude:
43
- - a
44
- - b
45
- - c
46
- - Setup#a
47
- - Setup#b
48
- - Setup#c
49
- - Setup::Cucumber#a
50
- - Setup::Cucumber#b
51
- - Setup::Cucumber#c
52
-
53
11
  UtilityFunction:
54
- exclude:
55
- - a
56
- - b
57
- - c
58
- - expected_specs
59
- - input_specs
12
+ enabled: false
60
13
 
61
14
  exclude_paths:
62
15
  - vendor
@@ -2,6 +2,8 @@ module TestBoosters
2
2
  module CliParser
3
3
  module_function
4
4
 
5
+ # :reek:TooManyStatements
6
+ # :reek:NestedIterators
5
7
  def parse
6
8
  options = {}
7
9
 
@@ -27,10 +27,10 @@ module TestBoosters
27
27
 
28
28
  def threads
29
29
  @threads ||= Array.new(@thread_count) do |thread_index|
30
- known_files = all_specs & split_configuration.files_for_thread(thread_index)
31
- leftover_files = TestBoosters::LeftoverFiles.select(all_leftover_specs, thread_count, thread_index)
30
+ known = all_specs & split_configuration.files_for_thread(thread_index)
31
+ leftover = leftover_specs.select(:index => thread_index, :total => thread_count)
32
32
 
33
- TestBoosters::Cucumber::Thread.new(known_files, leftover_files)
33
+ TestBoosters::Cucumber::Thread.new(known, leftover)
34
34
  end
35
35
  end
36
36
 
@@ -38,8 +38,8 @@ module TestBoosters
38
38
  @all_specs ||= Dir["#{specs_path}/**/*.feature"].sort
39
39
  end
40
40
 
41
- def all_leftover_specs
42
- @all_leftover_specs ||= all_specs - split_configuration.all_files
41
+ def leftover_specs
42
+ @leftover_specs ||= TestBoosters::LeftoverFiles.new(all_specs - split_configuration.all_files)
43
43
  end
44
44
 
45
45
  def split_configuration
@@ -1,29 +1,39 @@
1
1
  module TestBoosters
2
- module LeftoverFiles
3
- module_function
2
+ class LeftoverFiles
4
3
 
5
- def select(all_leftover_files, thread_count, thread_index)
6
- all_leftover_files = sort_descending_by_size(all_leftover_files)
4
+ attr_reader :files
7
5
 
8
- return [] if all_leftover_files.empty?
6
+ def initialize(files)
7
+ @files = files
8
+ end
9
+
10
+ def select(options = {})
11
+ index = options.fetch(:index)
12
+ total = options.fetch(:total)
13
+
14
+ file_distribution(total)[index]
15
+ end
9
16
 
10
- files = all_leftover_files
11
- .each_slice(thread_count)
12
- .reduce { |acc, slice| acc.map { |a| a }.zip(slice.reverse) }
13
- .map { |f| f.is_a?(Array) ? f.flatten : [f] } [thread_index]
17
+ private
14
18
 
15
- if files.nil? then []
16
- elsif files.is_a?(Array) then files.compact
19
+ def file_distribution(thread_count)
20
+ # create N empty boxes
21
+ threads = Array.new(thread_count) { [] }
22
+
23
+ # distribute files in Round Robin fashion
24
+ sorted_files_by_file_size.each.with_index do |file, index|
25
+ threads[index % thread_count] << file
17
26
  end
27
+
28
+ threads
29
+ end
30
+
31
+ def sorted_files_by_file_size
32
+ @sorted_files_by_file_size ||= existing_files.sort_by { |file| -File.size(file) }
18
33
  end
19
34
 
20
- def sort_descending_by_size(files)
21
- files
22
- .select { |f| File.file?(f) }
23
- .map { |f| [f, File.size(f)] }
24
- .sort_by { |a| a[1] }
25
- .map { |a| a[0] }
26
- .reverse
35
+ def existing_files
36
+ @existing_files ||= @files.select { |file| File.file?(file) }
27
37
  end
28
38
 
29
39
  end
@@ -27,10 +27,10 @@ module TestBoosters
27
27
 
28
28
  def threads
29
29
  @threads ||= Array.new(@thread_count) do |thread_index|
30
- known_files = all_specs & split_configuration.files_for_thread(thread_index)
31
- leftover_files = TestBoosters::LeftoverFiles.select(all_leftover_specs, thread_count, thread_index)
30
+ known = all_specs & split_configuration.files_for_thread(thread_index)
31
+ leftover = leftover_specs.select(:index => thread_index, :total => thread_count)
32
32
 
33
- TestBoosters::Rspec::Thread.new(known_files, leftover_files)
33
+ TestBoosters::Rspec::Thread.new(known, leftover)
34
34
  end
35
35
  end
36
36
 
@@ -38,8 +38,8 @@ module TestBoosters
38
38
  @all_specs ||= Dir["#{specs_path}/**/*_spec.rb"].sort
39
39
  end
40
40
 
41
- def all_leftover_specs
42
- @all_leftover_specs ||= all_specs - split_configuration.all_files
41
+ def leftover_specs
42
+ @leftover_specs ||= TestBoosters::LeftoverFiles.new(all_specs - split_configuration.all_files)
43
43
  end
44
44
 
45
45
  def split_configuration
@@ -1,3 +1,3 @@
1
1
  module TestBoosters
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphore_test_boosters
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Developers at Rendered Text
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2017-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semaphore_cucumber_booster_config
@@ -171,14 +171,6 @@ files:
171
171
  - lib/test_boosters/split_configuration.rb
172
172
  - lib/test_boosters/version.rb
173
173
  - test_boosters.gemspec
174
- - test_data/a.feature
175
- - test_data/a_spec.rb
176
- - test_data/b.feature
177
- - test_data/b_spec.rb
178
- - test_data/c.feature
179
- - test_data/c_spec.rb
180
- - test_data_fail/fail_spec.rb
181
- - test_data_pass/pass_spec.rb
182
174
  homepage: https://github.com/renderedtext/test-boosters
183
175
  licenses:
184
176
  - MIT
data/test_data/a.feature DELETED
@@ -1 +0,0 @@
1
- 12345678901234567890
data/test_data/a_spec.rb DELETED
@@ -1 +0,0 @@
1
- 12345678901234567890
data/test_data/b.feature DELETED
@@ -1 +0,0 @@
1
- 123
data/test_data/b_spec.rb DELETED
@@ -1 +0,0 @@
1
- 123
data/test_data/c.feature DELETED
@@ -1 +0,0 @@
1
- 123456789
data/test_data/c_spec.rb DELETED
@@ -1 +0,0 @@
1
- 123456789
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe TestBoosters::RspecBooster do
4
- it 'fails' do
5
- expect(TestBoosters::VERSION).to be "wrong"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe TestBoosters::RspecBooster do
4
- it 'passes' do
5
- expect(0).to eq(0)
6
- end
7
- end