spec_tiller 1.2.0 → 1.2.1
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 +4 -4
- data/lib/spec_tiller/build_matrix_parser.rb +7 -3
- data/lib/spec_tiller/sync_spec_file_list.rb +10 -5
- data/lib/spec_tiller/version.rb +1 -1
- data/spec/sync_spec_file_list_spec.rb +56 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13beb7e2c37b837223f232fc52c9e566dfe33801
|
4
|
+
data.tar.gz: f19fd50a68c23b32c436993f24b130e5ae8b7123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f349be26ef856b2f6b2739acec9ae4dd90defbdad2721fc18ac8a21904a9b66161e654464e6a4a799bc5b6e2ef97ffafa57e9424c9805640f5a0541c8c71a3
|
7
|
+
data.tar.gz: e02dead8672b5bcdb107e1c61061d9619d70f1afa52c64dd9feee6cd86e74771cfc482c38b7cebc76d5daf9aa3350d19f900362a802f07e7a891a12392c3d471
|
@@ -17,8 +17,8 @@ module BuildMatrixParser
|
|
17
17
|
content_env_matrix = []
|
18
18
|
|
19
19
|
env_matrix.each do |var_hash|
|
20
|
-
next if
|
21
|
-
line = var_hash.map { |key, value| %
|
20
|
+
next if nil_or_empty?(var_hash)
|
21
|
+
line = var_hash.map { |key, value| %(#{key}="#{value}") }.join(' ')
|
22
22
|
|
23
23
|
content_env_matrix << line
|
24
24
|
end
|
@@ -27,4 +27,8 @@ module BuildMatrixParser
|
|
27
27
|
end
|
28
28
|
module_function :format_matrix
|
29
29
|
|
30
|
-
|
30
|
+
def self.nil_or_empty?(var_hash)
|
31
|
+
return true if var_hash.empty? || var_hash['TEST_SUITE'].nil?
|
32
|
+
var_hash['TEST_SUITE'].empty?
|
33
|
+
end
|
34
|
+
end
|
@@ -4,13 +4,15 @@ module SyncSpecFiles
|
|
4
4
|
include BuildMatrixParser
|
5
5
|
|
6
6
|
def rewrite_travis_content(content, current_file_list, &block)
|
7
|
+
num_buckets = content['num_builds']
|
8
|
+
|
7
9
|
ignore_specs = get_ignored_specs(content)
|
8
10
|
current_file_list = current_file_list.reject { |file_path| ignore_specs.include?(file_path) }
|
9
11
|
env_matrix = BuildMatrixParser.parse_env_matrix(content)
|
10
12
|
original = extract_spec_files(env_matrix)
|
11
13
|
after_removed = delete_removed_files(original, current_file_list)
|
12
|
-
after_added = add_new_files(original, after_removed, current_file_list)
|
13
|
-
|
14
|
+
after_added = add_new_files(original, after_removed, current_file_list, num_buckets)
|
15
|
+
|
14
16
|
env_matrix.each do |var_hash|
|
15
17
|
if var_hash.has_key?('TEST_SUITE')
|
16
18
|
test_bucket = after_added.shift
|
@@ -70,9 +72,12 @@ module SyncSpecFiles
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
def self.add_new_files(original, buckets, current_file_list)
|
75
|
+
def self.add_new_files(original, buckets, current_file_list, num_buckets)
|
74
76
|
buckets_clone = buckets.map(&:dup)
|
75
|
-
|
77
|
+
test_suite_worker_count = buckets_clone.length
|
78
|
+
|
79
|
+
# This check is to determine if the stated bucket count is > available workers
|
80
|
+
num_buckets = test_suite_worker_count < num_buckets ? test_suite_worker_count : num_buckets
|
76
81
|
|
77
82
|
added_files(original, current_file_list).each do |spec_file|
|
78
83
|
bucket_index = rand(num_buckets)
|
@@ -99,4 +104,4 @@ module SyncSpecFiles
|
|
99
104
|
|
100
105
|
" Removed: #{removed}\n Added: #{added}\n\n"
|
101
106
|
end
|
102
|
-
end
|
107
|
+
end
|
data/lib/spec_tiller/version.rb
CHANGED
@@ -14,34 +14,71 @@ describe 'SyncSpecFiles' do
|
|
14
14
|
end
|
15
15
|
let(:travis_yaml) { YAML::load(File.open('spec/documents/.travis.yml')) }
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it 'adds new files to random line' do
|
22
|
-
expect(travis_yaml['env']['matrix'].join(' ')).to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
23
|
-
end
|
17
|
+
describe 'Static Yaml' do
|
18
|
+
before(:each) do
|
19
|
+
SyncSpecFiles.rewrite_travis_content(travis_yaml, current_file_list)
|
20
|
+
end
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
expect(bucket).not_to include('spec/features/three_vars.rb')
|
22
|
+
it 'adds new files to random line' do
|
23
|
+
expect(travis_yaml['env']['matrix'].join(' ')).to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
28
24
|
end
|
29
25
|
|
30
|
-
|
26
|
+
it 'removes unused specs' do
|
27
|
+
travis_yaml['env']['matrix'].each do |bucket|
|
28
|
+
expect(bucket).not_to include('spec/features/three_vars.rb')
|
29
|
+
end
|
31
30
|
|
32
|
-
it 'removes lines without a TEST_SUITE' do
|
33
|
-
travis_yaml['env']['matrix'].each do |bucket|
|
34
|
-
expect(bucket).to include('TEST_SUITE="')
|
35
31
|
end
|
36
|
-
end
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
it 'removes lines without a TEST_SUITE' do
|
34
|
+
travis_yaml['env']['matrix'].each do |bucket|
|
35
|
+
expect(bucket).to include('TEST_SUITE="')
|
36
|
+
end
|
41
37
|
end
|
42
38
|
|
39
|
+
it 'does not include ignored specs' do
|
40
|
+
travis_yaml['env']['matrix'].each do |bucket|
|
41
|
+
expect(bucket).not_to include('spec/features/ignore_me.rb')
|
42
|
+
end
|
43
|
+
end
|
43
44
|
end
|
44
45
|
|
46
|
+
describe 'Modified Yaml' do
|
47
|
+
describe 'Respects num_builds in syncing files' do
|
48
|
+
it 'when num_builds: 1, adds files to only the first two lines of the matrix' do
|
49
|
+
travis_yaml['num_builds'] = 1
|
50
|
+
SyncSpecFiles.rewrite_travis_content(travis_yaml, current_file_list) do |yaml|
|
51
|
+
matrix = yaml['env']['matrix']
|
52
|
+
first_bucket = matrix.first
|
53
|
+
rest_buckets = matrix[1..-1].join(' ')
|
54
|
+
|
55
|
+
expect(first_bucket).to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
56
|
+
expect(rest_buckets).not_to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'when num_builds: 2, adds files to only the first 2 lines of the matrix' do
|
61
|
+
travis_yaml['num_builds'] = 2
|
62
|
+
SyncSpecFiles.rewrite_travis_content(travis_yaml, current_file_list) do |yaml|
|
63
|
+
matrix = yaml['env']['matrix']
|
64
|
+
first_two_buckets = matrix[0..1].join(' ')
|
65
|
+
rest_buckets = matrix[2..-1].join(' ')
|
66
|
+
|
67
|
+
expect(first_two_buckets).to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
68
|
+
expect(rest_buckets).not_to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'when num_builds > current bucket count it uses current bucket count' do
|
73
|
+
travis_yaml['num_builds'] = 100
|
74
|
+
SyncSpecFiles.rewrite_travis_content(travis_yaml, current_file_list) do |yaml|
|
75
|
+
matrix = yaml['env']['matrix']
|
76
|
+
buckets = matrix.join(' ')
|
77
|
+
expect(buckets).to include('spec/test/new1.rb','spec/test2/new2.rb','spec/test/new3.rb')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
45
82
|
end
|
46
83
|
|
47
|
-
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spec_tiller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Schmaus
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|