albacore 2.5.14 → 2.6.0

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: 5504fa88181023236c6e51b93d975ef953f36ae8
4
- data.tar.gz: e019e93bb5c942f574d41679ac57164599eb6c04
3
+ metadata.gz: fca7e93d7733d7e5bf335e38ef80e88591d7f2ab
4
+ data.tar.gz: 6e7eb09131e0bd1f2633ba1e9d6791d20467bf8c
5
5
  SHA512:
6
- metadata.gz: 138d9e0ab76538cfe63613b21f53f77f6321a8a5afcc0c4ecc994c899a547c63f4053b79acdb4ad1dd879d10f8a5a4c15990d86e760cb78ba8f50b26823e4497
7
- data.tar.gz: 7d878c75fd44c9881716a06cfa910a134df35920ffe9b04f721e571439e5ee409c3798988e226a81ab255f793fd84132da4f91f7bfeccbbc1248db2db1f7f387
6
+ metadata.gz: 675c67991bf94a14ff29b67d3404d01b38869b488a9129739dd0cef8da00bab5a40842841757355837bff31b5a26d952f0c8a3abd2b906945bbf59d6dff7b918
7
+ data.tar.gz: d44ae46744d7c752a2b69fec2c3d013c43545a21a64cccb568a610060e9026a4fe6181b7fb9dbfe7f0ede2ecfc2a2877c759c30d7f3f33740e9ade4b05a302db
@@ -77,7 +77,7 @@ module Albacore
77
77
  # target database that do not exist in the database project, and that will
78
78
  # cause errors when you publish.
79
79
  def verify_deployment
80
- @parameters.add "/p:VerifyDeployment:True"
80
+ @parameters.add "/p:VerifyDeployment=True"
81
81
  end
82
82
 
83
83
  # Specifies whether detailed feedback is suppressed. Defaults to False.
@@ -26,6 +26,7 @@ module Albacore
26
26
  @copy_local = false
27
27
  @is_ms_test = false
28
28
  @clr_command = true
29
+ @execute_as_batch = false
29
30
  @files = []
30
31
  end
31
32
 
@@ -38,7 +39,8 @@ module Albacore
38
39
  :is_ms_test => @is_ms_test,
39
40
  :exe => @exe,
40
41
  :parameters => @parameters,
41
- :clr_command => @clr_command)
42
+ :clr_command => @clr_command,
43
+ :execute_as_batch => @execute_as_batch)
42
44
  end
43
45
 
44
46
  attr_path_accessor :settings do |s|
@@ -63,6 +65,11 @@ module Albacore
63
65
  @is_ms_test = true
64
66
  end
65
67
 
68
+ # Will cause the executable to be run only once, testing all files as a batch.
69
+ def execute_as_batch
70
+ @execute_as_batch = true
71
+ end
72
+
66
73
  private
67
74
  def files
68
75
  if @files.respond_to? :each
@@ -78,9 +85,14 @@ module Albacore
78
85
 
79
86
  # expects both parameters and executable to be relative to the
80
87
  # work_dir parameter
81
- def initialize work_dir, executable, parameters, file, clr_command = true
88
+ def initialize work_dir, executable, parameters, files, clr_command = true
82
89
  @work_dir, @executable = work_dir, executable
83
- @parameters = parameters.to_a.unshift(file)
90
+ if files.respond_to? :each
91
+ @parameters = files.to_a.concat(parameters.to_a)
92
+ else
93
+ @parameters = parameters.to_a.unshift(files)
94
+ end
95
+
84
96
  @clr_command = clr_command
85
97
  end
86
98
 
@@ -103,28 +115,52 @@ module Albacore
103
115
  def execute
104
116
  raise ArgumentError, 'missing :exe' unless @opts.get :exe
105
117
  raise ArgumentError, 'missing :files' unless @opts.get :files
118
+ raise ArgumentError, 'cannot specify both execute_as_batch and is_ms_test' if @opts.get :execute_as_batch and @opts.get :is_ms_test
119
+ raise ArgumentError, 'cannot specify both execute_as_batch and is_ms_test' if @opts.get :execute_as_batch and @opts.get :copy_local
120
+
106
121
  @opts.get(:files).each do |dll|
107
122
  raise ArgumentError, "could not find test dll '#{dll}' in dir #{FileUtils.pwd}" unless File.exists? dll
108
- execute_tests_for dll
109
123
  end
124
+
125
+ commands = []
126
+ if @opts.get(:execute_as_batch)
127
+ commands = build_command_for_all_dlls
128
+ else
129
+ commands = @opts.get(:files).map { |dll| build_command_for dll }
130
+ end
131
+
132
+ execute_commands commands
110
133
  end
111
134
 
112
135
  private
113
- def execute_tests_for dll
136
+ def execute_commands commands
137
+ commands.each { |command| command.execute }
138
+ end
139
+
140
+ def build_command_for dll
114
141
  handle_directory dll, @opts.get(:exe) do |dir, exe|
115
142
  filename = File.basename dll
116
143
 
117
144
  if @opts.get(:is_ms_test)
118
145
  filename = "/testcontainer:#{filename}"
119
146
  end
120
- cmd = Albacore::TestRunner::Cmd.new dir,
121
- exe,
122
- @opts.get(:parameters, []),
123
- filename,
124
- @opts.get(:clr_command)
125
- cmd.execute
147
+ Albacore::TestRunner::Cmd.new dir,
148
+ exe,
149
+ @opts.get(:parameters, []),
150
+ [filename],
151
+ @opts.get(:clr_command)
126
152
  end
127
153
  end
154
+
155
+ def build_command_for_all_dlls
156
+ command = Albacore::TestRunner::Cmd.new '.',
157
+ @opts.get(:exe),
158
+ @opts.get(:parameters, []),
159
+ @opts.get(:files),
160
+ @opts.get(:clr_command)
161
+ [command]
162
+ end
163
+
128
164
  def handle_directory dll, exe, &block
129
165
  if @opts.get(:copy_local)
130
166
  # TODO: #mktmpdir is not always reliable; consider contributing a patch to ruby?
@@ -1,3 +1,3 @@
1
1
  module Albacore
2
- VERSION = "2.5.14"
2
+ VERSION = "2.6.0"
3
3
  end
@@ -76,9 +76,9 @@ describe 'when running with sql' do
76
76
  expect(subject.executable).to eq('SqlPackage')
77
77
  end
78
78
  it do
79
- expect(subject.parameters).to eq(%W|/Action:Publish /SourceFile:testdata/test.dacpac /Profile:testdata/test.publish /p:VerifyDeployment:True /Quiet:True|)
79
+ expect(subject.parameters).to eq(%W|/Action:Publish /SourceFile:testdata/test.dacpac /Profile:testdata/test.publish /p:VerifyDeployment=True /Quiet:True|)
80
80
  end
81
81
  it do
82
82
  expect(subject.is_mono_command?).to be false
83
83
  end
84
- end
84
+ end
@@ -21,7 +21,11 @@ describe ::Albacore::TestRunner::Config do
21
21
  it do
22
22
  should respond_to :native_exe
23
23
  end
24
+ it do
25
+ should respond_to :execute_as_batch
26
+ end
24
27
  end
28
+
25
29
  describe ::Albacore::TestRunner::Config do
26
30
  subject do
27
31
  ::Albacore::TestRunner::Config.new
@@ -35,7 +39,7 @@ describe ::Albacore::TestRunner::Config do
35
39
  it 'should have the appropriate parameter in #opts.get(:parameters)' do
36
40
  expect(subject.opts.get(:parameters)).to include('/TestResults=/b/c/d/e.xml')
37
41
  end
38
-
42
+
39
43
  it 'should have clr_command=false' do
40
44
  expect(subject.opts.get(:clr_command)).to be false
41
45
  end
@@ -82,46 +86,255 @@ describe ::Albacore::TestRunner::Cmd do
82
86
  end
83
87
  end
84
88
 
89
+ describe ::Albacore::TestRunner::Task, 'when configured improperly' do
90
+ context 'is_ms_test and execute_as_batch both specified' do
91
+ it 'should raise ArgumentError' do
92
+ config = ::Albacore::TestRunner::Config.new
93
+ config.exe = 'test-runner.exe'
94
+ config.files = 'Rakefile' # not a real DLL, but we need something that exists
95
+ config.is_ms_test
96
+ config.execute_as_batch
97
+
98
+ task = ::Albacore::TestRunner::Task.new(config.opts)
99
+
100
+ expect {
101
+ task.execute
102
+ }.to raise_error(ArgumentError)
103
+ end
104
+ end
105
+
106
+ context 'copy_local and execute_as_batch both specified' do
107
+ it 'should raise ArgumentError' do
108
+ config = ::Albacore::TestRunner::Config.new
109
+ config.exe = 'test-runner.exe'
110
+ config.files = 'Rakefile' # not a real DLL, but we need something that exists
111
+ config.copy_local
112
+ config.execute_as_batch
113
+
114
+ task = ::Albacore::TestRunner::Task.new(config.opts)
115
+
116
+ expect {
117
+ task.execute
118
+ }.to raise_error(ArgumentError)
119
+ end
120
+ end
121
+ end
122
+
85
123
  describe ::Albacore::TestRunner::Task do
86
- let :config do
87
- config = ::Albacore::TestRunner::Config.new
88
- config.files = 'a/b/c/file.dll'
89
- config.exe = 'test-runner.exe'
90
- config.add_parameter '/TestResults=abc.xml'
91
- config
124
+ def create_task_that_intercepts_commands opts
125
+ task = ::Albacore::TestRunner::Task.new(config.opts)
126
+ def task.execute_commands commands
127
+ @commands = commands
128
+ commands.each { |command|
129
+ command.extend ShInterceptor
130
+ command.execute
131
+ }
132
+ end
133
+
134
+ def task.commands
135
+ @commands
136
+ end
137
+
138
+ task.execute
139
+ task
140
+ end
141
+
142
+ before(:context) do
143
+ Dir.chdir 'spec'
144
+ end
145
+
146
+ after(:context) do
147
+ Dir.chdir '..'
92
148
  end
93
149
 
94
150
  subject do
95
- ::Albacore::TestRunner::Task.new(config.opts)
151
+ create_task_that_intercepts_commands config.opts
96
152
  end
97
153
 
98
- it do
99
- should respond_to :execute
154
+ context "native_exe not specified" do
155
+ let :config do
156
+ config = ::Albacore::TestRunner::Config.new
157
+ config.exe = 'test-runner.exe'
158
+ config.files = 'utils_spec.rb' # not a real DLL, but we need something that exists
159
+ config
160
+ end
161
+
162
+ it "should execute command as CLR command" do
163
+ expect(subject.commands[0].invocations[0].options[:clr_command]).to eq(true)
164
+ end
165
+
166
+ it "should include the file at the beginning of the command" do
167
+ expect(subject.commands[0].invocations[0].parameters.first).to eq('utils_spec.rb')
168
+ end
169
+ end
170
+
171
+ context "native_exe specified" do
172
+ let :config do
173
+ config = ::Albacore::TestRunner::Config.new
174
+ config.exe = 'test-runner.exe'
175
+ config.files = 'utils_spec.rb' # not a real DLL, but we need something that exists
176
+ config.native_exe
177
+ config
178
+ end
179
+
180
+ it "should execute command as non-CLR command" do
181
+ expect(subject.commands[0].invocations[0].options[:clr_command]).to eq(false)
182
+ end
183
+
184
+ it "should include the file at the beginning of the command" do
185
+ expect(subject.commands[0].invocations[0].parameters.first).to eq('utils_spec.rb')
186
+ end
187
+ end
188
+
189
+ context "extra parameters and options specified" do
190
+ let :config do
191
+ config = ::Albacore::TestRunner::Config.new
192
+ config.exe = 'test-runner.exe'
193
+ config.files = 'utils_spec.rb' # not a real DLL, but we need something that exists
194
+ config.add_parameter '/magic_parameter1'
195
+ config.add_parameter '/magic_parameter2'
196
+ config
197
+ end
198
+
199
+ it "should include the parameters at the end of the command" do
200
+ expect(subject.commands[0].invocations[0].parameters.last(2)).to eq(['/magic_parameter1', '/magic_parameter2'])
201
+ end
202
+
203
+ it "should include the file at the beginning of the command" do
204
+ expect(subject.commands[0].invocations[0].parameters.first).to eq('utils_spec.rb')
205
+ end
206
+ end
207
+
208
+ context "file is in current directory" do
209
+ let :config do
210
+ config = ::Albacore::TestRunner::Config.new
211
+ config.exe = 'test-runner.exe'
212
+ config.files = 'utils_spec.rb' # not a real DLL, but we need something that exists
213
+ config
214
+ end
215
+
216
+ it "should run the command from the current directory" do
217
+ expect(subject.commands[0].invocations[0].options[:work_dir]).to eq('.')
218
+ expect(subject.commands[0].invocations[0].executable).to eq('test-runner.exe')
219
+ end
220
+
221
+ it "should reference the file without directory qualifiers" do
222
+ expect(subject.commands[0].invocations[0].parameters).to include 'utils_spec.rb'
223
+ end
224
+ end
225
+
226
+ context "file is in subdirectory" do
227
+ let :config do
228
+ config = ::Albacore::TestRunner::Config.new
229
+ config.exe = 'test-runner.exe'
230
+ config.files = 'tools/fluent_migrator_spec.rb' # not a real DLL, but we need something that exists
231
+ config
232
+ end
233
+
234
+ it "should run the command from the subdirectory" do
235
+ expect(subject.commands[0].invocations[0].options[:work_dir]).to eq('tools')
236
+ expect(subject.commands[0].invocations[0].executable).to eq('../test-runner.exe')
237
+ end
238
+
239
+ it "should reference the file without directory qualifiers" do
240
+ expect(subject.commands[0].invocations[0].parameters).to include 'fluent_migrator_spec.rb'
241
+ end
242
+ end
243
+
244
+ context "file is in parent directory" do
245
+ let :config do
246
+ config = ::Albacore::TestRunner::Config.new
247
+ config.exe = 'test-runner.exe'
248
+ config.files = '../Rakefile' # not a real DLL, but we need something that exists
249
+ config
250
+ end
251
+
252
+ it "should run the command from the parent directory" do
253
+ expect(subject.commands[0].invocations[0].options[:work_dir]).to eq('..')
254
+ expect(subject.commands[0].invocations[0].executable).to eq('../spec/test-runner.exe')
255
+ end
256
+
257
+ it "should reference the file without directory qualifiers" do
258
+ expect(subject.commands[0].invocations[0].parameters).to include 'Rakefile'
259
+ end
100
260
  end
101
261
 
102
- def test_dir_exe hash
103
- given = hash.first[0]
104
- expected = hash.first[1]
105
- subject.send(:handle_directory, given[0], given[1]) do |dir, exe|
106
- expect(dir).to eq(expected[0])
107
- expect(exe).to eq(expected[1])
262
+ context 'is_ms_test specified' do
263
+ let :config do
264
+ config = ::Albacore::TestRunner::Config.new
265
+ config.exe = 'test-runner.exe'
266
+ config.is_ms_test
267
+ config.files = 'utils_spec.rb' # not a real DLL, but we need something that exists
268
+ config
108
269
  end
109
270
 
271
+ it 'should handle is_ms_test by adding testcontainer to the filename' do
272
+ expect(subject.commands.length).to eq(1)
273
+ expect(subject.commands[0].invocations[0].parameters.last).to eq('/testcontainer:utils_spec.rb')
274
+ end
110
275
  end
111
276
 
112
- it 'should handle relative handle_directory' do
113
- test_dir_exe ['d.dll', 'e.exe'] => ['.', 'e.exe']
277
+ context 'multiple files tested individually' do
278
+ let :config do
279
+ config = ::Albacore::TestRunner::Config.new
280
+ config.exe = 'test-runner.exe'
281
+ config.files = ['utils_spec.rb', 'tools/fluent_migrator_spec.rb'] # not real DLLs, but we need files that exist
282
+ config
283
+ end
284
+
285
+ it 'should execute one command per file' do
286
+ expect(subject.commands.length).to eq(2)
287
+ expect(subject.commands[0].invocations[0].parameters.last).to eq('utils_spec.rb')
288
+ expect(subject.commands[1].invocations[0].parameters.last).to eq('fluent_migrator_spec.rb')
289
+ end
114
290
  end
115
291
 
116
- it 'should handle actual relative directories correctly' do
117
- test_dir_exe ['a/d.dll', 'e.exe'] => ['a', '../e.exe']
292
+ context 'multiple files tested as a batch' do
293
+ let :config do
294
+ config = ::Albacore::TestRunner::Config.new
295
+ config.exe = 'test-runner.exe'
296
+ config.files = ['utils_spec.rb', 'tools/fluent_migrator_spec.rb'] # not real DLLs, but we need files that exist
297
+ config.execute_as_batch
298
+ config
299
+ end
300
+
301
+ it 'should execute a single command for all the files' do
302
+ expect(subject.commands.length).to eq(1)
303
+ expect(subject.commands[0].invocations[0].parameters).to eq(['utils_spec.rb', 'tools/fluent_migrator_spec.rb'])
304
+ end
118
305
  end
306
+ end
307
+
308
+ describe ::Albacore::TestRunner::Cmd do
309
+ describe "creation" do
310
+ subject do
311
+ command = ::Albacore::TestRunner::Cmd.new '.',
312
+ 'test-runner.exe',
313
+ ['/parameter'],
314
+ files
315
+ command.extend ShInterceptor
316
+ command.execute
317
+ command
318
+ end
319
+
320
+ context "files is a single file" do
321
+ let :files do
322
+ 'file'
323
+ end
324
+
325
+ it "should prepend the file to the parameters list" do
326
+ expect(subject.invocations[0].parameters).to eq(['file', '/parameter'])
327
+ end
328
+ end
329
+
330
+ context "files is an array" do
331
+ let :files do
332
+ ['file1', 'file2']
333
+ end
119
334
 
120
- it 'should handle negative dirs by getting current dir name' do
121
- subject.send(:handle_directory, '../d.dll', 'e.exe') do |dir, exe|
122
- expect(dir).to eq('..')
123
- # at this point, the exe file is just a dir in
124
- expect(exe).to match /\w+\/e\.exe/
335
+ it "should prepend the files to the parameters list" do
336
+ expect(subject.invocations[0].parameters).to eq(['file1', 'file2', '/parameter'])
337
+ end
125
338
  end
126
339
  end
127
340
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: albacore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.14
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Feldt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-05 00:00:00.000000000 Z
12
+ date: 2016-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake