delta_test 1.0.3 → 1.0.4

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: a176739129c5821a3db48e783d057a02ac2e7d7f
4
- data.tar.gz: 76065c7dd622c9b4077431e5a5662a97fbb27d80
3
+ metadata.gz: d14bb0fcf07a5b5d636080569681613af4c042df
4
+ data.tar.gz: 4545cf1bb2ed91db20065b5c646697a688337adb
5
5
  SHA512:
6
- metadata.gz: 5b6a2b75604884e8c1d93929e4c4a3d179392c4df79ed581e7206e69e474553186413c49e1435bca207c905a20fe847435ed0ec2391a7bd3c954e9f7e5ba486a
7
- data.tar.gz: 7a5df579dfe7ca4a60eebdd863094e7e75cb5584f4dbb5572bd58dd23ac30f3e56246a6a42cc916db6b4b51724b750a488b224e494320f8fddbc259ffeb431b6
6
+ metadata.gz: 7f707be5d9acce380728b7ae36fe87941861360a035362c8257feb343575675f78e241d744f23b5419fe005d03f96df511f28357cfa64dc8cb89a2118b4e2203
7
+ data.tar.gz: 4e0610584cca7b8e9a2c36535c7c4b8a821281811f64d2a8cd132f1a4ab16791687237dc61548f823ac69f96d374a1614a545311922e69c0b1c2461edbad1bc7
data/README.md CHANGED
@@ -136,6 +136,12 @@ $ bundle exec delta_test exec parallel_test -t rspec -n 4 -- spec/features
136
136
  stats_path: tmp/delta_test_stats
137
137
  stats_life: 1000
138
138
 
139
+ full_test_patterns:
140
+ - Gemfile.lock
141
+
142
+ full_test_braches:
143
+ - master
144
+
139
145
  patterns:
140
146
  - lib/**/*.rb
141
147
  - app/**/*.rb
@@ -143,9 +149,6 @@ patterns:
143
149
  exclude_patterns:
144
150
  - lib/batch/*.rb
145
151
 
146
- full_test_patterns:
147
- - Gemfile.lock
148
-
149
152
  custom_mappings:
150
153
  spec/features/i18n_spec.rb:
151
154
  - config/locales/**/*.yml
@@ -53,9 +53,11 @@ module DeltaTest
53
53
 
54
54
  files
55
55
 
56
+ full_test_patterns
57
+ full_test_branches
58
+
56
59
  patterns
57
60
  exclude_patterns
58
- full_test_patterns
59
61
  custom_mappings
60
62
  ])
61
63
 
@@ -88,6 +90,14 @@ module DeltaTest
88
90
  self.files.is_a?(Array)
89
91
  end
90
92
 
93
+ validate :full_test_patterns, 'need to be an array' do
94
+ self.full_test_patterns.is_a?(Array)
95
+ end
96
+
97
+ validate :full_test_branches, 'need to be an array' do
98
+ self.full_test_branches.is_a?(Array)
99
+ end
100
+
91
101
  validate :patterns, 'need to be an array' do
92
102
  self.patterns.is_a?(Array)
93
103
  end
@@ -96,10 +106,6 @@ module DeltaTest
96
106
  self.exclude_patterns.is_a?(Array)
97
107
  end
98
108
 
99
- validate :full_test_patterns, 'need to be an array' do
100
- self.full_test_patterns.is_a?(Array)
101
- end
102
-
103
109
  validate :custom_mappings, 'need to be a hash' do
104
110
  self.custom_mappings.is_a?(Hash)
105
111
  end
@@ -116,9 +122,11 @@ module DeltaTest
116
122
 
117
123
  c.files = []
118
124
 
125
+ c.full_test_patterns = []
126
+ c.full_test_branches = []
127
+
119
128
  c.patterns = []
120
129
  c.exclude_patterns = []
121
- c.full_test_patterns = []
122
130
  c.custom_mappings = {}
123
131
  end
124
132
  end
@@ -42,6 +42,16 @@ module DeltaTest
42
42
  s.success? ? o.strip : nil
43
43
  end
44
44
 
45
+ ###
46
+ # Get name of the current branch
47
+ #
48
+ # @return {String}
49
+ ###
50
+ def current_branch
51
+ o, _, s = exec(%q{symbolic-ref --short HEAD})
52
+ s.success? ? o.strip : nil
53
+ end
54
+
45
55
  ###
46
56
  # Compare two rev names by their commit ids
47
57
  #
@@ -48,15 +48,16 @@ module DeltaTest
48
48
  ###
49
49
  def full_tests?
50
50
  return false unless @changed_files
51
+ return @full_tests if defined?(@full_tests)
51
52
 
52
- @full_tests ||= if DeltaTest.config.full_test_patterns.empty?
53
- false
54
- else
55
- Utils.files_grep(
56
- @changed_files,
57
- DeltaTest.config.full_test_patterns
58
- ).any?
59
- end
53
+ @full_tests = false
54
+ @full_tests ||= DeltaTest.config.full_test_branches.include?(@git.current_branch)
55
+ @full_tests ||= DeltaTest.config.full_test_patterns.any? && Utils.files_grep(
56
+ @changed_files,
57
+ DeltaTest.config.full_test_patterns
58
+ ).any?
59
+
60
+ @full_tests
60
61
  end
61
62
 
62
63
  ###
@@ -2,7 +2,7 @@ module DeltaTest
2
2
 
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 3
5
+ REVISION = 4
6
6
 
7
7
  VERSION = [MAJOR, MINOR, REVISION].compact.join('.')
8
8
 
@@ -117,6 +117,36 @@ describe DeltaTest::Git do
117
117
 
118
118
  end
119
119
 
120
+ describe '#current_branch' do
121
+
122
+ let(:subcommand) { ['symbolic-ref --short HEAD'] }
123
+ let(:out) { 'master' }
124
+
125
+ it 'should raise an error if the command is not exist' do
126
+ expect(git).to receive(:exec).with(*subcommand).and_call_original
127
+ allow(Open3).to receive(:capture3).and_raise
128
+
129
+ expect {
130
+ git.current_branch
131
+ }.to raise_error
132
+ end
133
+
134
+ it 'should return name of the current branch if success' do
135
+ expect(git).to receive(:exec).with(*subcommand).and_call_original
136
+ allow(Open3).to receive(:capture3).and_return(success_status)
137
+
138
+ expect(git.current_branch).to eq(out)
139
+ end
140
+
141
+ it 'should return nil if error' do
142
+ expect(git).to receive(:exec).with(*subcommand).and_call_original
143
+ allow(Open3).to receive(:capture3).and_return(error_status)
144
+
145
+ expect(git.current_branch).to be_nil
146
+ end
147
+
148
+ end
149
+
120
150
  describe '#same_commit?' do
121
151
 
122
152
  let(:map) do
@@ -36,11 +36,20 @@ describe DeltaTest::RelatedSpecList do
36
36
  ]
37
37
  end
38
38
 
39
+ let(:current_branch) { 'master' }
40
+
41
+ let(:full_test_branches) { [] }
42
+ let(:full_test_patterns) { [] }
43
+
39
44
  before do
40
45
  allow(DeltaTest::DependenciesTable).to receive(:load).with(Pathname.new(table_file_path)).and_return(table)
41
46
 
42
47
  allow(list.git).to receive(:git_repo?).and_return(true)
43
48
  allow(list.git).to receive(:changed_files).with(base_commit).and_return(changed_files)
49
+ allow(list.git).to receive(:current_branch).and_return(current_branch)
50
+
51
+ allow(DeltaTest.config).to receive(:full_test_branches).and_return(full_test_branches)
52
+ allow(DeltaTest.config).to receive(:full_test_patterns).and_return(full_test_patterns)
44
53
  end
45
54
 
46
55
  end
@@ -184,7 +193,46 @@ describe DeltaTest::RelatedSpecList do
184
193
 
185
194
  describe '#full_tests?' do
186
195
 
187
- context 'No file in full test patterns is changed' do
196
+ context 'full_test_branches is empty' do
197
+
198
+ it 'should return false' do
199
+ expect(list.full_tests?).to be(false)
200
+ end
201
+
202
+ end
203
+
204
+ context 'the current branch is in full_test_branches' do
205
+
206
+ let(:current_branch) { 'master' }
207
+ let(:full_test_branches) { ['master'] }
208
+
209
+ it 'should return true' do
210
+ expect(list.full_tests?).to be(true)
211
+ end
212
+
213
+ end
214
+
215
+ context 'the current branch is not in full_test_branches' do
216
+
217
+ let(:current_branch) { 'master' }
218
+ let(:full_test_branches) { ['other_branch'] }
219
+ let(:changed_files) { [] }
220
+
221
+ it 'should return false' do
222
+ expect(list.full_tests?).to be(false)
223
+ end
224
+
225
+ end
226
+
227
+ context 'full_test_patterns is empty' do
228
+
229
+ it 'should return false' do
230
+ expect(list.full_tests?).to be(false)
231
+ end
232
+
233
+ end
234
+
235
+ context 'no file in full_test_patterns is changed' do
188
236
 
189
237
  let(:changed_files) do
190
238
  [
@@ -198,7 +246,7 @@ describe DeltaTest::RelatedSpecList do
198
246
 
199
247
  end
200
248
 
201
- context 'No file in full test patterns is changed' do
249
+ context 'no file in full_test_patterns is changed' do
202
250
 
203
251
  let(:full_test_patterns) do
204
252
  [
@@ -212,18 +260,6 @@ describe DeltaTest::RelatedSpecList do
212
260
  ]
213
261
  end
214
262
 
215
- before do
216
- DeltaTest.configure do |config|
217
- config.full_test_patterns = full_test_patterns
218
- end
219
- end
220
-
221
- after do
222
- DeltaTest.configure do |config|
223
- config.full_test_patterns = []
224
- end
225
- end
226
-
227
263
  it 'should return true' do
228
264
  expect(list.full_tests?).to be(true)
229
265
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delta_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Iwanaga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler