omnibus 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/CHANGELOG.md +21 -0
  4. data/Gemfile +8 -5
  5. data/README.md +3 -1
  6. data/Rakefile +20 -13
  7. data/appveyor.yml +4 -3
  8. data/bin/omnibus +3 -3
  9. data/features/commands/manifest.feature +19 -5
  10. data/features/step_definitions/generator_steps.rb +5 -6
  11. data/features/support/env.rb +4 -4
  12. data/lib/omnibus/build_version.rb +14 -14
  13. data/lib/omnibus/build_version_dsl.rb +3 -3
  14. data/lib/omnibus/builder.rb +50 -61
  15. data/lib/omnibus/changelog.rb +2 -2
  16. data/lib/omnibus/changelog_printer.rb +4 -4
  17. data/lib/omnibus/cleaner.rb +4 -4
  18. data/lib/omnibus/cli/base.rb +15 -15
  19. data/lib/omnibus/cli/cache.rb +13 -13
  20. data/lib/omnibus/cli/changelog.rb +8 -9
  21. data/lib/omnibus/cli/publish.rb +12 -13
  22. data/lib/omnibus/cli.rb +26 -27
  23. data/lib/omnibus/compressor.rb +6 -6
  24. data/lib/omnibus/compressors/base.rb +7 -2
  25. data/lib/omnibus/compressors/dmg.rb +12 -12
  26. data/lib/omnibus/compressors/null.rb +1 -1
  27. data/lib/omnibus/compressors/tgz.rb +8 -8
  28. data/lib/omnibus/config.rb +37 -26
  29. data/lib/omnibus/core_extensions/open_uri.rb +3 -3
  30. data/lib/omnibus/core_extensions.rb +1 -1
  31. data/lib/omnibus/digestable.rb +5 -4
  32. data/lib/omnibus/download_helpers.rb +7 -6
  33. data/lib/omnibus/exceptions.rb +29 -13
  34. data/lib/omnibus/fetcher.rb +0 -1
  35. data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
  36. data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
  37. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  38. data/lib/omnibus/file_syncer.rb +3 -3
  39. data/lib/omnibus/generator.rb +60 -47
  40. data/lib/omnibus/git_cache.rb +33 -22
  41. data/lib/omnibus/git_repository.rb +5 -5
  42. data/lib/omnibus/health_check.rb +122 -119
  43. data/lib/omnibus/instrumentation.rb +1 -1
  44. data/lib/omnibus/licensing.rb +348 -60
  45. data/lib/omnibus/logger.rb +12 -9
  46. data/lib/omnibus/logging.rb +1 -1
  47. data/lib/omnibus/manifest.rb +4 -4
  48. data/lib/omnibus/manifest_diff.rb +6 -7
  49. data/lib/omnibus/manifest_entry.rb +1 -1
  50. data/lib/omnibus/metadata.rb +36 -36
  51. data/lib/omnibus/ohai.rb +6 -7
  52. data/lib/omnibus/package.rb +1 -1
  53. data/lib/omnibus/packager.rb +37 -28
  54. data/lib/omnibus/packagers/appx.rb +86 -0
  55. data/lib/omnibus/packagers/base.rb +21 -18
  56. data/lib/omnibus/packagers/bff.rb +22 -24
  57. data/lib/omnibus/packagers/deb.rb +20 -20
  58. data/lib/omnibus/packagers/ips.rb +18 -17
  59. data/lib/omnibus/packagers/makeself.rb +7 -7
  60. data/lib/omnibus/packagers/msi.rb +38 -193
  61. data/lib/omnibus/packagers/pkg.rb +16 -16
  62. data/lib/omnibus/packagers/rpm.rb +53 -54
  63. data/lib/omnibus/packagers/solaris.rb +14 -14
  64. data/lib/omnibus/packagers/windows_base.rb +192 -0
  65. data/lib/omnibus/project.rb +45 -43
  66. data/lib/omnibus/publisher.rb +3 -3
  67. data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
  68. data/lib/omnibus/publishers/s3_publisher.rb +7 -7
  69. data/lib/omnibus/reports.rb +10 -10
  70. data/lib/omnibus/s3_cache.rb +7 -7
  71. data/lib/omnibus/s3_helpers.rb +8 -7
  72. data/lib/omnibus/semantic_version.rb +1 -1
  73. data/lib/omnibus/software.rb +131 -81
  74. data/lib/omnibus/sugarable.rb +10 -10
  75. data/lib/omnibus/templating.rb +5 -5
  76. data/lib/omnibus/thread_pool.rb +1 -1
  77. data/lib/omnibus/util.rb +5 -5
  78. data/lib/omnibus/version.rb +1 -1
  79. data/lib/omnibus.rb +65 -65
  80. data/omnibus.gemspec +34 -32
  81. data/resources/appx/AppxManifest.xml.erb +18 -0
  82. data/resources/appx/assets/clear.png +0 -0
  83. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
  84. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
  85. data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
  86. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
  87. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
  88. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
  89. data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
  90. data/spec/functional/builder_spec.rb +149 -150
  91. data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
  92. data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
  93. data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
  94. data/spec/functional/file_syncer_spec.rb +74 -74
  95. data/spec/functional/licensing_spec.rb +344 -35
  96. data/spec/functional/templating_spec.rb +17 -17
  97. data/spec/spec_helper.rb +20 -20
  98. data/spec/support/examples.rb +21 -15
  99. data/spec/support/file_helpers.rb +1 -1
  100. data/spec/support/git_helpers.rb +37 -37
  101. data/spec/support/matchers.rb +3 -3
  102. data/spec/support/ohai_helpers.rb +4 -4
  103. data/spec/support/path_helpers.rb +2 -2
  104. data/spec/support/shell_helpers.rb +2 -2
  105. data/spec/unit/build_version_dsl_spec.rb +5 -5
  106. data/spec/unit/build_version_spec.rb +63 -63
  107. data/spec/unit/builder_spec.rb +86 -70
  108. data/spec/unit/changelog_spec.rb +4 -4
  109. data/spec/unit/changelogprinter_spec.rb +130 -0
  110. data/spec/unit/cleanroom_spec.rb +11 -11
  111. data/spec/unit/compressor_spec.rb +16 -16
  112. data/spec/unit/compressors/base_spec.rb +6 -6
  113. data/spec/unit/compressors/dmg_spec.rb +76 -76
  114. data/spec/unit/compressors/null_spec.rb +4 -4
  115. data/spec/unit/compressors/tgz_spec.rb +20 -20
  116. data/spec/unit/config_spec.rb +44 -43
  117. data/spec/unit/digestable_spec.rb +13 -13
  118. data/spec/unit/fetcher_spec.rb +11 -12
  119. data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
  120. data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
  121. data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
  122. data/spec/unit/generator_spec.rb +38 -38
  123. data/spec/unit/git_cache_spec.rb +56 -54
  124. data/spec/unit/git_repository_spec.rb +2 -2
  125. data/spec/unit/health_check_spec.rb +40 -40
  126. data/spec/unit/library_spec.rb +35 -35
  127. data/spec/unit/manifest_diff_spec.rb +10 -11
  128. data/spec/unit/manifest_spec.rb +17 -17
  129. data/spec/unit/metadata_spec.rb +152 -152
  130. data/spec/unit/ohai_spec.rb +5 -5
  131. data/spec/unit/omnibus_spec.rb +31 -31
  132. data/spec/unit/package_spec.rb +20 -20
  133. data/spec/unit/packager_spec.rb +48 -42
  134. data/spec/unit/packagers/appx_spec.rb +165 -0
  135. data/spec/unit/packagers/base_spec.rb +34 -34
  136. data/spec/unit/packagers/bff_spec.rb +60 -60
  137. data/spec/unit/packagers/deb_spec.rb +71 -71
  138. data/spec/unit/packagers/ips_spec.rb +45 -45
  139. data/spec/unit/packagers/makeself_spec.rb +22 -22
  140. data/spec/unit/packagers/msi_spec.rb +141 -147
  141. data/spec/unit/packagers/pkg_spec.rb +59 -60
  142. data/spec/unit/packagers/rpm_spec.rb +125 -126
  143. data/spec/unit/packagers/solaris_spec.rb +52 -52
  144. data/spec/unit/project_spec.rb +137 -135
  145. data/spec/unit/publisher_spec.rb +70 -70
  146. data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
  147. data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
  148. data/spec/unit/s3_cacher_spec.rb +34 -34
  149. data/spec/unit/s3_helpers_spec.rb +6 -6
  150. data/spec/unit/semantic_version_spec.rb +2 -2
  151. data/spec/unit/software_spec.rb +346 -384
  152. data/spec/unit/sugarable_spec.rb +10 -10
  153. data/spec/unit/util_spec.rb +60 -60
  154. metadata +54 -6
  155. data/.rubocop.yml +0 -48
@@ -5,9 +5,10 @@ module Omnibus
5
5
  let(:license) { nil }
6
6
  let(:license_file_path) { nil }
7
7
  let(:license_file) { nil }
8
+ let(:zlib_version_override) { nil }
8
9
 
9
- let(:install_dir) { File.join(tmp_path, "install_dir")}
10
- let(:software_project_dir) { File.join(tmp_path, "software_project_dir")}
10
+ let(:install_dir) { File.join(tmp_path, "install_dir") }
11
+ let(:software_project_dir) { File.join(tmp_path, "software_project_dir") }
11
12
 
12
13
  let(:expected_project_license_path) { "LICENSE" }
13
14
  let(:expected_project_license) { "Unspecified" }
@@ -18,7 +19,7 @@ module Omnibus
18
19
  FileUtils.mkdir_p(software_project_dir)
19
20
 
20
21
  allow_any_instance_of(Software).to receive(:project_dir).and_return(software_project_dir)
21
- %w{LICENSE NOTICE}.each do |file|
22
+ %w{LICENSE NOTICE APACHE}.each do |file|
22
23
  File.open(File.join(software_project_dir, file), "w+") do |f|
23
24
  f.puts "This file is #{file}."
24
25
  end
@@ -35,11 +36,16 @@ module Omnibus
35
36
  expect(project_license).to match /#{expected_project_license_content}/
36
37
  expect(project_license).to match /This product bundles private_code 1.7.2,\nwhich is available under a "Unspecified"/
37
38
  expect(project_license).to match /This product bundles snoopy 1.0.0,\nwhich is available under a "GPL v2"/
38
- expect(project_license).to match /This product bundles zlib 1.7.2,\nwhich is available under a "Zlib"/
39
39
  expect(project_license).not_to match /preparation/
40
40
  expect(project_license).to match /LICENSES\/snoopy-artistic.html/
41
41
  expect(project_license).to match /LICENSES\/snoopy-NOTICE/
42
- expect(project_license).to match /LICENSES\/zlib-LICENSE/
42
+ if zlib_version_override
43
+ expect(project_license).to match /This product bundles zlib 1.8.0,\nwhich is available under a "Apache-2.0"/
44
+ expect(project_license).to match /LICENSES\/zlib-APACHE/
45
+ else
46
+ expect(project_license).to match /This product bundles zlib 1.7.2,\nwhich is available under a "Zlib"/
47
+ expect(project_license).to match /LICENSES\/zlib-LICENSE/
48
+ end
43
49
  end
44
50
 
45
51
  it "creates the license files of software components correctly" do
@@ -47,9 +53,17 @@ module Omnibus
47
53
  license_dir = File.join(install_dir, "LICENSES")
48
54
  expect(Dir.glob("#{license_dir}/**/*").length).to be(3)
49
55
 
50
- %w{snoopy-NOTICE zlib-LICENSE}.each do |software_license|
56
+ license_names = [ "snoopy-NOTICE" ]
57
+ if zlib_version_override
58
+ license_names << "zlib-APACHE"
59
+ else
60
+ license_names << "zlib-LICENSE"
61
+ end
62
+
63
+ license_names.each do |software_license|
51
64
  license_path = File.join(license_dir, software_license)
52
65
  expect(File.exist?(license_path)).to be(true)
66
+ expect(File.world_readable?(license_path)).to be_truthy
53
67
  expect(File.read(license_path)).to match /#{software_license.split("-").last}/
54
68
  end
55
69
 
@@ -72,35 +86,48 @@ module Omnibus
72
86
 
73
87
  let(:project) do
74
88
  Project.new.tap do |project|
75
- project.name('test-project')
89
+ project.name("test-project")
76
90
  project.install_dir(install_dir)
77
91
  project.license(license) unless license.nil?
78
92
  project.license_file_path(license_file_path) unless license_file_path.nil?
79
93
  project.license_file(license_file) unless license_file.nil?
80
- project.build_version('1.2.3')
94
+ project.build_version("1.2.3")
95
+ if zlib_version_override
96
+ project.override :zlib, version: zlib_version_override
97
+ end
81
98
  end
82
99
  end
83
100
 
84
101
  let(:private_code) do
85
- Software.new(project, 'private_code.rb').evaluate do
86
- name 'private_code'
87
- default_version '1.7.2'
102
+ Software.new(project, "private_code.rb").evaluate do
103
+ name "private_code"
104
+ default_version "1.7.2"
105
+ skip_transitive_dependency_licensing true
88
106
  end
89
107
  end
90
108
 
91
109
  let(:zlib) do
92
- Software.new(project, 'zlib.rb').evaluate do
93
- name 'zlib'
94
- default_version '1.7.2'
110
+ Software.new(project, "zlib.rb").evaluate do
111
+ name "zlib"
112
+ default_version "1.7.2"
113
+ skip_transitive_dependency_licensing true
114
+
95
115
  license "Zlib"
96
116
  license_file "LICENSE"
117
+
118
+ version "1.8.0" do
119
+ license "Apache-2.0"
120
+ license_file "APACHE"
121
+ end
97
122
  end
98
123
  end
99
124
 
100
125
  let(:snoopy) do
101
- Software.new(project, 'snoopy.rb').evaluate do
102
- name 'snoopy'
103
- default_version '1.0.0'
126
+ Software.new(project, "snoopy.rb").evaluate do
127
+ name "snoopy"
128
+ default_version "1.0.0"
129
+ skip_transitive_dependency_licensing true
130
+
104
131
  license "GPL v2"
105
132
  license_file "http://dev.perl.org/licenses/artistic.html"
106
133
  license_file "NOTICE"
@@ -108,23 +135,51 @@ module Omnibus
108
135
  end
109
136
 
110
137
  let(:preparation) do
111
- Software.new(project, 'preparation.rb').evaluate do
112
- name 'preparation'
113
- default_version '1.0.0'
138
+ Software.new(project, "preparation.rb").evaluate do
139
+ name "preparation"
140
+ default_version "1.0.0"
114
141
  license :project_license
142
+ skip_transitive_dependency_licensing true
115
143
  end
116
144
  end
117
145
 
118
146
  let(:software_with_warnings) { nil }
119
147
 
148
+ let(:softwares) do
149
+ s = [preparation, snoopy, zlib, private_code]
150
+ s << software_with_warnings if software_with_warnings
151
+ s
152
+ end
153
+
120
154
  def create_licenses
121
- project.library.component_added(preparation)
122
- project.library.component_added(snoopy)
123
- project.library.component_added(zlib)
124
- project.library.component_added(private_code)
125
- project.library.component_added(software_with_warnings) if software_with_warnings
155
+ softwares.each { |s| project.library.component_added(s) }
156
+
157
+ Licensing.create_incrementally(project) do |licensing|
158
+ project.softwares.each do |software|
159
+ licensing.execute_post_build(software)
160
+ end
161
+ end
162
+ end
163
+
164
+ describe "prepare step" do
165
+
166
+ let(:licenses_dir) { File.join(install_dir, "LICENSES") }
167
+ let(:dot_gitkeep) { File.join(licenses_dir, ".gitkeep") }
168
+ let(:cache_dir) { File.join(install_dir, "license-cache") }
169
+ let(:cache_dot_gitkeep) { File.join(cache_dir, ".gitkeep") }
170
+
171
+ it "creates a LICENSES dir with a .gitkeep file inside the install directory" do
172
+ Licensing.new(project).prepare
173
+ expect(File).to exist(licenses_dir)
174
+ expect(File).to exist(dot_gitkeep)
175
+ end
176
+
177
+ it "creates a licenses-cache dir with a .gitkeep file inside the install directory" do
178
+ Licensing.new(project).prepare
179
+ expect(File).to exist(cache_dir)
180
+ expect(File).to exist(cache_dot_gitkeep)
181
+ end
126
182
 
127
- Licensing.create!(project)
128
183
  end
129
184
 
130
185
  describe "without license definitions in the project" do
@@ -161,14 +216,21 @@ module Omnibus
161
216
  output = capture_logging { create_licenses }
162
217
  expect(output).to include("Project 'test-project' is using 'Custom Chef' which is not one of the standard licenses")
163
218
  end
219
+
220
+ context "with a version override" do
221
+ let(:zlib_version_override) { "1.8.0" }
222
+
223
+ it_behaves_like "correctly created licenses"
224
+ end
164
225
  end
165
226
 
166
227
  describe "with a local license file that does not exist" do
167
228
  let(:software_with_warnings) do
168
- Software.new(project, 'problematic.rb').evaluate do
169
- name 'problematic'
170
- default_version '0.10.2'
229
+ Software.new(project, "problematic.rb").evaluate do
230
+ name "problematic"
231
+ default_version "0.10.2"
171
232
  license_file "NOT_EXISTS"
233
+ skip_transitive_dependency_licensing true
172
234
  end
173
235
  end
174
236
 
@@ -186,10 +248,11 @@ module Omnibus
186
248
  end
187
249
 
188
250
  let(:software_with_warnings) do
189
- Software.new(project, 'problematic.rb').evaluate do
190
- name 'problematic'
191
- default_version '0.10.2'
251
+ Software.new(project, "problematic.rb").evaluate do
252
+ name "problematic"
253
+ default_version "0.10.2"
192
254
  license_file "https://downloads.chef.io/LICENSE"
255
+ skip_transitive_dependency_licensing true
193
256
  end
194
257
  end
195
258
 
@@ -204,10 +267,11 @@ module Omnibus
204
267
 
205
268
  describe "with a software with no license files" do
206
269
  let(:software_with_warnings) do
207
- Software.new(project, 'problematic.rb').evaluate do
208
- name 'problematic'
209
- default_version '0.10.2'
270
+ Software.new(project, "problematic.rb").evaluate do
271
+ name "problematic"
272
+ default_version "0.10.2"
210
273
  license "Zlib"
274
+ skip_transitive_dependency_licensing true
211
275
  end
212
276
  end
213
277
 
@@ -233,5 +297,250 @@ module Omnibus
233
297
  expect(output).to include("Project 'test-project' does not point to a license file.")
234
298
  end
235
299
  end
300
+
301
+ describe "with :fatal_licensing_warnings set and without license definitions in the project" do
302
+ before do
303
+ Omnibus::Config.fatal_licensing_warnings(true)
304
+ end
305
+
306
+ it "fails the omnibus build" do
307
+ expect { create_licenses }.to raise_error(Omnibus::LicensingError, /Project 'test-project' does not contain licensing information.\s{1,}Software 'private_code' does not contain licensing information./)
308
+ end
309
+ end
310
+
311
+ describe "when all software is setting skip_transitive_dependency_licensing " do
312
+ # This is achieved by the default values of the let() parameters
313
+
314
+ it "does not collect transitive licensing info for any software" do
315
+ softwares.each { |s| project.library.component_added(s) }
316
+
317
+ Licensing.create_incrementally(project) do |licensing|
318
+ expect(licensing).not_to receive(:collect_transitive_dependency_licenses_for)
319
+
320
+ project.softwares.each do |software|
321
+ licensing.execute_post_build(software)
322
+ end
323
+ end
324
+ end
325
+ end
326
+
327
+ describe "when a project has transitive dependencies" do
328
+ let(:license) { "Custom Chef" }
329
+ let(:license_file_path) { "CHEF.LICENSE" }
330
+ let(:license_file) { "CUSTOM_CHEF" }
331
+
332
+ let(:expected_project_license_path) { license_file_path }
333
+
334
+ let(:softwares) { [zlib] }
335
+
336
+ before do
337
+ File.open(File.join(Config.project_root, license_file), "w+") do |f|
338
+ f.puts "Chef Custom License is awesome."
339
+ end
340
+ end
341
+
342
+ after do
343
+ FileUtils.rm_rf(license_file)
344
+ end
345
+
346
+ let(:zlib) do
347
+ Software.new(project, "zlib.rb").evaluate do
348
+ name "zlib"
349
+ default_version "1.7.2"
350
+
351
+ license "Zlib"
352
+ license_file "LICENSE"
353
+ end
354
+ end
355
+
356
+ let(:snoopy) do
357
+ Software.new(project, "snoopy.rb").evaluate do
358
+ name "snoopy"
359
+ default_version "1.0.0"
360
+
361
+ license "GPL v2"
362
+ license_file "NOTICE"
363
+ end
364
+ end
365
+
366
+ let(:license_fixtures_path) { File.join(fixtures_path, "licensing/license_scout") }
367
+
368
+ describe "when project type is not supported" do
369
+
370
+ before do
371
+ allow_any_instance_of(LicenseScout::Collector).to receive(:run) do
372
+ raise LicenseScout::Exceptions::UnsupportedProjectType.new("/path/to/project")
373
+ end
374
+ end
375
+
376
+ it "does not raise an error" do
377
+ expect { create_licenses }.not_to raise_error
378
+ end
379
+
380
+ it "logs a warning message" do
381
+ output = capture_logging { create_licenses }
382
+ expect(output).to include("is not supported project type for transitive dependency license collection")
383
+ end
384
+
385
+ context "with :fatal_licensing_warnings" do
386
+
387
+ before do
388
+ Omnibus::Config.fatal_licensing_warnings(true)
389
+ end
390
+
391
+ it "does not fail omnibus build" do
392
+ expect { create_licenses }.not_to raise_error
393
+ end
394
+ end
395
+
396
+ context "with :fatal_transitive_dependency_licensing_warnings" do
397
+
398
+ before do
399
+ Omnibus::Config.fatal_transitive_dependency_licensing_warnings(true)
400
+ end
401
+
402
+ it "fails omnibus build" do
403
+ expect { create_licenses }.to raise_error(Omnibus::LicensingError, /is not supported project type for transitive dependency license collection/)
404
+ end
405
+ end
406
+ end
407
+
408
+ describe "when there are warnings in the licensing info" do
409
+ before do
410
+ allow_any_instance_of(LicenseScout::Collector).to receive(:run)
411
+ allow_any_instance_of(LicenseScout::Collector).to receive(:issue_report).and_return(["This is a licensing warning!!!"])
412
+ end
413
+
414
+ it "logs the warnings" do
415
+ output = capture_logging { create_licenses }
416
+ expect(output).to include("This is a licensing warning!!!")
417
+ end
418
+ end
419
+
420
+ describe "when there are no warnings in the licensing info" do
421
+ before do
422
+ allow_any_instance_of(LicenseScout::Collector).to receive(:run) do
423
+ FileUtils.cp_r(File.join(license_fixtures_path, "zlib"), File.join(install_dir, "license-cache/"))
424
+ end
425
+
426
+ allow_any_instance_of(LicenseScout::Collector).to receive(:issue_report).and_return([])
427
+ end
428
+
429
+ let(:expected_license_files) {
430
+ %w{
431
+ ruby_bundler-inifile-3.0.0-README.md
432
+ ruby_bundler-mime-types-3.1-Licence.rdoc
433
+ ruby_bundler-mini_portile2-2.1.0-LICENSE.txt
434
+ }
435
+ }
436
+
437
+ let(:expected_license_texts) {
438
+ [
439
+ <<-EOH,
440
+ This product includes inifile 3.0.0
441
+ which is a 'ruby_bundler' dependency of 'zlib',
442
+ and which is available under a 'MIT' License.
443
+ For details, see:
444
+ #{install_dir}/LICENSES/ruby_bundler-inifile-3.0.0-README.md
445
+ EOH
446
+ <<-EOH,
447
+ This product includes mime-types 3.1
448
+ which is a 'ruby_bundler' dependency of 'zlib',
449
+ and which is available under a 'MIT' License.
450
+ For details, see:
451
+ #{install_dir}/LICENSES/ruby_bundler-mime-types-3.1-Licence.rdoc
452
+ EOH
453
+ <<-EOH,
454
+ This product includes mini_portile2 2.1.0
455
+ which is a 'ruby_bundler' dependency of 'zlib',
456
+ and which is available under a 'MIT' License.
457
+ For details, see:
458
+ #{install_dir}/LICENSES/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt
459
+ EOH
460
+ ]
461
+ }
462
+
463
+ it "includes transitive dependency license information in the project license information" do
464
+ create_licenses
465
+
466
+ project_license = File.join(install_dir, expected_project_license_path)
467
+ expect(File.exist?(project_license)).to be(true)
468
+ project_license_content = File.read(project_license)
469
+
470
+ expected_license_texts.each { |t| expect(project_license_content).to include(t) }
471
+ expected_license_files.each { |f| expect(File).to exist(File.join(install_dir, "LICENSES", f)) }
472
+ expect(File).not_to exist(File.join(install_dir, "license-cache"))
473
+ end
474
+ end
475
+
476
+ describe "with multiple softwares that have dependencies" do
477
+ let(:softwares) { [zlib, snoopy] }
478
+
479
+ before do
480
+ allow_any_instance_of(LicenseScout::Collector).to receive(:run) do
481
+ FileUtils.cp_r(File.join(license_fixtures_path, "zlib"), File.join(install_dir, "license-cache/"))
482
+ FileUtils.cp_r(File.join(license_fixtures_path, "snoopy"), File.join(install_dir, "license-cache/"))
483
+ end
484
+
485
+ allow_any_instance_of(LicenseScout::Collector).to receive(:issue_report).and_return([])
486
+ end
487
+
488
+ let(:expected_license_files) {
489
+ %w{
490
+ ruby_bundler-inifile-3.0.0-README.md
491
+ ruby_bundler-mime-types-3.1-Licence.rdoc
492
+ ruby_bundler-mini_portile2-2.1.0-LICENSE.txt
493
+ }
494
+ }
495
+
496
+ let(:expected_license_texts) {
497
+ [
498
+ <<-EOH,
499
+ This product includes inifile 3.0.0
500
+ which is a 'ruby_bundler' dependency of 'snoopy', 'zlib',
501
+ and which is available under a 'MIT' License.
502
+ For details, see:
503
+ #{install_dir}/LICENSES/ruby_bundler-inifile-3.0.0-README.md
504
+ EOH
505
+ <<-EOH,
506
+ This product includes mime-types 3.1
507
+ which is a 'ruby_bundler' dependency of 'zlib',
508
+ and which is available under a 'MIT' License.
509
+ For details, see:
510
+ #{install_dir}/LICENSES/ruby_bundler-mime-types-3.1-Licence.rdoc
511
+ EOH
512
+ <<-EOH,
513
+ This product includes mini_portile2 2.1.0
514
+ which is a 'ruby_bundler' dependency of 'zlib',
515
+ and which is available under a 'MIT' License.
516
+ For details, see:
517
+ #{install_dir}/LICENSES/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt
518
+ EOH
519
+ <<-EOH,
520
+ This product includes bundler-audit 0.5.0
521
+ which is a 'ruby_bundler' dependency of 'snoopy',
522
+ and which is available under a 'GPLv3' License.
523
+ For details, see:
524
+ #{install_dir}/LICENSES/ruby_bundler-bundler-audit-0.5.0-COPYING.txt
525
+ EOH
526
+
527
+ ]
528
+ }
529
+
530
+ it "includes merged licensing information from multiple software definitions" do
531
+ create_licenses
532
+
533
+ project_license = File.join(install_dir, expected_project_license_path)
534
+ expect(File.exist?(project_license)).to be(true)
535
+ project_license_content = File.read(project_license)
536
+
537
+ expected_license_texts.each { |t| expect(project_license_content).to include(t) }
538
+ expected_license_files.each { |f| expect(File).to exist(File.join(install_dir, "LICENSES", f)) }
539
+ expect(File).not_to exist(File.join(install_dir, "license-cache"))
540
+ end
541
+
542
+ end
543
+
544
+ end
236
545
  end
237
546
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Omnibus
4
4
  class RandomClass
@@ -9,12 +9,12 @@ module Omnibus
9
9
  subject { RandomClass.new }
10
10
 
11
11
  describe '#render_template' do
12
- let(:source) { File.join(tmp_path, 'source.erb') }
13
- let(:destination) { File.join(tmp_path, 'final') }
12
+ let(:source) { File.join(tmp_path, "source.erb") }
13
+ let(:destination) { File.join(tmp_path, "final") }
14
14
  let(:mode) { 0644 }
15
- let(:variables) { { name: 'Name' } }
15
+ let(:variables) { { name: "Name" } }
16
16
  let(:contents) do
17
- <<-EOH.gsub(/^ {10}/, '')
17
+ <<-EOH.gsub(/^ {10}/, "")
18
18
  <%= name %>
19
19
 
20
20
  <% if false -%>
@@ -32,49 +32,49 @@ module Omnibus
32
32
  end
33
33
 
34
34
  before do
35
- File.open(source, 'w') { |f| f.write(contents) }
35
+ File.open(source, "w") { |f| f.write(contents) }
36
36
  end
37
37
 
38
- context 'when no destination is given' do
38
+ context "when no destination is given" do
39
39
  let(:destination) { nil }
40
40
 
41
- it 'renders adjacent, without the erb extension' do
41
+ it "renders adjacent, without the erb extension" do
42
42
  subject.render_template(source, options)
43
- expect(File.join(tmp_path, 'source')).to be_a_file
43
+ expect(File.join(tmp_path, "source")).to be_a_file
44
44
  end
45
45
  end
46
46
 
47
- context 'when a destination is given' do
48
- it 'renders at the destination' do
47
+ context "when a destination is given" do
48
+ it "renders at the destination" do
49
49
  subject.render_template(source, options)
50
50
  expect(destination).to be_a_file
51
51
  end
52
52
  end
53
53
 
54
- context 'when a mode is given', :not_supported_on_windows do
54
+ context "when a mode is given", :not_supported_on_windows do
55
55
  let(:mode) { 0755 }
56
56
 
57
- it 'renders the object with the mode' do
57
+ it "renders the object with the mode" do
58
58
  subject.render_template(source, options)
59
59
  expect(destination).to be_an_executable
60
60
  end
61
61
  end
62
62
 
63
- context 'when an undefined variable is used' do
63
+ context "when an undefined variable is used" do
64
64
  let(:contents) { "<%= not_a_real_variable %>" }
65
65
 
66
- it 'raise an exception' do
66
+ it "raise an exception" do
67
67
  expect do
68
68
  subject.render_template(source, options)
69
69
  end.to raise_error(NameError)
70
70
  end
71
71
  end
72
72
 
73
- context 'when no variables are present' do
73
+ context "when no variables are present" do
74
74
  let(:content) { "static content" }
75
75
  let(:variables) { {} }
76
76
 
77
- it 'renders the template' do
77
+ it "renders the template" do
78
78
  subject.render_template(source, options)
79
79
  expect(destination).to be_a_file
80
80
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,11 @@
1
- require 'rspec'
2
- require 'rspec/its'
1
+ require "rspec"
2
+ require "rspec/its"
3
3
  require "rspec/json_expectations"
4
- require 'webmock/rspec'
4
+ require "webmock/rspec"
5
5
 
6
- require 'cleanroom/rspec'
6
+ require "cleanroom/rspec"
7
7
 
8
- require 'omnibus'
8
+ require "omnibus"
9
9
 
10
10
  def windows?
11
11
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
@@ -17,31 +17,31 @@ end
17
17
 
18
18
  RSpec.configure do |config|
19
19
  # Custom matchers and shared examples
20
- require_relative 'support/examples'
21
- require_relative 'support/matchers'
20
+ require_relative "support/examples"
21
+ require_relative "support/matchers"
22
22
 
23
- require_relative 'support/env_helpers'
23
+ require_relative "support/env_helpers"
24
24
  config.include(Omnibus::RSpec::EnvHelpers)
25
25
 
26
- require_relative 'support/file_helpers'
26
+ require_relative "support/file_helpers"
27
27
  config.include(Omnibus::RSpec::FileHelpers)
28
28
 
29
- require_relative 'support/git_helpers'
29
+ require_relative "support/git_helpers"
30
30
  config.include(Omnibus::RSpec::GitHelpers)
31
31
 
32
- require_relative 'support/logging_helpers'
32
+ require_relative "support/logging_helpers"
33
33
  config.include(Omnibus::RSpec::LoggingHelpers)
34
34
 
35
- require_relative 'support/ohai_helpers'
35
+ require_relative "support/ohai_helpers"
36
36
  config.include(Omnibus::RSpec::OhaiHelpers)
37
37
 
38
- require_relative 'support/output_helpers'
38
+ require_relative "support/output_helpers"
39
39
  config.include(Omnibus::RSpec::OutputHelpers)
40
40
 
41
- require_relative 'support/path_helpers'
41
+ require_relative "support/path_helpers"
42
42
  config.include(Omnibus::RSpec::PathHelpers)
43
43
 
44
- require_relative 'support/shell_helpers'
44
+ require_relative "support/shell_helpers"
45
45
  config.include(Omnibus::RSpec::ShellHelpers)
46
46
 
47
47
  config.filter_run(focus: true)
@@ -55,7 +55,7 @@ RSpec.configure do |config|
55
55
  # Use the documentation formatter for detailed output,
56
56
  # unless a formatter has already been configured
57
57
  # (e.g. via a command-line flag).
58
- config.default_formatter = 'doc'
58
+ config.default_formatter = "doc"
59
59
  config.color = true
60
60
  end
61
61
 
@@ -72,7 +72,7 @@ RSpec.configure do |config|
72
72
  FileUtils.mkdir_p(tmp_path)
73
73
 
74
74
  # Don't run Ohai - tests can still override this
75
- stub_ohai(platform: 'ubuntu', version: '12.04')
75
+ stub_ohai(platform: "ubuntu", version: "12.04")
76
76
 
77
77
  # Default to real HTTP requests
78
78
  WebMock.allow_net_connect!
@@ -88,7 +88,7 @@ RSpec.configure do |config|
88
88
  end
89
89
 
90
90
  # Run specs in a random order
91
- config.order = 'random'
91
+ config.order = "random"
92
92
  end
93
93
 
94
94
  #
@@ -99,7 +99,7 @@ end
99
99
  # name 'foo'
100
100
  # EOH
101
101
  #
102
- RSpec.shared_examples 'a cleanroom setter' do |id, string|
102
+ RSpec.shared_examples "a cleanroom setter" do |id, string|
103
103
  it "for `#{id}'" do
104
104
  expect { subject.evaluate(string) }
105
105
  .to_not raise_error
@@ -112,7 +112,7 @@ end
112
112
  # @example
113
113
  # it_behaves_like 'a cleanroom getter', :name
114
114
  #
115
- RSpec.shared_examples 'a cleanroom getter' do |id|
115
+ RSpec.shared_examples "a cleanroom getter" do |id|
116
116
  it "for `#{id}'" do
117
117
  expect { subject.evaluate("#{id}") }.to_not raise_error
118
118
  end