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,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "omnibus/manifest_entry"
|
3
3
|
|
4
4
|
module Omnibus
|
5
5
|
describe GitFetcher do
|
6
|
-
include_examples
|
6
|
+
include_examples "a software"
|
7
7
|
|
8
|
-
let(:remote) { remote_git_repo(
|
9
|
-
let(:version) {
|
8
|
+
let(:remote) { remote_git_repo("zlib") }
|
9
|
+
let(:version) { "master" }
|
10
10
|
|
11
11
|
let(:source) do
|
12
12
|
{ git: remote }
|
@@ -14,42 +14,42 @@ module Omnibus
|
|
14
14
|
|
15
15
|
let(:manifest_entry) do
|
16
16
|
double(ManifestEntry,
|
17
|
-
name:
|
18
|
-
locked_version:
|
17
|
+
name: "software",
|
18
|
+
locked_version: "45ded6d3b1a35d66ed866b2c3eb418426e6382b0",
|
19
19
|
described_version: version,
|
20
20
|
locked_source: source)
|
21
21
|
end
|
22
22
|
|
23
23
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
24
|
-
|
25
|
-
let(:revision) { shellout!(
|
24
|
+
|
25
|
+
let(:revision) { shellout!("git rev-parse HEAD", cwd: project_dir).stdout.strip }
|
26
26
|
|
27
27
|
describe '#fetch_required?' do
|
28
|
-
context
|
29
|
-
it
|
28
|
+
context "when the repo is not cloned" do
|
29
|
+
it "return true" do
|
30
30
|
expect(subject.fetch_required?).to be_truthy
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
context
|
34
|
+
context "when the repo is cloned" do
|
35
35
|
before { subject.fetch }
|
36
36
|
|
37
|
-
context
|
37
|
+
context "when the revision is not available" do
|
38
38
|
let(:manifest_entry) do
|
39
39
|
double(ManifestEntry,
|
40
|
-
name:
|
41
|
-
locked_version:
|
40
|
+
name: "software",
|
41
|
+
locked_version: "abcdefabcdef5d66ed866b2c3eb418426e6382b0",
|
42
42
|
described_version: version,
|
43
43
|
locked_source: source)
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it "return true" do
|
47
47
|
expect(subject.fetch_required?).to be_truthy
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
52
|
-
it
|
51
|
+
context "when the revisions are the same" do
|
52
|
+
it "return false" do
|
53
53
|
expect(subject.fetch_required?).to be(false)
|
54
54
|
end
|
55
55
|
end
|
@@ -57,7 +57,7 @@ module Omnibus
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '#version_guid' do
|
60
|
-
it
|
60
|
+
it "includes the current revision" do
|
61
61
|
expect(subject.version_guid).to match(/^git:[0-9a-f]{40}/)
|
62
62
|
end
|
63
63
|
end
|
@@ -67,12 +67,12 @@ module Omnibus
|
|
67
67
|
subject.fetch
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
70
|
+
it "returns true" do
|
71
71
|
expect(subject.clean).to be_truthy
|
72
72
|
end
|
73
73
|
|
74
|
-
context
|
75
|
-
it
|
74
|
+
context "when the project directory has extra files in it" do
|
75
|
+
it "cleans the git repo" do
|
76
76
|
create_file("#{project_dir}/file_a")
|
77
77
|
create_file("#{project_dir}/.file_b")
|
78
78
|
subject.clean
|
@@ -81,117 +81,115 @@ module Omnibus
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
context
|
84
|
+
context "when the project directory is at a different version" do
|
85
85
|
before do
|
86
86
|
# Dirty the project_dir by giving it a conflicting commit.
|
87
|
-
create_file("#{project_dir}/file_a") {
|
88
|
-
create_file("#{project_dir}/configure") {
|
89
|
-
shellout!(
|
87
|
+
create_file("#{project_dir}/file_a") { "some new file" }
|
88
|
+
create_file("#{project_dir}/configure") { "LALALALA" }
|
89
|
+
shellout!("git add .", cwd: project_dir)
|
90
90
|
shellout!('git commit -am "Some commit"', cwd: project_dir)
|
91
91
|
create_file("#{project_dir}/.file_b")
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it "checks out the right version" do
|
95
95
|
subject.clean
|
96
96
|
expect(revision).to eq(manifest_entry.locked_version)
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
99
|
+
it "resets the working tree" do
|
100
100
|
subject.clean
|
101
101
|
expect("#{project_dir}/file_a").to_not be_a_file
|
102
102
|
expect("#{project_dir}/.file_b").to_not be_a_file
|
103
|
-
expect(File.read("#{project_dir}/configure")).to_not match(
|
103
|
+
expect(File.read("#{project_dir}/configure")).to_not match("LA")
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
describe '#fetch' do
|
109
|
-
let(:version) {
|
110
|
-
let(:remote) { remote_git_repo(
|
109
|
+
let(:version) { "v1.2.4" }
|
110
|
+
let(:remote) { remote_git_repo("zlib", annotated_tags: [version]) }
|
111
111
|
let(:manifest_entry) do
|
112
112
|
double(ManifestEntry,
|
113
|
-
name:
|
114
|
-
locked_version:
|
113
|
+
name: "software",
|
114
|
+
locked_version: "efde208366abd0f91419d8a54b45e3f6e0540105",
|
115
115
|
described_version: version,
|
116
116
|
locked_source: source)
|
117
117
|
end
|
118
118
|
|
119
119
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
120
120
|
|
121
|
-
|
122
|
-
it 'clones the repository' do
|
121
|
+
it "clones the repository" do
|
123
122
|
subject.fetch
|
124
123
|
expect("#{project_dir}/.git").to be_a_directory
|
125
124
|
end
|
126
125
|
end
|
127
126
|
|
128
|
-
|
129
127
|
describe '#resolve_version' do
|
130
|
-
context
|
131
|
-
let(:version) {
|
132
|
-
let(:remote) { remote_git_repo(
|
128
|
+
context "when the version is a tag" do
|
129
|
+
let(:version) { "v1.2.3" }
|
130
|
+
let(:remote) { remote_git_repo("zlib", tags: [version]) }
|
133
131
|
|
134
|
-
it
|
135
|
-
expect(GitFetcher.resolve_version(version, source)).to eq(
|
132
|
+
it "parses the tag" do
|
133
|
+
expect(GitFetcher.resolve_version(version, source)).to eq("53c72c4abcc961b153996f5b5f402ce715e47146")
|
136
134
|
end
|
137
135
|
end
|
138
136
|
|
139
|
-
context
|
140
|
-
let(:version) {
|
141
|
-
let(:remote) { remote_git_repo(
|
137
|
+
context "when the version is an annnotated tag" do
|
138
|
+
let(:version) { "v1.2.4" }
|
139
|
+
let(:remote) { remote_git_repo("zlib", annotated_tags: [version]) }
|
142
140
|
|
143
|
-
it
|
144
|
-
expect(GitFetcher.resolve_version(version, source)).to eq(
|
141
|
+
it "it defererences and parses the annotated tag" do
|
142
|
+
expect(GitFetcher.resolve_version(version, source)).to eq("efde208366abd0f91419d8a54b45e3f6e0540105")
|
145
143
|
end
|
146
144
|
end
|
147
145
|
|
148
|
-
context
|
149
|
-
let(:version) {
|
150
|
-
let(:remote) { remote_git_repo(
|
146
|
+
context "when the version is a branch" do
|
147
|
+
let(:version) { "sethvargo/magic_ponies" }
|
148
|
+
let(:remote) { remote_git_repo("zlib", branches: [version]) }
|
151
149
|
|
152
|
-
it
|
153
|
-
expect(GitFetcher.resolve_version(version, source)).to eq(
|
150
|
+
it "parses the branch" do
|
151
|
+
expect(GitFetcher.resolve_version(version, source)).to eq("171a1aec35ac0a050f8dccd9c9ef4609b1d8d8ea")
|
154
152
|
end
|
155
153
|
end
|
156
154
|
|
157
|
-
context
|
158
|
-
let(:version) {
|
159
|
-
let(:remote) { remote_git_repo(
|
155
|
+
context "when the version is a full SHA-1" do
|
156
|
+
let(:version) { "45ded6d3b1a35d66ed866b2c3eb418426e6382b0" }
|
157
|
+
let(:remote) { remote_git_repo("zlib") }
|
160
158
|
|
161
|
-
it
|
162
|
-
expect(GitFetcher.resolve_version(version, source)).to eq(
|
159
|
+
it "parses the full SHA-1" do
|
160
|
+
expect(GitFetcher.resolve_version(version, source)).to eq("45ded6d3b1a35d66ed866b2c3eb418426e6382b0")
|
163
161
|
end
|
164
162
|
end
|
165
163
|
|
166
|
-
context
|
167
|
-
let(:version) {
|
168
|
-
let(:remote) { remote_git_repo(
|
164
|
+
context "when the version is a abbreviated SHA-1" do
|
165
|
+
let(:version) { "45ded6d" }
|
166
|
+
let(:remote) { remote_git_repo("zlib") }
|
169
167
|
|
170
|
-
it
|
171
|
-
expect(GitFetcher.resolve_version(version, source)).to eq(
|
168
|
+
it "parses the abbreviated SHA-1" do
|
169
|
+
expect(GitFetcher.resolve_version(version, source)).to eq("45ded6d")
|
172
170
|
end
|
173
171
|
end
|
174
172
|
|
175
|
-
context
|
176
|
-
let(:version) {
|
177
|
-
let(:remote) { remote_git_repo(
|
173
|
+
context "when the version is a non-existent ref" do
|
174
|
+
let(:version) { "fufufufufu" }
|
175
|
+
let(:remote) { remote_git_repo("zlib") }
|
178
176
|
|
179
|
-
it
|
177
|
+
it "raise an exception" do
|
180
178
|
expect { GitFetcher.resolve_version(version, source) }.to raise_error(UnresolvableGitReference)
|
181
179
|
end
|
182
180
|
end
|
183
181
|
end
|
184
182
|
|
185
183
|
describe '#version_for_cache' do
|
186
|
-
it
|
187
|
-
expect(subject.version_for_cache).to eq(
|
184
|
+
it "includes the resolved revision" do
|
185
|
+
expect(subject.version_for_cache).to eq("revision:45ded6d3b1a35d66ed866b2c3eb418426e6382b0")
|
188
186
|
end
|
189
187
|
|
190
|
-
it
|
191
|
-
expect(subject.version_for_cache).to eq(
|
188
|
+
it "not use the current version on disk after fetching" do
|
189
|
+
expect(subject.version_for_cache).to eq("revision:45ded6d3b1a35d66ed866b2c3eb418426e6382b0")
|
192
190
|
subject.fetch
|
193
|
-
expect(subject.version_for_cache).to eq(
|
194
|
-
expect(revision).to_not eq(
|
191
|
+
expect(subject.version_for_cache).to eq("revision:45ded6d3b1a35d66ed866b2c3eb418426e6382b0")
|
192
|
+
expect(revision).to_not eq("revision:45ded6d3b1a35d66ed866b2c3eb418426e6382b0")
|
195
193
|
end
|
196
194
|
end
|
197
195
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
module RSpec
|
@@ -10,52 +10,52 @@ module Omnibus
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe NetFetcher do
|
13
|
-
include_examples
|
13
|
+
include_examples "a software", "zlib"
|
14
14
|
|
15
|
-
let(:source_url) {
|
16
|
-
let(:source_md5) {
|
17
|
-
let(:source_sha1) {
|
18
|
-
let(:source_sha256) {
|
19
|
-
let(:source_sha512) {
|
15
|
+
let(:source_url) { "http://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz" }
|
16
|
+
let(:source_md5) { "44d667c142d7cda120332623eab69f40" }
|
17
|
+
let(:source_sha1) { "a4d316c404ff54ca545ea71a27af7dbc29817088" }
|
18
|
+
let(:source_sha256) { "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d" }
|
19
|
+
let(:source_sha512) { "ece209d4c7ec0cb58ede791444dc754e0d10811cbbdebe3df61c0fd9f9f9867c1c3ccd5f1827f847c005e24eef34fb5bf87b5d3f894d75da04f1797538290e4a" }
|
20
20
|
|
21
21
|
let(:source) do
|
22
22
|
{ url: source_url, md5: source_md5 }
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:downloaded_file) { subject.send(:downloaded_file) }
|
26
|
-
let(:extracted) { File.join(source_dir,
|
26
|
+
let(:extracted) { File.join(source_dir, "zlib-1.2.8") }
|
27
27
|
|
28
28
|
let(:fetch!) { capture_stdout { subject.fetch } }
|
29
29
|
|
30
30
|
let(:manifest_entry) do
|
31
31
|
double(ManifestEntry,
|
32
|
-
name:
|
33
|
-
locked_version:
|
34
|
-
described_version:
|
32
|
+
name: "software",
|
33
|
+
locked_version: "1.2.8",
|
34
|
+
described_version: "1.2.8",
|
35
35
|
locked_source: source)
|
36
36
|
end
|
37
37
|
|
38
38
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
39
39
|
|
40
40
|
describe '#fetch_required?' do
|
41
|
-
context
|
42
|
-
it
|
41
|
+
context "when the file is not downloaded" do
|
42
|
+
it "return true" do
|
43
43
|
expect(subject.fetch_required?).to be_truthy
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
47
|
+
context "when the file is downloaded" do
|
48
48
|
before { fetch! }
|
49
49
|
|
50
|
-
context
|
51
|
-
it
|
52
|
-
allow(subject).to receive(:checksum).and_return(
|
50
|
+
context "when the checksum is different" do
|
51
|
+
it "return true" do
|
52
|
+
allow(subject).to receive(:checksum).and_return("abcd1234")
|
53
53
|
expect(subject.fetch_required?).to be_truthy
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
context
|
58
|
-
it
|
57
|
+
context "when the checksum is the same" do
|
58
|
+
it "return false" do
|
59
59
|
expect(subject.fetch_required?).to be(false)
|
60
60
|
end
|
61
61
|
end
|
@@ -63,38 +63,38 @@ module Omnibus
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe '#version_guid' do
|
66
|
-
context
|
67
|
-
it
|
66
|
+
context "source with md5" do
|
67
|
+
it "includes the md5 digest" do
|
68
68
|
expect(subject.version_guid).to eq("md5:#{source_md5}")
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
72
|
+
context "source with sha1" do
|
73
73
|
let(:source) do
|
74
74
|
{ url: source_url, sha1: source_sha1 }
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
77
|
+
it "includes the sha1 digest" do
|
78
78
|
expect(subject.version_guid).to eq("sha1:#{source_sha1}")
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
context
|
82
|
+
context "source with sha256" do
|
83
83
|
let(:source) do
|
84
84
|
{ url: source_url, sha256: source_sha256 }
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
87
|
+
it "includes the sha256 digest" do
|
88
88
|
expect(subject.version_guid).to eq("sha256:#{source_sha256}")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
context
|
92
|
+
context "source with sha512" do
|
93
93
|
let(:source) do
|
94
94
|
{ url: source_url, sha512: source_sha512 }
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it "includes the sha512 digest" do
|
98
98
|
expect(subject.version_guid).to eq("sha512:#{source_sha512}")
|
99
99
|
end
|
100
100
|
end
|
@@ -103,36 +103,36 @@ module Omnibus
|
|
103
103
|
describe '#clean' do
|
104
104
|
before { fetch! }
|
105
105
|
|
106
|
-
context
|
106
|
+
context "when the project directory exists" do
|
107
107
|
before do
|
108
108
|
create_file("#{project_dir}/file_a")
|
109
109
|
end
|
110
110
|
|
111
|
-
it
|
111
|
+
it "extracts the asset" do
|
112
112
|
subject.clean
|
113
113
|
expect(extracted).to_not be_a_file
|
114
114
|
end
|
115
115
|
|
116
|
-
it
|
116
|
+
it "returns true" do
|
117
117
|
expect(subject.clean).to be_truthy
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
context
|
121
|
+
context "when the project directory does not exist" do
|
122
122
|
before do
|
123
123
|
remove_directory(project_dir)
|
124
124
|
end
|
125
125
|
|
126
|
-
it
|
126
|
+
it "returns false" do
|
127
127
|
expect(subject.clean).to be(false)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
context
|
132
|
-
let(:source_url) {
|
133
|
-
let(:source_md5) {
|
134
|
-
|
135
|
-
it
|
131
|
+
context "when the source has read-only files" do
|
132
|
+
let(:source_url) { "http://dl.bintray.com/oneclick/OpenKnapsack/x86/openssl-1.0.0q-x86-windows.tar.lzma" }
|
133
|
+
let(:source_md5) { "577dbe528415c6f178a9431fd0554df4" }
|
134
|
+
|
135
|
+
it "extracts the asset without crashing" do
|
136
136
|
subject.clean
|
137
137
|
expect(extracted).to_not be_a_file
|
138
138
|
subject.clean
|
@@ -140,15 +140,15 @@ module Omnibus
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
context
|
144
|
-
let(:source_url) {
|
145
|
-
let(:source_md5) {
|
143
|
+
context "when the source has broken symlinks" do
|
144
|
+
let(:source_url) { "http://www.openssl.org/source/openssl-1.0.1q.tar.gz" }
|
145
|
+
let(:source_md5) { "54538d0cdcb912f9bc2b36268388205e" }
|
146
146
|
|
147
147
|
let(:source) do
|
148
148
|
{ url: source_url, md5: source_md5, extract: :lax_tar }
|
149
149
|
end
|
150
150
|
|
151
|
-
it
|
151
|
+
it "extracts the asset without crashing" do
|
152
152
|
subject.clean
|
153
153
|
expect(extracted).to_not be_a_file
|
154
154
|
subject.clean
|
@@ -158,89 +158,89 @@ module Omnibus
|
|
158
158
|
end
|
159
159
|
|
160
160
|
describe '#fetch' do
|
161
|
-
context
|
162
|
-
it
|
161
|
+
context "source with md5" do
|
162
|
+
it "downloads the file" do
|
163
163
|
fetch!
|
164
164
|
expect(downloaded_file).to be_a_file
|
165
165
|
end
|
166
166
|
|
167
|
-
context
|
168
|
-
let(:source_md5) {
|
167
|
+
context "when the checksum is invalid" do
|
168
|
+
let(:source_md5) { "bad01234checksum" }
|
169
169
|
|
170
|
-
it
|
170
|
+
it "raises an exception" do
|
171
171
|
expect { fetch! }.to raise_error(ChecksumMismatch)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
-
context
|
176
|
+
context "source with no checksum" do
|
177
177
|
let(:source) do
|
178
178
|
{ url: source_url }
|
179
179
|
end
|
180
180
|
|
181
|
-
it
|
181
|
+
it "raises an exception" do
|
182
182
|
expect { fetch! }.to raise_error(ChecksumMissing)
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
context
|
186
|
+
context "source with sha1" do
|
187
187
|
let(:source) do
|
188
188
|
{ url: source_url, sha1: source_sha1 }
|
189
189
|
end
|
190
190
|
|
191
|
-
it
|
191
|
+
it "downloads the file" do
|
192
192
|
fetch!
|
193
193
|
expect(downloaded_file).to be_a_file
|
194
194
|
end
|
195
195
|
|
196
|
-
context
|
197
|
-
let(:source_sha1) {
|
196
|
+
context "when the checksum is invalid" do
|
197
|
+
let(:source_sha1) { "bad01234checksum" }
|
198
198
|
|
199
|
-
it
|
199
|
+
it "raises an exception" do
|
200
200
|
expect { fetch! }.to raise_error(ChecksumMismatch)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
context
|
205
|
+
context "source with sha256" do
|
206
206
|
let(:source) do
|
207
207
|
{ url: source_url, sha256: source_sha256 }
|
208
208
|
end
|
209
209
|
|
210
|
-
it
|
210
|
+
it "downloads the file" do
|
211
211
|
fetch!
|
212
212
|
expect(downloaded_file).to be_a_file
|
213
213
|
end
|
214
214
|
|
215
|
-
context
|
216
|
-
let(:source_sha256) {
|
215
|
+
context "when the checksum is invalid" do
|
216
|
+
let(:source_sha256) { "bad01234checksum" }
|
217
217
|
|
218
|
-
it
|
218
|
+
it "raises an exception" do
|
219
219
|
expect { fetch! }.to raise_error(ChecksumMismatch)
|
220
220
|
end
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
|
-
context
|
224
|
+
context "source with sha512" do
|
225
225
|
let(:source) do
|
226
226
|
{ url: source_url, sha512: source_sha512 }
|
227
227
|
end
|
228
228
|
|
229
|
-
it
|
229
|
+
it "downloads the file" do
|
230
230
|
fetch!
|
231
231
|
expect(downloaded_file).to be_a_file
|
232
232
|
end
|
233
233
|
|
234
|
-
context
|
235
|
-
let(:source_sha512) {
|
234
|
+
context "when the checksum is invalid" do
|
235
|
+
let(:source_sha512) { "bad01234checksum" }
|
236
236
|
|
237
|
-
it
|
237
|
+
it "raises an exception" do
|
238
238
|
expect { fetch! }.to raise_error(ChecksumMismatch)
|
239
239
|
end
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
243
|
-
it
|
243
|
+
it "when the download times out" do
|
244
244
|
# Mock the Timeout::Error for this particular test only
|
245
245
|
WebMock.disable_net_connect!
|
246
246
|
stub_request(:get, "http://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz").to_timeout
|
@@ -248,17 +248,17 @@ module Omnibus
|
|
248
248
|
expect { subject.send(:download) }.to raise_error(Timeout::Error)
|
249
249
|
end
|
250
250
|
|
251
|
-
expect(output).to include(
|
252
|
-
expect(output).to include(
|
253
|
-
retry_count = output.scan(
|
251
|
+
expect(output).to include("Retrying failed download")
|
252
|
+
expect(output).to include("Download failed")
|
253
|
+
retry_count = output.scan("Retrying failed download").count
|
254
254
|
expect(retry_count).to eq(Omnibus::Config.fetcher_retries)
|
255
255
|
end
|
256
256
|
|
257
|
-
context
|
258
|
-
let(:source_url) {
|
259
|
-
let(:source_md5) {
|
257
|
+
context "when the file is less than 10240 bytes" do
|
258
|
+
let(:source_url) { "https://downloads.chef.io/packages-chef-io-public.key" }
|
259
|
+
let(:source_md5) { "369efc3a19b9118cdf51c7e87a34f266" }
|
260
260
|
|
261
|
-
it
|
261
|
+
it "downloads the file" do
|
262
262
|
fetch!
|
263
263
|
expect(downloaded_file).to be_a_file
|
264
264
|
end
|
@@ -272,38 +272,38 @@ module Omnibus
|
|
272
272
|
create_file("#{project_dir}/.file_c")
|
273
273
|
end
|
274
274
|
|
275
|
-
context
|
276
|
-
it
|
275
|
+
context "source with md5" do
|
276
|
+
it "includes the download_url and checksum" do
|
277
277
|
expect(subject.version_for_cache).to eq("download_url:#{source_url}|md5:#{source_md5}")
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
-
context
|
281
|
+
context "source with sha1" do
|
282
282
|
let(:source) do
|
283
283
|
{ url: source_url, sha1: source_sha1 }
|
284
284
|
end
|
285
285
|
|
286
|
-
it
|
286
|
+
it "includes the download_url and checksum" do
|
287
287
|
expect(subject.version_for_cache).to eq("download_url:#{source_url}|sha1:#{source_sha1}")
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
291
|
-
context
|
291
|
+
context "source with sha256" do
|
292
292
|
let(:source) do
|
293
293
|
{ url: source_url, sha256: source_sha256 }
|
294
294
|
end
|
295
295
|
|
296
|
-
it
|
296
|
+
it "includes the download_url and checksum" do
|
297
297
|
expect(subject.version_for_cache).to eq("download_url:#{source_url}|sha256:#{source_sha256}")
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
301
|
-
context
|
301
|
+
context "source with sha512" do
|
302
302
|
let(:source) do
|
303
303
|
{ url: source_url, sha512: source_sha512 }
|
304
304
|
end
|
305
305
|
|
306
|
-
it
|
306
|
+
it "includes the download_url and checksum" do
|
307
307
|
expect(subject.version_for_cache).to eq("download_url:#{source_url}|sha512:#{source_sha512}")
|
308
308
|
end
|
309
309
|
end
|