omnibus 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +21 -0
- data/Gemfile +8 -5
- data/README.md +3 -1
- data/Rakefile +20 -13
- data/appveyor.yml +4 -3
- data/bin/omnibus +3 -3
- data/features/commands/manifest.feature +19 -5
- data/features/step_definitions/generator_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/lib/omnibus/build_version.rb +14 -14
- data/lib/omnibus/build_version_dsl.rb +3 -3
- data/lib/omnibus/builder.rb +50 -61
- data/lib/omnibus/changelog.rb +2 -2
- data/lib/omnibus/changelog_printer.rb +4 -4
- data/lib/omnibus/cleaner.rb +4 -4
- data/lib/omnibus/cli/base.rb +15 -15
- data/lib/omnibus/cli/cache.rb +13 -13
- data/lib/omnibus/cli/changelog.rb +8 -9
- data/lib/omnibus/cli/publish.rb +12 -13
- data/lib/omnibus/cli.rb +26 -27
- data/lib/omnibus/compressor.rb +6 -6
- data/lib/omnibus/compressors/base.rb +7 -2
- data/lib/omnibus/compressors/dmg.rb +12 -12
- data/lib/omnibus/compressors/null.rb +1 -1
- data/lib/omnibus/compressors/tgz.rb +8 -8
- data/lib/omnibus/config.rb +37 -26
- data/lib/omnibus/core_extensions/open_uri.rb +3 -3
- data/lib/omnibus/core_extensions.rb +1 -1
- data/lib/omnibus/digestable.rb +5 -4
- data/lib/omnibus/download_helpers.rb +7 -6
- data/lib/omnibus/exceptions.rb +29 -13
- data/lib/omnibus/fetcher.rb +0 -1
- data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
- data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +3 -3
- data/lib/omnibus/generator.rb +60 -47
- data/lib/omnibus/git_cache.rb +33 -22
- data/lib/omnibus/git_repository.rb +5 -5
- data/lib/omnibus/health_check.rb +122 -119
- data/lib/omnibus/instrumentation.rb +1 -1
- data/lib/omnibus/licensing.rb +348 -60
- data/lib/omnibus/logger.rb +12 -9
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/manifest.rb +4 -4
- data/lib/omnibus/manifest_diff.rb +6 -7
- data/lib/omnibus/manifest_entry.rb +1 -1
- data/lib/omnibus/metadata.rb +36 -36
- data/lib/omnibus/ohai.rb +6 -7
- data/lib/omnibus/package.rb +1 -1
- data/lib/omnibus/packager.rb +37 -28
- data/lib/omnibus/packagers/appx.rb +86 -0
- data/lib/omnibus/packagers/base.rb +21 -18
- data/lib/omnibus/packagers/bff.rb +22 -24
- data/lib/omnibus/packagers/deb.rb +20 -20
- data/lib/omnibus/packagers/ips.rb +18 -17
- data/lib/omnibus/packagers/makeself.rb +7 -7
- data/lib/omnibus/packagers/msi.rb +38 -193
- data/lib/omnibus/packagers/pkg.rb +16 -16
- data/lib/omnibus/packagers/rpm.rb +53 -54
- data/lib/omnibus/packagers/solaris.rb +14 -14
- data/lib/omnibus/packagers/windows_base.rb +192 -0
- data/lib/omnibus/project.rb +45 -43
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
- data/lib/omnibus/publishers/s3_publisher.rb +7 -7
- data/lib/omnibus/reports.rb +10 -10
- data/lib/omnibus/s3_cache.rb +7 -7
- data/lib/omnibus/s3_helpers.rb +8 -7
- data/lib/omnibus/semantic_version.rb +1 -1
- data/lib/omnibus/software.rb +131 -81
- data/lib/omnibus/sugarable.rb +10 -10
- data/lib/omnibus/templating.rb +5 -5
- data/lib/omnibus/thread_pool.rb +1 -1
- data/lib/omnibus/util.rb +5 -5
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus.rb +65 -65
- data/omnibus.gemspec +34 -32
- data/resources/appx/AppxManifest.xml.erb +18 -0
- data/resources/appx/assets/clear.png +0 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
- data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
- data/spec/functional/builder_spec.rb +149 -150
- data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
- data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
- data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
- data/spec/functional/file_syncer_spec.rb +74 -74
- data/spec/functional/licensing_spec.rb +344 -35
- data/spec/functional/templating_spec.rb +17 -17
- data/spec/spec_helper.rb +20 -20
- data/spec/support/examples.rb +21 -15
- data/spec/support/file_helpers.rb +1 -1
- data/spec/support/git_helpers.rb +37 -37
- data/spec/support/matchers.rb +3 -3
- data/spec/support/ohai_helpers.rb +4 -4
- data/spec/support/path_helpers.rb +2 -2
- data/spec/support/shell_helpers.rb +2 -2
- data/spec/unit/build_version_dsl_spec.rb +5 -5
- data/spec/unit/build_version_spec.rb +63 -63
- data/spec/unit/builder_spec.rb +86 -70
- data/spec/unit/changelog_spec.rb +4 -4
- data/spec/unit/changelogprinter_spec.rb +130 -0
- data/spec/unit/cleanroom_spec.rb +11 -11
- data/spec/unit/compressor_spec.rb +16 -16
- data/spec/unit/compressors/base_spec.rb +6 -6
- data/spec/unit/compressors/dmg_spec.rb +76 -76
- data/spec/unit/compressors/null_spec.rb +4 -4
- data/spec/unit/compressors/tgz_spec.rb +20 -20
- data/spec/unit/config_spec.rb +44 -43
- data/spec/unit/digestable_spec.rb +13 -13
- data/spec/unit/fetcher_spec.rb +11 -12
- data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
- data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
- data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
- data/spec/unit/generator_spec.rb +38 -38
- data/spec/unit/git_cache_spec.rb +56 -54
- data/spec/unit/git_repository_spec.rb +2 -2
- data/spec/unit/health_check_spec.rb +40 -40
- data/spec/unit/library_spec.rb +35 -35
- data/spec/unit/manifest_diff_spec.rb +10 -11
- data/spec/unit/manifest_spec.rb +17 -17
- data/spec/unit/metadata_spec.rb +152 -152
- data/spec/unit/ohai_spec.rb +5 -5
- data/spec/unit/omnibus_spec.rb +31 -31
- data/spec/unit/package_spec.rb +20 -20
- data/spec/unit/packager_spec.rb +48 -42
- data/spec/unit/packagers/appx_spec.rb +165 -0
- data/spec/unit/packagers/base_spec.rb +34 -34
- data/spec/unit/packagers/bff_spec.rb +60 -60
- data/spec/unit/packagers/deb_spec.rb +71 -71
- data/spec/unit/packagers/ips_spec.rb +45 -45
- data/spec/unit/packagers/makeself_spec.rb +22 -22
- data/spec/unit/packagers/msi_spec.rb +141 -147
- data/spec/unit/packagers/pkg_spec.rb +59 -60
- data/spec/unit/packagers/rpm_spec.rb +125 -126
- data/spec/unit/packagers/solaris_spec.rb +52 -52
- data/spec/unit/project_spec.rb +137 -135
- data/spec/unit/publisher_spec.rb +70 -70
- data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
- data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
- data/spec/unit/s3_cacher_spec.rb +34 -34
- data/spec/unit/s3_helpers_spec.rb +6 -6
- data/spec/unit/semantic_version_spec.rb +2 -2
- data/spec/unit/software_spec.rb +346 -384
- data/spec/unit/sugarable_spec.rb +10 -10
- data/spec/unit/util_spec.rb +60 -60
- metadata +54 -6
- data/.rubocop.yml +0 -48
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Builder do
|
5
|
-
include_examples
|
5
|
+
include_examples "a software"
|
6
6
|
|
7
7
|
#
|
8
8
|
# Fakes the embedded bin path to whatever exists in bundler. This is useful
|
@@ -19,11 +19,11 @@ module Omnibus
|
|
19
19
|
# corresponding to the system installation and hope it all works out.
|
20
20
|
def fake_embedded_bin(name)
|
21
21
|
if windows?
|
22
|
-
ext = name ==
|
22
|
+
ext = name == "ruby" ? ".exe" : ".bat"
|
23
23
|
source = Bundler.which(name + ext)
|
24
24
|
raise "Could not find #{name} in bundler environment" unless source
|
25
|
-
File.open(File.join(embedded_bin_dir, name +
|
26
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
25
|
+
File.open(File.join(embedded_bin_dir, name + ".bat"), "w") do |f|
|
26
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
27
27
|
@"#{source}" %*
|
28
28
|
EOH
|
29
29
|
end
|
@@ -40,18 +40,17 @@ module Omnibus
|
|
40
40
|
# Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
|
41
41
|
options = {}
|
42
42
|
options[:env] = {
|
43
|
-
|
44
|
-
|
43
|
+
"GEM_HOME" => ENV["GEM_HOME"],
|
44
|
+
"GEM_PATH" => ENV["GEM_PATH"],
|
45
45
|
}
|
46
46
|
options[:env].merge!(subject.with_embedded_path)
|
47
47
|
options
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
50
|
def make_gemspec()
|
52
51
|
gemspec = File.join(project_dir, "#{project_name}.gemspec")
|
53
|
-
File.open(gemspec,
|
54
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
52
|
+
File.open(gemspec, "w") do |f|
|
53
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
55
54
|
Gem::Specification.new do |gem|
|
56
55
|
gem.name = '#{project_name}'
|
57
56
|
gem.version = '1.0.0'
|
@@ -66,9 +65,9 @@ module Omnibus
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def make_gemfile()
|
69
|
-
gemfile = File.join(project_dir,
|
70
|
-
File.open(gemfile,
|
71
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
68
|
+
gemfile = File.join(project_dir, "Gemfile")
|
69
|
+
File.open(gemfile, "w") do |f|
|
70
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
72
71
|
gemspec
|
73
72
|
EOH
|
74
73
|
end
|
@@ -76,9 +75,9 @@ module Omnibus
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def make_gemfile_lock()
|
79
|
-
gemfile_lock = File.join(project_dir,
|
80
|
-
File.open(gemfile_lock,
|
81
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
78
|
+
gemfile_lock = File.join(project_dir, "Gemfile.lock")
|
79
|
+
File.open(gemfile_lock, "w") do |f|
|
80
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
82
81
|
PATH
|
83
82
|
remote: .
|
84
83
|
specs:
|
@@ -98,37 +97,37 @@ module Omnibus
|
|
98
97
|
end
|
99
98
|
|
100
99
|
subject { described_class.new(software) }
|
101
|
-
let(:project_name) {
|
100
|
+
let(:project_name) { "example" }
|
102
101
|
let(:project_dir) { File.join(source_dir, project_name) }
|
103
102
|
|
104
103
|
describe '#command' do
|
105
|
-
it
|
104
|
+
it "executes the command" do
|
106
105
|
subject.command("echo 'Hello World!'")
|
107
106
|
|
108
107
|
output = capture_logging { subject.build }
|
109
|
-
expect(output).to include(
|
108
|
+
expect(output).to include("Hello World")
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
112
|
describe '#make' do
|
114
|
-
it
|
113
|
+
it "is waiting for a good samaritan to write tests" do
|
115
114
|
skip
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
118
|
describe '#patch' do
|
120
|
-
it
|
121
|
-
configure = File.join(project_dir,
|
122
|
-
File.open(configure,
|
123
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
119
|
+
it "applies the patch" do
|
120
|
+
configure = File.join(project_dir, "configure")
|
121
|
+
File.open(configure, "w") do |f|
|
122
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
124
123
|
THING="-e foo"
|
125
124
|
ZIP="zap"
|
126
125
|
EOH
|
127
126
|
end
|
128
127
|
|
129
|
-
patch = File.join(patches_dir,
|
130
|
-
File.open(patch,
|
131
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
128
|
+
patch = File.join(patches_dir, "apply.patch")
|
129
|
+
File.open(patch, "w") do |f|
|
130
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
132
131
|
--- a/configure
|
133
132
|
+++ b/configure
|
134
133
|
@@ -1,2 +1,3 @@
|
@@ -139,41 +138,41 @@ module Omnibus
|
|
139
138
|
end
|
140
139
|
|
141
140
|
if windows?
|
142
|
-
bash_path = Bundler.which(
|
141
|
+
bash_path = Bundler.which("bash.exe")
|
143
142
|
allow(subject).to receive(:embedded_msys_bin)
|
144
|
-
.with(
|
143
|
+
.with("bash.exe")
|
145
144
|
.and_return("#{bash_path}")
|
146
145
|
end
|
147
146
|
|
148
|
-
subject.patch(source:
|
147
|
+
subject.patch(source: "apply.patch")
|
149
148
|
subject.build
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|
153
152
|
describe '#ruby' do
|
154
|
-
it
|
155
|
-
ruby = File.join(scripts_dir,
|
156
|
-
File.open(ruby,
|
157
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
153
|
+
it "executes the command as the embdedded ruby" do
|
154
|
+
ruby = File.join(scripts_dir, "setup.rb")
|
155
|
+
File.open(ruby, "w") do |f|
|
156
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
158
157
|
File.write("#{software.install_dir}/test.txt", 'This is content!')
|
159
158
|
EOH
|
160
159
|
end
|
161
160
|
|
162
|
-
fake_embedded_bin(
|
161
|
+
fake_embedded_bin("ruby")
|
163
162
|
|
164
163
|
subject.ruby(ruby, env: subject.with_embedded_path)
|
165
164
|
subject.build
|
166
165
|
|
167
166
|
path = "#{software.install_dir}/test.txt"
|
168
167
|
expect(path).to be_a_file
|
169
|
-
expect(File.read(path)).to eq(
|
168
|
+
expect(File.read(path)).to eq("This is content!")
|
170
169
|
end
|
171
170
|
end
|
172
171
|
|
173
172
|
describe '#gem' do
|
174
|
-
it
|
173
|
+
it "executes the command as the embedded gem" do
|
175
174
|
make_gemspec
|
176
|
-
fake_embedded_bin(
|
175
|
+
fake_embedded_bin("gem")
|
177
176
|
gem_file = "#{project_name}-1.0.0.gem"
|
178
177
|
|
179
178
|
subject.gem("build #{project_name}.gemspec", shellout_opts(subject))
|
@@ -181,36 +180,36 @@ module Omnibus
|
|
181
180
|
output = capture_logging { subject.build }
|
182
181
|
|
183
182
|
expect(File.join(project_dir, gem_file)).to be_a_file
|
184
|
-
expect(output).to include(
|
185
|
-
expect(output).to include(
|
183
|
+
expect(output).to include("gem build")
|
184
|
+
expect(output).to include("gem install")
|
186
185
|
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
190
189
|
describe '#bundler' do
|
191
|
-
it
|
190
|
+
it "executes the command as the embedded bundler" do
|
192
191
|
make_gemspec
|
193
192
|
make_gemfile
|
194
|
-
fake_embedded_bin(
|
193
|
+
fake_embedded_bin("bundle")
|
195
194
|
|
196
|
-
subject.bundle(
|
195
|
+
subject.bundle("install", shellout_opts(subject))
|
197
196
|
output = capture_logging { subject.build }
|
198
197
|
|
199
|
-
expect(File.join(project_dir,
|
200
|
-
expect(output).to include(
|
198
|
+
expect(File.join(project_dir, "Gemfile.lock")).to be_a_file
|
199
|
+
expect(output).to include("bundle install")
|
201
200
|
end
|
202
201
|
end
|
203
202
|
|
204
203
|
describe '#appbundle' do
|
205
204
|
let(:project) { double("Project") }
|
206
205
|
let(:project_softwares) { [ double("Software", name: project_name, project_dir: project_dir) ] }
|
207
|
-
it
|
206
|
+
it "executes the command as the embedded appbundler" do
|
208
207
|
make_gemspec
|
209
208
|
make_gemfile
|
210
209
|
make_gemfile_lock
|
211
210
|
|
212
|
-
fake_embedded_bin(
|
213
|
-
fake_embedded_bin(
|
211
|
+
fake_embedded_bin("gem")
|
212
|
+
fake_embedded_bin("appbundler")
|
214
213
|
|
215
214
|
subject.gem("build #{project_name}.gemspec", shellout_opts(subject))
|
216
215
|
subject.gem("install #{project_name}-1.0.0.gem", shellout_opts(subject))
|
@@ -221,60 +220,60 @@ module Omnibus
|
|
221
220
|
|
222
221
|
output = capture_logging { subject.build }
|
223
222
|
|
224
|
-
appbundler_path = File.join(embedded_bin_dir,
|
225
|
-
appbundler_path.gsub!(/\//,'\\') if windows?
|
223
|
+
appbundler_path = File.join(embedded_bin_dir, "appbundler")
|
224
|
+
appbundler_path.gsub!(/\//, '\\') if windows?
|
226
225
|
expect(output).to include("#{appbundler_path} '#{project_dir}' '#{bin_dir}'")
|
227
226
|
end
|
228
227
|
end
|
229
228
|
|
230
229
|
describe '#rake' do
|
231
|
-
it
|
232
|
-
rakefile = File.join(project_dir,
|
233
|
-
File.open(rakefile,
|
234
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
230
|
+
it "executes the command as the embedded rake" do
|
231
|
+
rakefile = File.join(project_dir, "Rakefile")
|
232
|
+
File.open(rakefile, "w") do |f|
|
233
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
235
234
|
task(:foo) { }
|
236
235
|
EOH
|
237
236
|
end
|
238
237
|
|
239
|
-
fake_embedded_bin(
|
238
|
+
fake_embedded_bin("rake")
|
240
239
|
|
241
|
-
subject.rake(
|
242
|
-
subject.rake(
|
240
|
+
subject.rake("-T", shellout_opts(subject))
|
241
|
+
subject.rake("foo", shellout_opts(subject))
|
243
242
|
output = capture_logging { subject.build }
|
244
243
|
|
245
|
-
expect(output).to include(
|
246
|
-
expect(output).to include(
|
244
|
+
expect(output).to include("rake -T")
|
245
|
+
expect(output).to include("rake foo")
|
247
246
|
end
|
248
247
|
end
|
249
248
|
|
250
249
|
describe '#block' do
|
251
|
-
it
|
252
|
-
subject.block(
|
250
|
+
it "executes the command as a block" do
|
251
|
+
subject.block("A complex operation") do
|
253
252
|
FileUtils.touch("#{project_dir}/bacon")
|
254
253
|
end
|
255
254
|
output = capture_logging { subject.build }
|
256
255
|
|
257
|
-
expect(output).to include(
|
256
|
+
expect(output).to include("A complex operation")
|
258
257
|
expect("#{software.project_dir}/bacon").to be_a_file
|
259
258
|
end
|
260
259
|
end
|
261
260
|
|
262
261
|
describe '#erb' do
|
263
|
-
it
|
264
|
-
erb = File.join(templates_dir,
|
265
|
-
File.open(erb,
|
266
|
-
f.write <<-EOH.gsub(/^ {12}/,
|
262
|
+
it "renders the erb" do
|
263
|
+
erb = File.join(templates_dir, "example.erb")
|
264
|
+
File.open(erb, "w") do |f|
|
265
|
+
f.write <<-EOH.gsub(/^ {12}/, "")
|
267
266
|
<%= a %>
|
268
267
|
<%= b %>
|
269
268
|
EOH
|
270
269
|
end
|
271
270
|
|
272
|
-
destination = File.join(tmp_path,
|
271
|
+
destination = File.join(tmp_path, "rendered")
|
273
272
|
|
274
273
|
subject.erb(
|
275
|
-
source:
|
274
|
+
source: "example.erb",
|
276
275
|
dest: destination,
|
277
|
-
vars: { a:
|
276
|
+
vars: { a: "foo", b: "bar" }
|
278
277
|
)
|
279
278
|
subject.build
|
280
279
|
|
@@ -284,8 +283,8 @@ module Omnibus
|
|
284
283
|
end
|
285
284
|
|
286
285
|
describe '#mkdir' do
|
287
|
-
it
|
288
|
-
path = File.join(tmp_path,
|
286
|
+
it "creates the directory" do
|
287
|
+
path = File.join(tmp_path, "scratch")
|
289
288
|
remove_directory(path)
|
290
289
|
|
291
290
|
subject.mkdir(path)
|
@@ -296,8 +295,8 @@ module Omnibus
|
|
296
295
|
end
|
297
296
|
|
298
297
|
describe '#touch' do
|
299
|
-
it
|
300
|
-
path = File.join(tmp_path,
|
298
|
+
it "creates the file" do
|
299
|
+
path = File.join(tmp_path, "file")
|
301
300
|
remove_file(path)
|
302
301
|
|
303
302
|
subject.touch(path)
|
@@ -306,8 +305,8 @@ module Omnibus
|
|
306
305
|
expect(path).to be_a_file
|
307
306
|
end
|
308
307
|
|
309
|
-
it
|
310
|
-
path = File.join(tmp_path,
|
308
|
+
it "creates the containing directory" do
|
309
|
+
path = File.join(tmp_path, "foo", "bar", "file")
|
311
310
|
FileUtils.rm_rf(path)
|
312
311
|
|
313
312
|
subject.touch(path)
|
@@ -318,8 +317,8 @@ module Omnibus
|
|
318
317
|
end
|
319
318
|
|
320
319
|
describe '#delete' do
|
321
|
-
it
|
322
|
-
path = File.join(tmp_path,
|
320
|
+
it "deletes the directory" do
|
321
|
+
path = File.join(tmp_path, "scratch")
|
323
322
|
create_directory(path)
|
324
323
|
|
325
324
|
subject.delete(path)
|
@@ -328,8 +327,8 @@ module Omnibus
|
|
328
327
|
expect(path).to_not be_a_directory
|
329
328
|
end
|
330
329
|
|
331
|
-
it
|
332
|
-
path = File.join(tmp_path,
|
330
|
+
it "deletes the file" do
|
331
|
+
path = File.join(tmp_path, "file")
|
333
332
|
create_file(path)
|
334
333
|
|
335
334
|
subject.delete(path)
|
@@ -338,9 +337,9 @@ module Omnibus
|
|
338
337
|
expect(path).to_not be_a_file
|
339
338
|
end
|
340
339
|
|
341
|
-
it
|
342
|
-
path_a = File.join(tmp_path,
|
343
|
-
path_b = File.join(tmp_path,
|
340
|
+
it "accepts a glob pattern" do
|
341
|
+
path_a = File.join(tmp_path, "file_a")
|
342
|
+
path_b = File.join(tmp_path, "file_b")
|
344
343
|
FileUtils.touch(path_a)
|
345
344
|
FileUtils.touch(path_b)
|
346
345
|
|
@@ -353,9 +352,9 @@ module Omnibus
|
|
353
352
|
end
|
354
353
|
|
355
354
|
describe '#copy' do
|
356
|
-
it
|
357
|
-
path_a = File.join(tmp_path,
|
358
|
-
path_b = File.join(tmp_path,
|
355
|
+
it "copies the file" do
|
356
|
+
path_a = File.join(tmp_path, "file1")
|
357
|
+
path_b = File.join(tmp_path, "file2")
|
359
358
|
create_file(path_a)
|
360
359
|
|
361
360
|
subject.copy(path_a, path_b)
|
@@ -365,14 +364,14 @@ module Omnibus
|
|
365
364
|
expect(File.read(path_b)).to eq(File.read(path_a))
|
366
365
|
end
|
367
366
|
|
368
|
-
it
|
369
|
-
destination = File.join(tmp_path,
|
367
|
+
it "copies the directory and entries" do
|
368
|
+
destination = File.join(tmp_path, "destination")
|
370
369
|
|
371
|
-
directory = File.join(tmp_path,
|
370
|
+
directory = File.join(tmp_path, "scratch")
|
372
371
|
FileUtils.mkdir_p(directory)
|
373
372
|
|
374
|
-
path_a = File.join(directory,
|
375
|
-
path_b = File.join(directory,
|
373
|
+
path_a = File.join(directory, "file_a")
|
374
|
+
path_b = File.join(directory, "file_b")
|
376
375
|
FileUtils.touch(path_a)
|
377
376
|
FileUtils.touch(path_b)
|
378
377
|
|
@@ -384,15 +383,15 @@ module Omnibus
|
|
384
383
|
expect("#{destination}/file_b").to be_a_file
|
385
384
|
end
|
386
385
|
|
387
|
-
it
|
388
|
-
destination = File.join(tmp_path,
|
386
|
+
it "accepts a glob pattern" do
|
387
|
+
destination = File.join(tmp_path, "destination")
|
389
388
|
FileUtils.mkdir_p(destination)
|
390
389
|
|
391
|
-
directory = File.join(tmp_path,
|
390
|
+
directory = File.join(tmp_path, "scratch")
|
392
391
|
FileUtils.mkdir_p(directory)
|
393
392
|
|
394
|
-
path_a = File.join(directory,
|
395
|
-
path_b = File.join(directory,
|
393
|
+
path_a = File.join(directory, "file_a")
|
394
|
+
path_b = File.join(directory, "file_b")
|
396
395
|
FileUtils.touch(path_a)
|
397
396
|
FileUtils.touch(path_b)
|
398
397
|
|
@@ -406,9 +405,9 @@ module Omnibus
|
|
406
405
|
end
|
407
406
|
|
408
407
|
describe '#move' do
|
409
|
-
it
|
410
|
-
path_a = File.join(tmp_path,
|
411
|
-
path_b = File.join(tmp_path,
|
408
|
+
it "moves the file" do
|
409
|
+
path_a = File.join(tmp_path, "file1")
|
410
|
+
path_b = File.join(tmp_path, "file2")
|
412
411
|
create_file(path_a)
|
413
412
|
|
414
413
|
subject.move(path_a, path_b)
|
@@ -418,14 +417,14 @@ module Omnibus
|
|
418
417
|
expect(path_a).to_not be_a_file
|
419
418
|
end
|
420
419
|
|
421
|
-
it
|
422
|
-
destination = File.join(tmp_path,
|
420
|
+
it "moves the directory and entries" do
|
421
|
+
destination = File.join(tmp_path, "destination")
|
423
422
|
|
424
|
-
directory = File.join(tmp_path,
|
423
|
+
directory = File.join(tmp_path, "scratch")
|
425
424
|
FileUtils.mkdir_p(directory)
|
426
425
|
|
427
|
-
path_a = File.join(directory,
|
428
|
-
path_b = File.join(directory,
|
426
|
+
path_a = File.join(directory, "file_a")
|
427
|
+
path_b = File.join(directory, "file_b")
|
429
428
|
FileUtils.touch(path_a)
|
430
429
|
FileUtils.touch(path_b)
|
431
430
|
|
@@ -439,15 +438,15 @@ module Omnibus
|
|
439
438
|
expect(directory).to_not be_a_directory
|
440
439
|
end
|
441
440
|
|
442
|
-
it
|
443
|
-
destination = File.join(tmp_path,
|
441
|
+
it "accepts a glob pattern" do
|
442
|
+
destination = File.join(tmp_path, "destination")
|
444
443
|
FileUtils.mkdir_p(destination)
|
445
444
|
|
446
|
-
directory = File.join(tmp_path,
|
445
|
+
directory = File.join(tmp_path, "scratch")
|
447
446
|
FileUtils.mkdir_p(directory)
|
448
447
|
|
449
|
-
path_a = File.join(directory,
|
450
|
-
path_b = File.join(directory,
|
448
|
+
path_a = File.join(directory, "file_a")
|
449
|
+
path_b = File.join(directory, "file_b")
|
451
450
|
FileUtils.touch(path_a)
|
452
451
|
FileUtils.touch(path_b)
|
453
452
|
|
@@ -463,9 +462,9 @@ module Omnibus
|
|
463
462
|
end
|
464
463
|
|
465
464
|
describe '#link', :not_supported_on_windows do
|
466
|
-
it
|
467
|
-
path_a = File.join(tmp_path,
|
468
|
-
path_b = File.join(tmp_path,
|
465
|
+
it "links the file" do
|
466
|
+
path_a = File.join(tmp_path, "file1")
|
467
|
+
path_b = File.join(tmp_path, "file2")
|
469
468
|
create_file(path_a)
|
470
469
|
|
471
470
|
subject.link(path_a, path_b)
|
@@ -474,9 +473,9 @@ module Omnibus
|
|
474
473
|
expect(path_b).to be_a_symlink
|
475
474
|
end
|
476
475
|
|
477
|
-
it
|
478
|
-
destination = File.join(tmp_path,
|
479
|
-
directory = File.join(tmp_path,
|
476
|
+
it "links the directory" do
|
477
|
+
destination = File.join(tmp_path, "destination")
|
478
|
+
directory = File.join(tmp_path, "scratch")
|
480
479
|
FileUtils.mkdir_p(directory)
|
481
480
|
|
482
481
|
subject.link(directory, destination)
|
@@ -485,15 +484,15 @@ module Omnibus
|
|
485
484
|
expect(destination).to be_a_symlink
|
486
485
|
end
|
487
486
|
|
488
|
-
it
|
489
|
-
destination = File.join(tmp_path,
|
487
|
+
it "accepts a glob pattern" do
|
488
|
+
destination = File.join(tmp_path, "destination")
|
490
489
|
FileUtils.mkdir_p(destination)
|
491
490
|
|
492
|
-
directory = File.join(tmp_path,
|
491
|
+
directory = File.join(tmp_path, "scratch")
|
493
492
|
FileUtils.mkdir_p(directory)
|
494
493
|
|
495
|
-
path_a = File.join(directory,
|
496
|
-
path_b = File.join(directory,
|
494
|
+
path_a = File.join(directory, "file_a")
|
495
|
+
path_b = File.join(directory, "file_b")
|
497
496
|
FileUtils.touch(path_a)
|
498
497
|
FileUtils.touch(path_b)
|
499
498
|
|
@@ -507,28 +506,28 @@ module Omnibus
|
|
507
506
|
|
508
507
|
describe '#sync' do
|
509
508
|
let(:source) do
|
510
|
-
source = File.join(tmp_path,
|
509
|
+
source = File.join(tmp_path, "source")
|
511
510
|
FileUtils.mkdir_p(source)
|
512
511
|
|
513
|
-
FileUtils.touch(File.join(source,
|
514
|
-
FileUtils.touch(File.join(source,
|
515
|
-
FileUtils.touch(File.join(source,
|
512
|
+
FileUtils.touch(File.join(source, "file_a"))
|
513
|
+
FileUtils.touch(File.join(source, "file_b"))
|
514
|
+
FileUtils.touch(File.join(source, "file_c"))
|
516
515
|
|
517
|
-
FileUtils.mkdir_p(File.join(source,
|
518
|
-
FileUtils.touch(File.join(source,
|
519
|
-
FileUtils.touch(File.join(source,
|
516
|
+
FileUtils.mkdir_p(File.join(source, "folder"))
|
517
|
+
FileUtils.touch(File.join(source, "folder", "file_d"))
|
518
|
+
FileUtils.touch(File.join(source, "folder", "file_e"))
|
520
519
|
|
521
|
-
FileUtils.mkdir_p(File.join(source,
|
522
|
-
FileUtils.touch(File.join(source,
|
520
|
+
FileUtils.mkdir_p(File.join(source, ".dot_folder"))
|
521
|
+
FileUtils.touch(File.join(source, ".dot_folder", "file_f"))
|
523
522
|
|
524
|
-
FileUtils.touch(File.join(source,
|
523
|
+
FileUtils.touch(File.join(source, ".file_g"))
|
525
524
|
source
|
526
525
|
end
|
527
526
|
|
528
|
-
let(:destination) { File.join(tmp_path,
|
527
|
+
let(:destination) { File.join(tmp_path, "destination") }
|
529
528
|
|
530
|
-
context
|
531
|
-
it
|
529
|
+
context "when the destination is empty" do
|
530
|
+
it "syncs the directories" do
|
532
531
|
subject.sync(source, destination)
|
533
532
|
subject.build
|
534
533
|
|
@@ -542,10 +541,10 @@ module Omnibus
|
|
542
541
|
end
|
543
542
|
end
|
544
543
|
|
545
|
-
context
|
544
|
+
context "when the directory exists" do
|
546
545
|
before { FileUtils.mkdir_p(destination) }
|
547
546
|
|
548
|
-
it
|
547
|
+
it "deletes existing files and folders" do
|
549
548
|
FileUtils.mkdir_p("#{destination}/existing_folder")
|
550
549
|
FileUtils.mkdir_p("#{destination}/.existing_folder")
|
551
550
|
FileUtils.touch("#{destination}/existing_file")
|
@@ -569,9 +568,9 @@ module Omnibus
|
|
569
568
|
end
|
570
569
|
end
|
571
570
|
|
572
|
-
context
|
573
|
-
it
|
574
|
-
subject.sync(source, destination, exclude:
|
571
|
+
context "when :exclude is given" do
|
572
|
+
it "does not copy files and folders that match the pattern" do
|
573
|
+
subject.sync(source, destination, exclude: ".dot_folder")
|
575
574
|
subject.build
|
576
575
|
|
577
576
|
expect("#{destination}/file_a").to be_a_file
|
@@ -584,13 +583,13 @@ module Omnibus
|
|
584
583
|
expect("#{destination}/.file_g").to be_a_file
|
585
584
|
end
|
586
585
|
|
587
|
-
it
|
586
|
+
it "removes existing files and folders in destination" do
|
588
587
|
FileUtils.mkdir_p("#{destination}/existing_folder")
|
589
588
|
FileUtils.touch("#{destination}/existing_file")
|
590
589
|
FileUtils.mkdir_p("#{destination}/.dot_folder")
|
591
590
|
FileUtils.touch("#{destination}/.dot_folder/file_f")
|
592
591
|
|
593
|
-
subject.sync(source, destination, exclude:
|
592
|
+
subject.sync(source, destination, exclude: ".dot_folder")
|
594
593
|
subject.build
|
595
594
|
|
596
595
|
expect("#{destination}/file_a").to be_a_file
|
@@ -615,33 +614,33 @@ module Omnibus
|
|
615
614
|
FileUtils.mkdir_p(config_guess_dir)
|
616
615
|
end
|
617
616
|
|
618
|
-
context
|
617
|
+
context "with no config.guess" do
|
619
618
|
before do
|
620
619
|
File.open("#{config_guess_dir}/config.sub", "w+") do |f|
|
621
620
|
f.write("This is config.sub")
|
622
621
|
end
|
623
622
|
end
|
624
623
|
|
625
|
-
it
|
624
|
+
it "fails" do
|
626
625
|
subject.update_config_guess
|
627
|
-
expect{subject.build}.to raise_error(RuntimeError)
|
626
|
+
expect { subject.build }.to raise_error(RuntimeError)
|
628
627
|
end
|
629
628
|
end
|
630
629
|
|
631
|
-
context
|
630
|
+
context "with no config.sub" do
|
632
631
|
before do
|
633
632
|
File.open("#{config_guess_dir}/config.guess", "w+") do |f|
|
634
633
|
f.write("This is config.guess")
|
635
634
|
end
|
636
635
|
end
|
637
636
|
|
638
|
-
it
|
637
|
+
it "fails" do
|
639
638
|
subject.update_config_guess
|
640
|
-
expect{subject.build}.to raise_error(RuntimeError)
|
639
|
+
expect { subject.build }.to raise_error(RuntimeError)
|
641
640
|
end
|
642
641
|
end
|
643
642
|
|
644
|
-
context
|
643
|
+
context "with config_guess dependency" do
|
645
644
|
before do
|
646
645
|
File.open("#{config_guess_dir}/config.guess", "w+") do |f|
|
647
646
|
f.write("This is config.guess")
|
@@ -652,28 +651,28 @@ module Omnibus
|
|
652
651
|
end
|
653
652
|
end
|
654
653
|
|
655
|
-
it
|
654
|
+
it "update config_guess with defaults" do
|
656
655
|
subject.update_config_guess
|
657
656
|
subject.build
|
658
657
|
expect(File.read("#{project_dir}/config.guess")).to match /config.guess/
|
659
658
|
expect(File.read("#{project_dir}/config.sub")).to match /config.sub/
|
660
659
|
end
|
661
660
|
|
662
|
-
it
|
661
|
+
it "honors :target option" do
|
663
662
|
subject.update_config_guess(target: "sub_dir")
|
664
663
|
subject.build
|
665
664
|
expect(File.read("#{project_dir}/sub_dir/config.guess")).to match /config.guess/
|
666
665
|
expect(File.read("#{project_dir}/sub_dir/config.sub")).to match /config.sub/
|
667
666
|
end
|
668
667
|
|
669
|
-
it
|
668
|
+
it "honors :config_guess in :install option" do
|
670
669
|
subject.update_config_guess(install: [:config_guess])
|
671
670
|
subject.build
|
672
671
|
expect(File.read("#{project_dir}/config.guess")).to match /config.guess/
|
673
672
|
expect(File.exist?("#{project_dir}/config.sub")).to be false
|
674
673
|
end
|
675
674
|
|
676
|
-
it
|
675
|
+
it "honors :config_sub in :install option" do
|
677
676
|
subject.update_config_guess(install: [:config_sub])
|
678
677
|
subject.build
|
679
678
|
expect(File.read("#{project_dir}/config.sub")).to match /config.sub/
|