omnibus 3.2.0.rc.1 → 3.2.0.rc.2
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/CHANGELOG.md +11 -2
- data/Rakefile +2 -2
- data/lib/omnibus.rb +13 -4
- data/lib/omnibus/builder.rb +596 -248
- data/lib/omnibus/cleanroom.rb +7 -7
- data/lib/omnibus/cli/deprecated.rb +1 -1
- data/lib/omnibus/exceptions.rb +36 -5
- data/lib/omnibus/fetchers/net_fetcher.rb +4 -0
- data/lib/omnibus/git_cache.rb +3 -3
- data/lib/omnibus/instrumentation.rb +29 -0
- data/lib/omnibus/package.rb +98 -5
- data/lib/omnibus/packagers/base.rb +1 -0
- data/lib/omnibus/project.rb +5 -64
- data/lib/omnibus/publishers/artifactory_publisher.rb +4 -1
- data/lib/omnibus/software.rb +52 -29
- data/lib/omnibus/util.rb +11 -1
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +2 -3
- data/spec/data/complicated/config/software/libyaml-windows.rb +1 -1
- data/spec/functional/builder_spec.rb +305 -0
- data/spec/{functional → integration}/packagers/mac_spec.rb +0 -0
- data/spec/{functional → integration}/packagers/windows_spec.rb +0 -0
- data/spec/spec_helper.rb +8 -7
- data/spec/unit/build_version_dsl_spec.rb +77 -75
- data/spec/unit/build_version_spec.rb +4 -4
- data/spec/unit/builder_spec.rb +49 -0
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/fetchers/git_fetcher_spec.rb +11 -11
- data/spec/unit/fetchers/net_fetcher_spec.rb +3 -5
- data/spec/unit/git_cache_spec.rb +2 -2
- data/spec/unit/package_spec.rb +118 -11
- data/spec/unit/packagers/base_spec.rb +17 -17
- data/spec/unit/packagers/mac_pkg_spec.rb +1 -1
- data/spec/unit/project_spec.rb +27 -101
- data/spec/unit/publisher_spec.rb +2 -2
- data/spec/unit/publishers/artifactory_publisher_spec.rb +8 -7
- data/spec/unit/publishers/s3_publisher_spec.rb +3 -3
- data/spec/unit/s3_cacher_spec.rb +2 -2
- data/spec/unit/software_spec.rb +26 -18
- metadata +27 -22
data/lib/omnibus/util.rb
CHANGED
|
@@ -48,6 +48,12 @@ module Omnibus
|
|
|
48
48
|
options = args.last.kind_of?(Hash) ? args.pop : {}
|
|
49
49
|
options = SHELLOUT_OPTIONS.merge(options)
|
|
50
50
|
|
|
51
|
+
# Since Mixlib::ShellOut supports :environment and :env, we want to
|
|
52
|
+
# standardize here
|
|
53
|
+
if options[:env]
|
|
54
|
+
options[:environment] = options.fetch(:environment, {}).merge(options[:env])
|
|
55
|
+
end
|
|
56
|
+
|
|
51
57
|
# Log any environment options given
|
|
52
58
|
unless options[:environment].empty?
|
|
53
59
|
Omnibus.logger.info { 'Environment:' }
|
|
@@ -60,6 +66,7 @@ module Omnibus
|
|
|
60
66
|
Omnibus.logger.info { "$ #{args.join(' ')}" }
|
|
61
67
|
|
|
62
68
|
cmd = Mixlib::ShellOut.new(*args, options)
|
|
69
|
+
cmd.environment['HOME'] = '/tmp' unless ENV['HOME']
|
|
63
70
|
cmd.run_command
|
|
64
71
|
cmd
|
|
65
72
|
end
|
|
@@ -92,13 +99,16 @@ module Omnibus
|
|
|
92
99
|
value && value.to_s =~ /^(false|f|no|n|0)$/i
|
|
93
100
|
end
|
|
94
101
|
|
|
102
|
+
#
|
|
103
|
+
# Convert the given path to be appropiate for shelling out on Windows.
|
|
104
|
+
#
|
|
95
105
|
# @param [Array<String>] pieces
|
|
96
106
|
# the pieces of the path to join and fix
|
|
97
107
|
# @return [String]
|
|
98
108
|
# the path with applied changes
|
|
99
109
|
#
|
|
100
110
|
def windows_safe_path(*pieces)
|
|
101
|
-
path = File.
|
|
111
|
+
path = File.join(*pieces)
|
|
102
112
|
|
|
103
113
|
if File::ALT_SEPARATOR
|
|
104
114
|
path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
data/lib/omnibus/version.rb
CHANGED
data/omnibus.gemspec
CHANGED
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
|
21
21
|
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
|
22
22
|
gem.require_paths = ['lib']
|
|
23
23
|
|
|
24
|
+
gem.add_dependency 'bundler'
|
|
24
25
|
gem.add_dependency 'chef-sugar', '~> 1.2'
|
|
25
26
|
gem.add_dependency 'mixlib-shellout', '~> 1.4'
|
|
26
27
|
gem.add_dependency 'ohai', '~> 7.2.0.rc'
|
|
@@ -31,9 +32,7 @@ Gem::Specification.new do |gem|
|
|
|
31
32
|
gem.add_development_dependency 'artifactory', '~> 1.2'
|
|
32
33
|
gem.add_development_dependency 'aruba', '~> 0.5'
|
|
33
34
|
gem.add_development_dependency 'fauxhai', '~> 2.1'
|
|
34
|
-
gem.add_development_dependency 'rspec', '~>
|
|
35
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
|
35
36
|
gem.add_development_dependency 'rspec-its'
|
|
36
37
|
gem.add_development_dependency 'rake'
|
|
37
|
-
|
|
38
|
-
gem.add_development_dependency 'bundler'
|
|
39
38
|
end
|
|
@@ -35,7 +35,7 @@ source :url => "http://packages.openknapsack.org/libyaml/libyaml-0.1.6-x86-windo
|
|
|
35
35
|
build do
|
|
36
36
|
temp_directory = File.join(cache_dir, "libyaml-cache")
|
|
37
37
|
# First extract the tar file out of lzma archive.
|
|
38
|
-
command "7z.exe x #{
|
|
38
|
+
command "7z.exe x #{downloaded_file} -o#{temp_directory} -r -y"
|
|
39
39
|
# Now extract the files out of tar archive.
|
|
40
40
|
command "7z.exe x #{File.join(temp_directory, "libyaml-0.1.6-x86-windows.tar")} -o#{temp_directory} -r -y"
|
|
41
41
|
# Now copy over libyaml-0-2.dll to the build dir
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Omnibus
|
|
4
|
+
describe Builder do
|
|
5
|
+
let(:software) do
|
|
6
|
+
double(Software,
|
|
7
|
+
name: 'chefdk',
|
|
8
|
+
install_dir: File.join(tmp_path, 'chefdk'),
|
|
9
|
+
project_dir: File.join(tmp_path, 'chefdk', 'cache'),
|
|
10
|
+
overridden?: false,
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Fakes the embedded bin path to whatever exists in bundler. This is useful
|
|
16
|
+
# for testing methods like +ruby+ and +rake+ without the need to compile
|
|
17
|
+
# a real Ruby just for functional tests.
|
|
18
|
+
#
|
|
19
|
+
def fake_embedded_bin(name)
|
|
20
|
+
bin = File.join(software.install_dir, 'embedded', 'bin')
|
|
21
|
+
|
|
22
|
+
FileUtils.mkdir_p(bin)
|
|
23
|
+
FileUtils.ln_s(Bundler.which(name), File.join(bin, name))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
subject { described_class.new(software) }
|
|
27
|
+
|
|
28
|
+
before do
|
|
29
|
+
Config.project_root(tmp_path)
|
|
30
|
+
Config.build_retries(0)
|
|
31
|
+
Config.use_git_caching(false)
|
|
32
|
+
Config.software_gems(nil)
|
|
33
|
+
|
|
34
|
+
# Make the directories
|
|
35
|
+
FileUtils.mkdir_p(software.install_dir)
|
|
36
|
+
FileUtils.mkdir_p(software.project_dir)
|
|
37
|
+
FileUtils.mkdir_p(File.join(tmp_path, 'config', 'software'))
|
|
38
|
+
FileUtils.mkdir_p(File.join(tmp_path, 'config', 'patches'))
|
|
39
|
+
FileUtils.mkdir_p(File.join(tmp_path, 'config', 'templates'))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#command' do
|
|
43
|
+
it 'executes the command' do
|
|
44
|
+
path = File.join(software.install_dir, 'file.txt')
|
|
45
|
+
subject.command("echo 'Hello World!'")
|
|
46
|
+
|
|
47
|
+
output = capture_logging { subject.build }
|
|
48
|
+
expect(output).to include('Hello World')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#patch' do
|
|
53
|
+
it 'applies the patch' do
|
|
54
|
+
configure = File.join(tmp_path, 'chefdk', 'cache', 'configure')
|
|
55
|
+
FileUtils.mkdir_p(File.dirname(configure))
|
|
56
|
+
File.open(configure, 'w') do |f|
|
|
57
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
58
|
+
THING="-e foo"
|
|
59
|
+
ZIP="zap"
|
|
60
|
+
EOH
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
patch = File.join(tmp_path, 'config', 'patches', 'chefdk', 'apply.patch')
|
|
64
|
+
FileUtils.mkdir_p(File.dirname(patch))
|
|
65
|
+
File.open(patch, 'w') do |f|
|
|
66
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
67
|
+
--- a/configure
|
|
68
|
+
+++ b/configure
|
|
69
|
+
@@ -1,2 +1,3 @@
|
|
70
|
+
THING="-e foo"
|
|
71
|
+
+FOO="bar"
|
|
72
|
+
ZIP="zap"
|
|
73
|
+
EOH
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
subject.patch(source: 'apply.patch')
|
|
77
|
+
subject.build
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '#ruby' do
|
|
82
|
+
it 'executes the command as the embdedded ruby' do
|
|
83
|
+
ruby = File.join(tmp_path, 'chefdk', 'scripts', 'setup.rb')
|
|
84
|
+
FileUtils.mkdir_p(File.dirname(ruby))
|
|
85
|
+
File.open(ruby, 'w') do |f|
|
|
86
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
87
|
+
File.write("#{software.install_dir}/test.txt", 'This is content!')
|
|
88
|
+
EOH
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
fake_embedded_bin('ruby')
|
|
92
|
+
|
|
93
|
+
subject.ruby(ruby)
|
|
94
|
+
subject.build
|
|
95
|
+
|
|
96
|
+
path = "#{software.install_dir}/test.txt"
|
|
97
|
+
expect(File.exist?(path)).to be_truthy
|
|
98
|
+
expect(File.read(path)).to eq('This is content!')
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe '#gem' do
|
|
103
|
+
it 'executes the command as the embedded gem' do
|
|
104
|
+
gemspec = File.join(tmp_path, 'example.gemspec')
|
|
105
|
+
File.open(gemspec, 'w') do |f|
|
|
106
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
107
|
+
Gem::Specification.new do |gem|
|
|
108
|
+
gem.name = 'example'
|
|
109
|
+
gem.version = '1.0.0'
|
|
110
|
+
gem.author = 'Chef Software, Inc.'
|
|
111
|
+
gem.email = 'info@getchef.com'
|
|
112
|
+
gem.description = 'Installs a thing'
|
|
113
|
+
gem.summary = gem.description
|
|
114
|
+
end
|
|
115
|
+
EOH
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
fake_embedded_bin('gem')
|
|
119
|
+
|
|
120
|
+
subject.gem("build #{gemspec}")
|
|
121
|
+
subject.gem("install #{tmp_path}/chefdk/cache/example-1.0.0.gem")
|
|
122
|
+
output = capture_logging { subject.build }
|
|
123
|
+
|
|
124
|
+
expect(output).to include('gem build')
|
|
125
|
+
expect(output).to include('gem install')
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#bundler' do
|
|
130
|
+
it 'executes the command as the embedded bundler' do
|
|
131
|
+
gemspec = File.join(tmp_path, 'example.gemspec')
|
|
132
|
+
File.open(gemspec, 'w') do |f|
|
|
133
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
134
|
+
Gem::Specification.new do |gem|
|
|
135
|
+
gem.name = 'example'
|
|
136
|
+
gem.version = '1.0.0'
|
|
137
|
+
gem.author = 'Chef Software, Inc.'
|
|
138
|
+
gem.email = 'info@getchef.com'
|
|
139
|
+
gem.description = 'Installs a thing'
|
|
140
|
+
gem.summary = gem.description
|
|
141
|
+
end
|
|
142
|
+
EOH
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
gemfile = File.join(tmp_path, 'Gemfile')
|
|
146
|
+
File.open(gemfile, 'w') do |f|
|
|
147
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
148
|
+
gemspec
|
|
149
|
+
EOH
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
fake_embedded_bin('bundle')
|
|
153
|
+
|
|
154
|
+
subject.bundle('install')
|
|
155
|
+
output = capture_logging { subject.build }
|
|
156
|
+
|
|
157
|
+
expect(output).to include('bundle install')
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
describe '#rake' do
|
|
162
|
+
it 'executes the command as the embedded rake' do
|
|
163
|
+
rakefile = File.join(tmp_path, 'Rakefile')
|
|
164
|
+
File.open(rakefile, 'w') do |f|
|
|
165
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
166
|
+
task(:foo) { }
|
|
167
|
+
EOH
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
fake_embedded_bin('rake')
|
|
171
|
+
|
|
172
|
+
subject.rake('-T')
|
|
173
|
+
subject.rake('foo')
|
|
174
|
+
output = capture_logging { subject.build }
|
|
175
|
+
|
|
176
|
+
expect(output).to include('rake -T')
|
|
177
|
+
expect(output).to include('rake foo')
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
describe '#block' do
|
|
182
|
+
it 'executes the command as a block' do
|
|
183
|
+
subject.block('A complex operation') do
|
|
184
|
+
FileUtils.touch("#{project_dir}/bacon")
|
|
185
|
+
end
|
|
186
|
+
output = capture_logging { subject.build }
|
|
187
|
+
|
|
188
|
+
expect(output).to include('A complex operation')
|
|
189
|
+
expect(File.exist?("#{software.project_dir}/bacon")).to be_truthy
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe '#erb' do
|
|
194
|
+
it 'renders the erb' do
|
|
195
|
+
erb = File.join(tmp_path, 'config', 'templates', 'chefdk', 'example.erb')
|
|
196
|
+
FileUtils.mkdir_p(File.dirname(erb))
|
|
197
|
+
File.open(erb, 'w') do |f|
|
|
198
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
|
199
|
+
<%= a %>
|
|
200
|
+
<%= b %>
|
|
201
|
+
EOH
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
destination = File.join(tmp_path, 'rendered')
|
|
205
|
+
|
|
206
|
+
subject.erb(
|
|
207
|
+
source: 'example.erb',
|
|
208
|
+
dest: destination,
|
|
209
|
+
vars: { a: 'foo', b: 'bar' },
|
|
210
|
+
)
|
|
211
|
+
subject.build
|
|
212
|
+
|
|
213
|
+
expect(File.exist?(destination)).to be_truthy
|
|
214
|
+
expect(File.read(destination)).to eq("foo\nbar\n")
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
describe '#mkdir' do
|
|
219
|
+
it 'creates the directory' do
|
|
220
|
+
path = File.join(tmp_path, 'scratch')
|
|
221
|
+
FileUtils.rm_rf(path)
|
|
222
|
+
|
|
223
|
+
subject.mkdir(path)
|
|
224
|
+
subject.build
|
|
225
|
+
|
|
226
|
+
expect(File.directory?(path)).to be_truthy
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
describe '#touch' do
|
|
231
|
+
it 'creates the file' do
|
|
232
|
+
path = File.join(tmp_path, 'file')
|
|
233
|
+
FileUtils.rm_rf(path)
|
|
234
|
+
|
|
235
|
+
subject.touch(path)
|
|
236
|
+
subject.build
|
|
237
|
+
|
|
238
|
+
expect(File.file?(path)).to be_truthy
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe '#delete' do
|
|
243
|
+
it 'deletes the directory' do
|
|
244
|
+
path = File.join(tmp_path, 'scratch')
|
|
245
|
+
FileUtils.mkdir_p(path)
|
|
246
|
+
|
|
247
|
+
subject.delete(path)
|
|
248
|
+
subject.build
|
|
249
|
+
|
|
250
|
+
expect(File.exist?(path)).to be_falsey
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it 'deletes the file' do
|
|
254
|
+
path = File.join(tmp_path, 'file')
|
|
255
|
+
FileUtils.touch(path)
|
|
256
|
+
|
|
257
|
+
subject.delete(path)
|
|
258
|
+
subject.build
|
|
259
|
+
|
|
260
|
+
expect(File.exist?(path)).to be_falsey
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
describe '#copy' do
|
|
265
|
+
it 'copies the file' do
|
|
266
|
+
path_a = File.join(tmp_path, 'file1')
|
|
267
|
+
path_b = File.join(tmp_path, 'file2')
|
|
268
|
+
FileUtils.touch(path_a)
|
|
269
|
+
|
|
270
|
+
subject.copy(path_a, path_b)
|
|
271
|
+
subject.build
|
|
272
|
+
|
|
273
|
+
expect(File.file?(path_b)).to be_truthy
|
|
274
|
+
expect(File.read(path_b)).to eq(File.read(path_a))
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
describe '#move' do
|
|
279
|
+
it 'moves the file' do
|
|
280
|
+
path_a = File.join(tmp_path, 'file1')
|
|
281
|
+
path_b = File.join(tmp_path, 'file2')
|
|
282
|
+
FileUtils.touch(path_a)
|
|
283
|
+
|
|
284
|
+
subject.move(path_a, path_b)
|
|
285
|
+
subject.build
|
|
286
|
+
|
|
287
|
+
expect(File.file?(path_b)).to be_truthy
|
|
288
|
+
expect(File.file?(path_a)).to be_falsey
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe '#link' do
|
|
293
|
+
it 'links the file' do
|
|
294
|
+
path_a = File.join(tmp_path, 'file1')
|
|
295
|
+
path_b = File.join(tmp_path, 'file2')
|
|
296
|
+
FileUtils.touch(path_a)
|
|
297
|
+
|
|
298
|
+
subject.link(path_a, path_b)
|
|
299
|
+
subject.build
|
|
300
|
+
|
|
301
|
+
expect(File.symlink?(path_b)).to be_truthy
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
end
|
|
File without changes
|
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
|
@@ -40,11 +40,11 @@ module Omnibus
|
|
|
40
40
|
#
|
|
41
41
|
def stub_env(key, value)
|
|
42
42
|
unless @__env_already_stubbed__
|
|
43
|
-
ENV.
|
|
43
|
+
allow(ENV).to receive(:[]).and_call_original
|
|
44
44
|
@__env_already_stubbed__ = true
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
ENV.
|
|
47
|
+
allow(ENV).to receive(:[]).with(key).and_return(value.to_s)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
#
|
|
@@ -56,7 +56,7 @@ module Omnibus
|
|
|
56
56
|
require 'ohai' unless defined?(Mash)
|
|
57
57
|
|
|
58
58
|
ohai = Mash.from_hash(Fauxhai.mock(options, &block).data)
|
|
59
|
-
Ohai.
|
|
59
|
+
allow(Ohai).to receive(:ohai).and_return(ohai)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
#
|
|
@@ -103,7 +103,6 @@ RSpec.configure do |config|
|
|
|
103
103
|
config.include Omnibus::RSpec
|
|
104
104
|
config.filter_run focus: true
|
|
105
105
|
config.run_all_when_everything_filtered = true
|
|
106
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
107
106
|
|
|
108
107
|
config.filter_run_excluding windows_only: true unless windows?
|
|
109
108
|
config.filter_run_excluding mac_only: true unless mac?
|
|
@@ -141,11 +140,13 @@ end
|
|
|
141
140
|
# Shard example group for asserting a DSL method
|
|
142
141
|
#
|
|
143
142
|
# @example
|
|
144
|
-
# it_behaves_like 'a cleanroom setter', :name,
|
|
143
|
+
# it_behaves_like 'a cleanroom setter', :name, <<-EOH
|
|
144
|
+
# name 'foo'
|
|
145
|
+
# EOH
|
|
145
146
|
#
|
|
146
|
-
RSpec.shared_examples 'a cleanroom setter' do |id,
|
|
147
|
+
RSpec.shared_examples 'a cleanroom setter' do |id, string|
|
|
147
148
|
it "for `#{id}'" do
|
|
148
|
-
expect { subject.evaluate(
|
|
149
|
+
expect { subject.evaluate(string) }
|
|
149
150
|
.to_not raise_error
|
|
150
151
|
end
|
|
151
152
|
end
|
|
@@ -17,120 +17,122 @@
|
|
|
17
17
|
|
|
18
18
|
require 'spec_helper'
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
module Omnibus
|
|
21
|
+
describe BuildVersionDSL do
|
|
22
|
+
let(:subject_with_version) { described_class.new(version_string) }
|
|
23
|
+
let(:subject_with_description) { described_class.new(&description) }
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
let(:version_string) { "1.0.0" }
|
|
26
|
+
let(:description) { nil }
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
let(:zoo_version) { double("BuildVersion", semver: "5.5.5", custom: "7.7.7") }
|
|
29
|
+
let(:zoo_software) { double("software", name: 'zoo', project_dir: '/etc/zoo', version: "6.6.6") }
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
describe "when given nil" do
|
|
32
|
+
it "fails" do
|
|
33
|
+
expect { subject.build_version }.to raise_error
|
|
34
|
+
end
|
|
33
35
|
end
|
|
34
|
-
end
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
describe "when given a string" do
|
|
38
|
+
it "sets the version to the string" do
|
|
39
|
+
expect(subject_with_version.build_version).to eq("1.0.0")
|
|
40
|
+
end
|
|
39
41
|
end
|
|
40
|
-
end
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
describe "when given a :git source" do
|
|
44
|
+
describe "when given a software as source" do
|
|
45
|
+
let(:description) do
|
|
46
|
+
proc do
|
|
47
|
+
source(:git, from_dependency: 'zoo')
|
|
48
|
+
end
|
|
47
49
|
end
|
|
48
|
-
end
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
describe "before resolving version" do
|
|
52
|
+
it "mentions the version is not ready yet" do
|
|
53
|
+
expect(subject_with_description.explain).to match(/will be determined/)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "includes the dependency name in the message" do
|
|
57
|
+
expect(subject_with_description.explain).to match(/zoo/)
|
|
58
|
+
end
|
|
53
59
|
end
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
describe "after resolving version" do
|
|
62
|
+
before do
|
|
63
|
+
expect(BuildVersion).to receive(:new).with("/etc/zoo").and_return(zoo_version)
|
|
64
|
+
subject_with_description.resolve(zoo_software)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "creates the version with path from source with semver" do
|
|
68
|
+
expect(subject_with_description.explain).to eq("Build Version: 5.5.5")
|
|
69
|
+
end
|
|
57
70
|
end
|
|
58
71
|
end
|
|
59
72
|
|
|
60
|
-
describe "
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
subject_with_description.resolve(zoo_software)
|
|
73
|
+
describe "when not given a software as source" do
|
|
74
|
+
let(:description) do
|
|
75
|
+
proc { source(:git) }
|
|
64
76
|
end
|
|
65
77
|
|
|
66
|
-
it "
|
|
67
|
-
expect(
|
|
78
|
+
it "creates the version with default path as semver" do
|
|
79
|
+
expect(BuildVersion).to receive(:new).with(no_args).and_return(zoo_version)
|
|
80
|
+
expect(subject_with_description.build_version).to eq("5.5.5")
|
|
68
81
|
end
|
|
69
82
|
end
|
|
70
|
-
end
|
|
71
83
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
describe "when given an output format" do
|
|
85
|
+
let(:description) do
|
|
86
|
+
proc do
|
|
87
|
+
source(:git)
|
|
88
|
+
output_format(:custom)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
it "outputs the version with given function" do
|
|
93
|
+
expect(BuildVersion).to receive(:new).with(no_args).and_return(zoo_version)
|
|
94
|
+
expect(subject_with_description.build_version).to eq("7.7.7")
|
|
95
|
+
end
|
|
80
96
|
end
|
|
81
97
|
end
|
|
82
98
|
|
|
83
|
-
describe "when given
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
describe "when given a :version source" do
|
|
100
|
+
describe "when given a software as source" do
|
|
101
|
+
let(:description) do
|
|
102
|
+
proc do
|
|
103
|
+
source(:version, from_dependency: 'zoo')
|
|
104
|
+
end
|
|
88
105
|
end
|
|
89
|
-
end
|
|
90
106
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
it "creates the version with version from source" do
|
|
108
|
+
subject_with_description.resolve(zoo_software)
|
|
109
|
+
expect(subject_with_description.build_version).to eq("6.6.6")
|
|
110
|
+
end
|
|
94
111
|
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
describe "when not given a software as source" do
|
|
114
|
+
let(:description) do
|
|
115
|
+
proc do
|
|
116
|
+
source(:version)
|
|
117
|
+
end
|
|
103
118
|
end
|
|
104
|
-
end
|
|
105
119
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
it "fails" do
|
|
121
|
+
expect { subject_with_description.build_version }.to raise_error
|
|
122
|
+
end
|
|
109
123
|
end
|
|
110
124
|
end
|
|
111
125
|
|
|
112
|
-
describe "when
|
|
126
|
+
describe "when given an unknown source" do
|
|
113
127
|
let(:description) do
|
|
114
128
|
proc do
|
|
115
|
-
source(:
|
|
129
|
+
source(:park)
|
|
116
130
|
end
|
|
117
131
|
end
|
|
118
132
|
|
|
119
|
-
it "
|
|
133
|
+
it "fails" do
|
|
120
134
|
expect { subject_with_description.build_version }.to raise_error
|
|
121
135
|
end
|
|
122
136
|
end
|
|
123
137
|
end
|
|
124
|
-
|
|
125
|
-
describe "when given an unknown source" do
|
|
126
|
-
let(:description) do
|
|
127
|
-
proc do
|
|
128
|
-
source(:park)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
it "should fail" do
|
|
133
|
-
expect { subject_with_description.build_version }.to raise_error
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
138
|
end
|