packaging 0.108.2 → 0.109.0
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/README.md +0 -2
- data/lib/packaging/artifactory.rb +15 -10
- data/lib/packaging/config/validations.rb +1 -1
- data/lib/packaging/config.rb +5 -5
- data/lib/packaging/deb/repo.rb +4 -4
- data/lib/packaging/nuget.rb +1 -1
- data/lib/packaging/paths.rb +4 -3
- data/lib/packaging/sign/msi.rb +6 -8
- data/lib/packaging/util/execution.rb +1 -1
- data/lib/packaging/util/ezbake.rb +1 -1
- data/lib/packaging/util/file.rb +4 -6
- data/lib/packaging/util/net.rb +8 -12
- data/lib/packaging/util/ship.rb +17 -7
- data/lib/packaging/util/tool.rb +1 -1
- data/lib/packaging/util/version.rb +7 -5
- data/spec/lib/packaging/config_spec.rb +300 -279
- data/spec/lib/packaging/deb/repo_spec.rb +138 -76
- data/spec/lib/packaging/deb_spec.rb +28 -25
- data/spec/lib/packaging/repo_spec.rb +52 -31
- data/spec/lib/packaging/rpm/repo_spec.rb +18 -37
- data/spec/lib/packaging/sign_spec.rb +22 -43
- data/spec/lib/packaging/tar_spec.rb +48 -44
- data/spec/lib/packaging/util/execution_spec.rb +32 -32
- data/spec/lib/packaging/util/file_spec.rb +112 -75
- data/spec/lib/packaging/util/gpg_spec.rb +24 -19
- data/spec/lib/packaging/util/jenkins_spec.rb +79 -48
- data/spec/lib/packaging/util/misc_spec.rb +13 -8
- data/spec/lib/packaging/util/net_spec.rb +193 -152
- data/spec/lib/packaging/util/rake_utils_spec.rb +24 -18
- data/spec/lib/packaging_spec.rb +7 -9
- data/tasks/apple.rake +7 -8
- data/tasks/deb.rake +1 -1
- data/tasks/fetch.rake +2 -2
- data/tasks/mock.rake +3 -3
- data/tasks/nightly_repos.rake +11 -9
- data/tasks/rpm.rake +2 -3
- data/tasks/ship.rake +4 -2
- data/tasks/sign.rake +8 -10
- data/tasks/z_data_dump.rake +3 -3
- metadata +46 -33
@@ -2,216 +2,216 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
describe
|
144
|
-
|
145
|
-
it "should have r/w accessors for #{
|
146
|
-
Pkg::Config.
|
147
|
-
Pkg::Config.
|
5
|
+
CONFIGURATION_KEYS = %i[
|
6
|
+
apt_archive_path
|
7
|
+
apt_archive_repo_command
|
8
|
+
apt_host
|
9
|
+
apt_releases
|
10
|
+
apt_repo_path
|
11
|
+
apt_repo_url
|
12
|
+
apt_repo_name
|
13
|
+
apt_repo_command
|
14
|
+
author
|
15
|
+
benchmark
|
16
|
+
build_date
|
17
|
+
build_defaults
|
18
|
+
build_dmg
|
19
|
+
build_doc
|
20
|
+
build_gem
|
21
|
+
build_ips
|
22
|
+
build_msi
|
23
|
+
build_pe
|
24
|
+
build_tar
|
25
|
+
builder_data_file
|
26
|
+
bundle_platforms
|
27
|
+
certificate_pem
|
28
|
+
cows
|
29
|
+
db_table
|
30
|
+
deb_build_host
|
31
|
+
deb_build_mirrors
|
32
|
+
debversion
|
33
|
+
debug
|
34
|
+
default_cow
|
35
|
+
default_mock
|
36
|
+
description
|
37
|
+
dmg_path
|
38
|
+
downloads_archive_path
|
39
|
+
email
|
40
|
+
files
|
41
|
+
final_mocks
|
42
|
+
freight_archive_path
|
43
|
+
freight_conf
|
44
|
+
gem_default_executables
|
45
|
+
gem_dependencies
|
46
|
+
gem_description
|
47
|
+
gem_devel_dependencies
|
48
|
+
gem_development_dependencies
|
49
|
+
gem_excludes
|
50
|
+
gem_executables
|
51
|
+
gem_files
|
52
|
+
gem_forge_project
|
53
|
+
gem_host
|
54
|
+
gem_license
|
55
|
+
gem_name
|
56
|
+
gem_path
|
57
|
+
gem_platform_dependencies
|
58
|
+
gem_rdoc_options
|
59
|
+
gem_require_path
|
60
|
+
gem_required_ruby_version
|
61
|
+
gem_required_rubygems_version
|
62
|
+
gem_runtime_dependencies
|
63
|
+
gem_summary
|
64
|
+
gem_test_files
|
65
|
+
gemversion
|
66
|
+
gpg_key
|
67
|
+
gpg_name
|
68
|
+
homepage
|
69
|
+
ips_build_host
|
70
|
+
ips_host
|
71
|
+
ips_inter_cert
|
72
|
+
ips_package_host
|
73
|
+
ips_path
|
74
|
+
ips_repo
|
75
|
+
ips_store
|
76
|
+
jenkins_build_host
|
77
|
+
jenkins_packaging_job
|
78
|
+
jenkins_repo_path
|
79
|
+
metrics
|
80
|
+
metrics_url
|
81
|
+
msi_name
|
82
|
+
name
|
83
|
+
nonfinal_apt_repo_command
|
84
|
+
nonfinal_apt_repo_path
|
85
|
+
nonfinal_apt_repo_staging_path
|
86
|
+
nonfinal_dmg_path
|
87
|
+
nonfinal_gem_path
|
88
|
+
nonfinal_ips_path
|
89
|
+
nonfinal_msi_path
|
90
|
+
nonfinal_p5p_path
|
91
|
+
nonfinal_repo_name
|
92
|
+
nonfinal_repo_link_target
|
93
|
+
nonfinal_svr4_path
|
94
|
+
nonfinal_swix_path
|
95
|
+
nonfinal_yum_repo_path
|
96
|
+
notify
|
97
|
+
project
|
98
|
+
origversion
|
99
|
+
osx_build_host
|
100
|
+
packager
|
101
|
+
packaging_repo
|
102
|
+
packaging_root
|
103
|
+
packaging_url
|
104
|
+
pbuild_conf
|
105
|
+
pe_name
|
106
|
+
pe_version
|
107
|
+
pg_major_version
|
108
|
+
pre_tar_task
|
109
|
+
pre_tasks
|
110
|
+
privatekey_pem
|
111
|
+
random_mockroot
|
112
|
+
rc_mocks
|
113
|
+
release
|
114
|
+
rpm_build_host
|
115
|
+
rpmrelease
|
116
|
+
rpmversion
|
117
|
+
ref
|
118
|
+
repo_name
|
119
|
+
short_ref
|
120
|
+
sign_tar
|
121
|
+
signing_server
|
122
|
+
summary
|
123
|
+
svr4_host
|
124
|
+
svr4_path
|
125
|
+
swix_path
|
126
|
+
tar_excludes
|
127
|
+
tar_host
|
128
|
+
tarball_path
|
129
|
+
team
|
130
|
+
templates
|
131
|
+
update_version_file
|
132
|
+
version
|
133
|
+
version_file
|
134
|
+
version_strategy
|
135
|
+
yum_archive_path
|
136
|
+
yum_host
|
137
|
+
yum_repo_path
|
138
|
+
yum_repo_name
|
139
|
+
yum_repo_command
|
140
|
+
]
|
141
|
+
|
142
|
+
describe 'Pkg::Config' do
|
143
|
+
describe '#new' do
|
144
|
+
CONFIGURATION_KEYS.each do |configuration_key|
|
145
|
+
it "should have r/w accessors for #{configuration_key}" do
|
146
|
+
expect(Pkg::Config).to respond_to(configuration_key)
|
147
|
+
expect(Pkg::Config).to respond_to("#{configuration_key.to_s}=")
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
describe
|
153
|
-
good_params = { :
|
152
|
+
describe '#config_from_hash' do
|
153
|
+
good_params = { yum_host: 'foo', pe_name: 'bar' }
|
154
154
|
context "given a valid params hash #{good_params}" do
|
155
|
-
it
|
155
|
+
it 'should set instance variable values for each param' do
|
156
156
|
good_params.each do |param, value|
|
157
|
-
Pkg::Config.
|
157
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{param}", value)
|
158
158
|
end
|
159
159
|
Pkg::Config.config_from_hash(good_params)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
bad_params = { :
|
163
|
+
bad_params = { foo: 'bar' }
|
164
164
|
context "given an invalid params hash #{bad_params}" do
|
165
165
|
bad_params.each do |param, value|
|
166
166
|
it "should print a warning that param '#{param}' is not valid" do
|
167
|
-
Pkg::Config.
|
167
|
+
expect(Pkg::Config).to receive(:warn).with(/No build data parameter found for '#{param}'/)
|
168
168
|
Pkg::Config.config_from_hash(bad_params)
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should not try to set instance variable @:#{param}" do
|
172
|
-
Pkg::Config.
|
172
|
+
expect(Pkg::Config).to_not receive(:instance_variable_set).with("@#{param}", value)
|
173
173
|
Pkg::Config.config_from_hash(bad_params)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
mixed_params = { :
|
179
|
-
context
|
180
|
-
it
|
181
|
-
Pkg::Config.
|
178
|
+
mixed_params = { sign_tar: true, baz: 'qux' }
|
179
|
+
context 'given a hash with both valid and invalid params' do
|
180
|
+
it 'should set the valid param' do
|
181
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@sign_tar", true)
|
182
182
|
Pkg::Config.config_from_hash(mixed_params)
|
183
183
|
end
|
184
184
|
|
185
|
-
it
|
186
|
-
Pkg::Config.
|
185
|
+
it 'should issue a warning that the invalid param is not valid' do
|
186
|
+
expect(Pkg::Config).to receive(:warn).with(/No build data parameter found for 'baz'/)
|
187
187
|
Pkg::Config.config_from_hash(mixed_params)
|
188
188
|
end
|
189
189
|
|
190
|
-
it
|
191
|
-
Pkg::Config.
|
190
|
+
it 'should not try to set instance variable @:baz' do
|
191
|
+
expect(Pkg::Config).to_not receive(:instance_variable_set).with('@baz', 'qux')
|
192
192
|
Pkg::Config.config_from_hash(mixed_params)
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
describe
|
198
|
-
it
|
197
|
+
describe '#params' do
|
198
|
+
it 'should return a hash containing keys for all build parameters' do
|
199
199
|
params = Pkg::Config.config
|
200
|
-
|
200
|
+
CONFIGURATION_KEYS.each { |param| expect(params.key?(param)).to be true }
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
describe
|
205
|
-
platform_tags = [
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
204
|
+
describe '#platform_data' do
|
205
|
+
platform_tags = %w[
|
206
|
+
osx-10.15-x86_64
|
207
|
+
osx-11-x86_64
|
208
|
+
ubuntu-18.04-amd64
|
209
|
+
el-6-x86_64
|
210
|
+
el-7-ppc64le
|
211
|
+
sles-12-x86_64
|
212
212
|
]
|
213
213
|
|
214
|
-
artifacts =
|
214
|
+
artifacts =
|
215
215
|
"./artifacts/apple/10.15/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx10.15.dmg\n" \
|
216
216
|
"./artifacts/apple/11/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx11.dmg\n" \
|
217
217
|
"./artifacts/deb/bionic/PC1/puppet-agent_5.3.2-1bionic_amd64.deb\n" \
|
@@ -257,27 +257,27 @@ describe "Pkg::Config" do
|
|
257
257
|
allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return([])
|
258
258
|
end
|
259
259
|
|
260
|
-
it
|
260
|
+
it 'should return a hash mapping platform tags to paths' do
|
261
261
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(artifacts, nil)
|
262
262
|
expect(Pkg::Config.platform_data.keys).to eql(platform_tags)
|
263
263
|
end
|
264
264
|
|
265
|
-
it
|
265
|
+
it 'should return nil if project isn\'t set' do
|
266
266
|
allow(Pkg::Config).to receive(:project).and_return(nil)
|
267
267
|
expect(Pkg::Config.platform_data).to be_nil
|
268
268
|
end
|
269
269
|
|
270
|
-
it
|
270
|
+
it 'should return nil if ref isn\'t set' do
|
271
271
|
allow(Pkg::Config).to receive(:ref).and_return(nil)
|
272
272
|
expect(Pkg::Config.platform_data).to be_nil
|
273
273
|
end
|
274
274
|
|
275
|
-
it
|
275
|
+
it 'should return nil if can\'t connect to build server' do
|
276
276
|
allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return(['something'])
|
277
277
|
expect(Pkg::Config.platform_data).to be_nil
|
278
278
|
end
|
279
279
|
|
280
|
-
it
|
280
|
+
it 'should not use \'f\' in fedora platform tags' do
|
281
281
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(fedora_artifacts, nil)
|
282
282
|
data = Pkg::Config.platform_data
|
283
283
|
expect(data).to include('fedora-36-x86_64')
|
@@ -287,28 +287,39 @@ describe "Pkg::Config" do
|
|
287
287
|
it "should collect packages whose extname differ from package_format" do
|
288
288
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(solaris_artifacts, nil)
|
289
289
|
data = Pkg::Config.platform_data
|
290
|
-
expect(data).to include(
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
290
|
+
expect(data).to include(
|
291
|
+
'solaris-10-i386' => {
|
292
|
+
artifact: './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz',
|
293
|
+
repo_config: nil
|
294
|
+
}
|
295
|
+
)
|
296
|
+
expect(data).to include(
|
297
|
+
'solaris-11-sparc' => {
|
298
|
+
artifact: './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p',
|
299
|
+
repo_config: nil
|
300
|
+
}
|
301
|
+
)
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should collect versioned msis' do
|
295
305
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(windows_artifacts, nil)
|
296
306
|
data = Pkg::Config.platform_data
|
297
|
-
expect(data['windows-2012-x86']).to include(:
|
298
|
-
expect(data['windows-2012-x64']).to include(:
|
299
|
-
expect(data['windowsfips-2012-x64']).to include(:
|
307
|
+
expect(data['windows-2012-x86']).to include(artifact: './windows/puppet-agent-5.3.2-x86.msi')
|
308
|
+
expect(data['windows-2012-x64']).to include(artifact: './windows/puppet-agent-5.3.2-x64.msi')
|
309
|
+
expect(data['windowsfips-2012-x64']).to include(artifact: './windowsfips/puppet-agent-5.3.2-x64.msi')
|
300
310
|
end
|
301
311
|
|
302
|
-
it
|
312
|
+
it 'should not collect debug packages' do
|
303
313
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(buster_artifacts, nil)
|
304
314
|
data = Pkg::Config.platform_data
|
305
|
-
expect(data['debian-10-amd64']).to include(:
|
315
|
+
expect(data['debian-10-amd64']).to include(artifact: './deb/buster/PC1/puppet-agent_5.3.2.658.gc79ef9a-1buster_amd64.deb')
|
306
316
|
end
|
307
317
|
|
308
|
-
it
|
309
|
-
allow(Pkg::Util::Net).to receive(:remote_execute)
|
318
|
+
it 'should collect packages that don\'t match the project name' do
|
319
|
+
allow(Pkg::Util::Net).to receive(:remote_execute)
|
320
|
+
.and_return(artifacts_not_matching_project, nil)
|
310
321
|
data = Pkg::Config.platform_data
|
311
|
-
expect(data['ubuntu-18.04-amd64']).to include(:
|
322
|
+
expect(data['ubuntu-18.04-amd64']).to include(artifact: './deb/bionic/pe-postgresql-contrib_2019.1.9.6.12-1bionic_amd64.deb')
|
312
323
|
expect(data['ubuntu-18.04-amd64'][:additional_artifacts].size).to eq(3)
|
313
324
|
expect(data['ubuntu-18.04-amd64'][:additional_artifacts]).to include('./deb/bionic/pe-postgresql-devel_2019.1.9.6.12-1bionic_amd64.deb')
|
314
325
|
expect(data['ubuntu-18.04-amd64'][:additional_artifacts]).to include('./deb/bionic/pe-postgresql-server_2019.1.9.6.12-1bionic_amd64.deb')
|
@@ -318,162 +329,170 @@ describe "Pkg::Config" do
|
|
318
329
|
it "should use 'ppc' instead of 'power' in aix paths" do
|
319
330
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
|
320
331
|
data = Pkg::Config.platform_data
|
321
|
-
expect(data['aix-7.1-power']).to include(:
|
332
|
+
expect(data['aix-7.1-power']).to include(artifact: './aix/7.1/PC1/ppc/puppet-agent-5.3.2-1.aix7.1.ppc.rpm')
|
322
333
|
end
|
323
334
|
|
324
|
-
it
|
335
|
+
it 'should not record an aix repo config' do
|
325
336
|
allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
|
326
337
|
data = Pkg::Config.platform_data
|
327
338
|
expect(data['aix-7.1-power'][:repo_config]).to be_nil
|
328
339
|
end
|
329
340
|
end
|
330
341
|
|
331
|
-
describe
|
332
|
-
it
|
342
|
+
describe '#config_to_yaml' do
|
343
|
+
it 'should write a valid yaml file' do
|
333
344
|
file = double('file')
|
334
|
-
File.
|
335
|
-
file.
|
336
|
-
YAML.
|
345
|
+
expect(File).to receive(:open).with(anything, 'w').and_yield(file)
|
346
|
+
expect(file).to receive(:puts).with(instance_of(String))
|
347
|
+
expect(YAML).to receive(:load_file).with(file)
|
337
348
|
expect { YAML.load_file(file) }.to_not raise_error
|
338
349
|
Pkg::Config.config_to_yaml
|
339
350
|
end
|
340
351
|
end
|
341
352
|
|
342
|
-
describe
|
343
|
-
it
|
353
|
+
describe '#get_binding' do
|
354
|
+
it 'should return the binding of the Pkg::Config object' do
|
344
355
|
# test by eval'ing using the binding before and after setting a param
|
345
356
|
orig = Pkg::Config.apt_host
|
346
357
|
Pkg::Config.apt_host = "foo"
|
347
|
-
expect(eval(
|
358
|
+
expect(eval('@apt_host', Pkg::Config.get_binding, __FILE__, __LINE__)).to eq("foo")
|
348
359
|
Pkg::Config.apt_host = "bar"
|
349
|
-
expect(eval(
|
360
|
+
expect(eval('@apt_host', Pkg::Config.get_binding, __FILE__, __LINE__)).to eq("bar")
|
350
361
|
Pkg::Config.apt_host = orig
|
351
362
|
end
|
352
363
|
end
|
353
364
|
|
354
|
-
describe
|
355
|
-
context
|
356
|
-
it
|
365
|
+
describe '#config_from_yaml' do
|
366
|
+
context 'given a yaml file' do
|
367
|
+
it 'should, use it to set params' do
|
357
368
|
# apt_host: is set to "foo" in the fixture
|
358
369
|
orig = Pkg::Config.apt_host
|
359
|
-
Pkg::Config.apt_host =
|
370
|
+
Pkg::Config.apt_host = 'bar'
|
360
371
|
Pkg::Config.config_from_yaml(File.join(FIXTURES, 'config', 'ext', 'build_defaults.yaml'))
|
361
|
-
expect(Pkg::Config.apt_host).to eq(
|
372
|
+
expect(Pkg::Config.apt_host).to eq('foo')
|
362
373
|
Pkg::Config.apt_host = orig
|
363
374
|
end
|
364
375
|
end
|
365
376
|
end
|
366
377
|
|
367
378
|
describe "#string_to_array" do
|
368
|
-
|
369
|
-
context
|
370
|
-
it
|
379
|
+
sample_array = %w[FOO BAR ARR RAY]
|
380
|
+
context 'given a string with spaces in it' do
|
381
|
+
it 'should return an array containing the contents of that string' do
|
371
382
|
space_str = "FOO BAR ARR RAY"
|
372
|
-
expect(Pkg::Config.string_to_array(space_str)).to eq(
|
383
|
+
expect(Pkg::Config.string_to_array(space_str)).to eq(sample_array)
|
373
384
|
end
|
374
385
|
end
|
375
386
|
|
376
|
-
context
|
377
|
-
it
|
378
|
-
comma_str =
|
379
|
-
expect(Pkg::Config.string_to_array(comma_str)).to eq(
|
387
|
+
context 'given a string with commas in it' do
|
388
|
+
it 'should return an array containing the contents of that string' do
|
389
|
+
comma_str = 'FOO,BAR,ARR,RAY'
|
390
|
+
expect(Pkg::Config.string_to_array(comma_str)).to eq(sample_array)
|
380
391
|
end
|
381
392
|
end
|
382
393
|
|
383
|
-
context
|
384
|
-
it
|
385
|
-
semi_str =
|
386
|
-
expect(Pkg::Config.string_to_array(semi_str)).to eq(
|
394
|
+
context 'given a string with semicolons in it' do
|
395
|
+
it 'should return an array containing the contents of that string' do
|
396
|
+
semi_str = 'FOO;BAR;ARR;RAY'
|
397
|
+
expect(Pkg::Config.string_to_array(semi_str)).to eq(sample_array)
|
387
398
|
end
|
388
399
|
end
|
389
400
|
|
390
|
-
context
|
401
|
+
context 'given a string with multiple delimiters in it' do
|
391
402
|
delimiters = [',', ' ', ';']
|
392
|
-
|
393
|
-
|
403
|
+
sample_string = "FOO, BAR, ARR, ; RAY"
|
404
|
+
sample_array = Pkg::Config.string_to_array(sample_string)
|
394
405
|
|
395
|
-
it
|
396
|
-
expect(
|
406
|
+
it 'should not return the delimiters as array items' do
|
407
|
+
expect(sample_array).to_not include(*delimiters)
|
397
408
|
end
|
398
409
|
|
399
|
-
it
|
400
|
-
expect(
|
410
|
+
it 'should not contain empty strings' do
|
411
|
+
expect(sample_array).to_not include("\s")
|
401
412
|
end
|
402
413
|
|
403
|
-
it
|
404
|
-
expect(
|
414
|
+
it 'should still return the expected array' do
|
415
|
+
expect(sample_array).to eq(sample_array)
|
405
416
|
end
|
406
417
|
end
|
407
418
|
end
|
408
419
|
|
409
|
-
describe
|
420
|
+
describe '#cow_list' do
|
410
421
|
it "should return a list of the cows for a project" do
|
411
|
-
Pkg::Config.cows =
|
412
|
-
|
422
|
+
Pkg::Config.cows = %w[
|
423
|
+
base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow
|
424
|
+
base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-saucy-i386.cow
|
425
|
+
base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow
|
426
|
+
base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow
|
427
|
+
base-testing-amd64.cow base-trusty-i386.cow base-trusty-amd64.cow base-unstable-i386.cow
|
428
|
+
base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow
|
429
|
+
].join(' ')
|
430
|
+
|
431
|
+
expect(Pkg::Config.cow_list)
|
432
|
+
.to eq 'lucid precise quantal saucy sid squeeze stable testing trusty unstable wheezy'
|
413
433
|
end
|
414
434
|
end
|
415
435
|
|
416
|
-
describe
|
417
|
-
context
|
418
|
-
it
|
436
|
+
describe '#config' do
|
437
|
+
context 'given :format => :hash' do
|
438
|
+
it 'should call Pkg::Config.config_to_hash' do
|
419
439
|
expect(Pkg::Config).to receive(:config_to_hash)
|
420
|
-
Pkg::Config.config(:
|
440
|
+
Pkg::Config.config(target: nil, format: :hash)
|
421
441
|
end
|
422
442
|
end
|
423
443
|
|
424
|
-
context
|
425
|
-
it
|
444
|
+
context 'given :format => :yaml' do
|
445
|
+
it 'should call Pkg::Config.config_to_yaml if given :format => :yaml' do
|
426
446
|
expect(Pkg::Config).to receive(:config_to_yaml)
|
427
|
-
Pkg::Config.config(:
|
447
|
+
Pkg::Config.config(target: nil, format: :yaml)
|
428
448
|
end
|
429
449
|
end
|
430
450
|
end
|
431
451
|
|
432
|
-
describe
|
452
|
+
describe '#issue_reassignments' do
|
433
453
|
around do |example|
|
434
|
-
|
454
|
+
original_tar_host = Pkg::Config.tar_host
|
435
455
|
Pkg::Config.tar_host = nil
|
436
456
|
example.run
|
437
|
-
Pkg::Config.tar_host =
|
457
|
+
Pkg::Config.tar_host = original_tar_host
|
438
458
|
end
|
439
459
|
|
440
|
-
it
|
441
|
-
Pkg::Config.config_from_hash({ :
|
460
|
+
it 'should set tar_host to staging_server' do
|
461
|
+
Pkg::Config.config_from_hash({ staging_server: 'foo' })
|
442
462
|
Pkg::Config.issue_reassignments
|
443
|
-
Pkg::Config.tar_host.
|
463
|
+
expect(Pkg::Config.tar_host).to eq('foo')
|
444
464
|
end
|
445
465
|
end
|
446
466
|
|
447
|
-
describe
|
448
|
-
it
|
449
|
-
|
450
|
-
hash.should be_a(Hash)
|
467
|
+
describe '#config_to_hash' do
|
468
|
+
it 'should return a hash object' do
|
469
|
+
expect(Pkg::Config.config_to_hash).to be_a(Hash)
|
451
470
|
end
|
452
471
|
|
453
|
-
it
|
454
|
-
Pkg::Config.apt_host =
|
455
|
-
Pkg::Config.config_to_hash[:apt_host].
|
456
|
-
Pkg::Config.apt_host =
|
457
|
-
Pkg::Config.config_to_hash[:apt_host].
|
472
|
+
it 'should return a hash with the current parameters' do
|
473
|
+
Pkg::Config.apt_host = 'foo'
|
474
|
+
expect(Pkg::Config.config_to_hash[:apt_host]).to eq('foo')
|
475
|
+
Pkg::Config.apt_host = 'bar'
|
476
|
+
expect(Pkg::Config.config_to_hash[:apt_host]).to eq('bar')
|
458
477
|
end
|
459
478
|
end
|
460
479
|
|
461
|
-
describe
|
480
|
+
describe '#load_default_configs' do
|
462
481
|
before(:each) do
|
463
|
-
@project_root =
|
482
|
+
@project_root = 'project_root'
|
464
483
|
Pkg::Config.project_root = @project_root
|
465
484
|
@test_project_data = File.join(Pkg::Config.project_root, 'ext', 'project_data.yaml')
|
466
485
|
@test_build_defaults = File.join(Pkg::Config.project_root, 'ext', 'build_defaults.yaml')
|
467
486
|
end
|
468
487
|
|
469
488
|
around do |example|
|
470
|
-
|
489
|
+
project_root_save = Pkg::Config.project_root
|
471
490
|
example.run
|
472
|
-
Pkg::Config.project_root =
|
491
|
+
Pkg::Config.project_root = project_root_save
|
473
492
|
end
|
474
493
|
|
475
|
-
context
|
476
|
-
it
|
494
|
+
context 'given ext/build_defaults.yaml and ext/project_data.yaml are readable' do
|
495
|
+
it 'should try to load build_defaults.yaml and project_data.yaml' do
|
477
496
|
allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
|
478
497
|
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
|
479
498
|
expect(Pkg::Config).to receive(:config_from_yaml).with(@test_project_data)
|
@@ -482,8 +501,8 @@ describe "Pkg::Config" do
|
|
482
501
|
end
|
483
502
|
end
|
484
503
|
|
485
|
-
context
|
486
|
-
it
|
504
|
+
context 'given ext/build_defaults.yaml is readable but ext/project_data.yaml is not' do
|
505
|
+
it 'should try to load build_defaults.yaml but not project_data.yaml' do
|
487
506
|
allow(File).to receive(:readable?).with(@test_project_data).and_return(false)
|
488
507
|
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
|
489
508
|
expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_project_data)
|
@@ -492,8 +511,8 @@ describe "Pkg::Config" do
|
|
492
511
|
end
|
493
512
|
end
|
494
513
|
|
495
|
-
context
|
496
|
-
it
|
514
|
+
context 'given ext/build_defaults.yaml is not readable but ext/project_data.yaml is' do
|
515
|
+
it 'should try to load build_defaults.yaml then unset project_root' do
|
497
516
|
allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
|
498
517
|
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(false)
|
499
518
|
expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_build_defaults)
|
@@ -502,14 +521,14 @@ describe "Pkg::Config" do
|
|
502
521
|
end
|
503
522
|
end
|
504
523
|
|
505
|
-
context
|
506
|
-
it
|
524
|
+
context 'given ext/build_defaults.yaml and ext/project_data.yaml are not readable' do
|
525
|
+
it 'should not try to load build_defaults.yaml and project_data.yaml' do
|
507
526
|
Pkg::Config.project_root = 'foo'
|
508
527
|
expect(Pkg::Config).to_not receive(:config_from_yaml)
|
509
528
|
Pkg::Config.load_default_configs
|
510
529
|
end
|
511
530
|
|
512
|
-
it
|
531
|
+
it 'should set the project root to nil' do
|
513
532
|
Pkg::Config.project_root = 'foo'
|
514
533
|
Pkg::Config.load_default_configs
|
515
534
|
expect(Pkg::Config.project_root).to be_nil
|
@@ -517,17 +536,17 @@ describe "Pkg::Config" do
|
|
517
536
|
end
|
518
537
|
end
|
519
538
|
|
520
|
-
describe
|
539
|
+
describe '#load_versioning' do
|
521
540
|
around do |example|
|
522
|
-
|
541
|
+
project_root_save = Pkg::Config.project_root
|
523
542
|
example.run
|
524
|
-
Pkg::Config.project_root =
|
543
|
+
Pkg::Config.project_root = project_root_save
|
525
544
|
end
|
526
545
|
|
527
546
|
# We let the actual version determination testing happen in the version
|
528
547
|
# tests. Here we just test that we try when we should.
|
529
|
-
context
|
530
|
-
it
|
548
|
+
context 'When project root is nil' do
|
549
|
+
it 'should not try to load versioning' do
|
531
550
|
Pkg::Config.project_root = nil
|
532
551
|
expect(Pkg::Util::Version).to_not receive(:git_sha_or_tag)
|
533
552
|
Pkg::Config.load_versioning
|
@@ -535,38 +554,40 @@ describe "Pkg::Config" do
|
|
535
554
|
end
|
536
555
|
end
|
537
556
|
|
538
|
-
describe
|
557
|
+
describe '#load_envvars' do
|
539
558
|
# We're going to pollute the environment with this test, so afterwards we
|
540
559
|
# explicitly set everything to nil to prevent any hazardous effects on
|
541
560
|
# the rest of the tests.
|
542
561
|
after(:all) do
|
543
|
-
reset_env(Pkg::Params::ENV_VARS.map {|hash| hash[:envvar].to_s})
|
562
|
+
reset_env(Pkg::Params::ENV_VARS.map { |hash| hash[:envvar].to_s })
|
544
563
|
end
|
545
564
|
|
546
565
|
Pkg::Params::ENV_VARS.each do |v|
|
547
566
|
case v[:type]
|
548
567
|
when :bool
|
549
568
|
it "should set boolean value on #{v[:var]} for :type == :bool" do
|
550
|
-
ENV[v[:envvar].to_s] =
|
551
|
-
Pkg::Util.
|
569
|
+
ENV[v[:envvar].to_s] = 'FOO'
|
570
|
+
allow(Pkg::Util).to receive(:boolean_value).and_return('FOO')
|
552
571
|
allow(Pkg::Config).to receive(:instance_variable_set)
|
553
|
-
expect(Pkg::Util).to receive(:boolean_value).with(
|
554
|
-
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}",
|
572
|
+
expect(Pkg::Util).to receive(:boolean_value).with('FOO')
|
573
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", 'FOO')
|
555
574
|
Pkg::Config.load_envvars
|
556
575
|
end
|
557
576
|
when :array
|
558
577
|
it "should set Pkg::Config##{v[:var]} to an Array for :type == :array" do
|
559
|
-
ENV[v[:envvar].to_s] =
|
560
|
-
Pkg::Config.
|
578
|
+
ENV[v[:envvar].to_s] = 'FOO BAR ARR RAY'
|
579
|
+
allow(Pkg::Config).to receive(:string_to_array).and_return(%w[FOO BAR ARR RAY])
|
561
580
|
allow(Pkg::Config).to receive(:instance_variable_set)
|
562
|
-
expect(Pkg::Config).to receive(:string_to_array).with(
|
563
|
-
expect(Pkg::Config)
|
581
|
+
expect(Pkg::Config).to receive(:string_to_array).with('FOO BAR ARR RAY')
|
582
|
+
expect(Pkg::Config)
|
583
|
+
.to receive(:instance_variable_set)
|
584
|
+
.with("@#{v[:var]}", %w[FOO BAR ARR RAY])
|
564
585
|
Pkg::Config.load_envvars
|
565
586
|
end
|
566
587
|
else
|
567
588
|
it "should set Pkg::Config##{v[:var]} to ENV[#{v[:envvar].to_s}]" do
|
568
589
|
ENV[v[:envvar].to_s] = "FOO"
|
569
|
-
Pkg::Util.
|
590
|
+
allow(Pkg::Util).to receive(:boolean_value).and_return('FOO')
|
570
591
|
allow(Pkg::Config).to receive(:instance_variable_set)
|
571
592
|
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO")
|
572
593
|
Pkg::Config.load_envvars
|