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
data/spec/unit/software_spec.rb
CHANGED
@@ -1,386 +1,361 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Software do
|
5
5
|
let(:project) do
|
6
6
|
Project.new.evaluate do
|
7
|
-
name
|
8
|
-
install_dir
|
7
|
+
name "project"
|
8
|
+
install_dir "/opt/project"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:source) do
|
13
13
|
{
|
14
|
-
url:
|
15
|
-
md5:
|
14
|
+
url: "http://example.com/",
|
15
|
+
md5: "abcd1234",
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
let(:rel_path) {
|
19
|
+
let(:rel_path) { "software" }
|
20
20
|
|
21
21
|
subject do
|
22
22
|
local_source = source
|
23
23
|
local_rel_path = rel_path
|
24
24
|
|
25
25
|
described_class.new(project).evaluate do
|
26
|
-
name
|
27
|
-
default_version
|
26
|
+
name "software"
|
27
|
+
default_version "1.2.3"
|
28
28
|
|
29
29
|
source local_source
|
30
30
|
relative_path local_rel_path
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
it_behaves_like
|
35
|
-
it_behaves_like
|
36
|
-
it_behaves_like
|
37
|
-
it_behaves_like
|
38
|
-
it_behaves_like
|
39
|
-
it_behaves_like
|
40
|
-
it_behaves_like
|
41
|
-
it_behaves_like
|
42
|
-
it_behaves_like
|
43
|
-
it_behaves_like
|
44
|
-
it_behaves_like
|
45
|
-
it_behaves_like
|
46
|
-
it_behaves_like
|
47
|
-
it_behaves_like
|
48
|
-
it_behaves_like
|
49
|
-
it_behaves_like
|
50
|
-
it_behaves_like
|
51
|
-
it_behaves_like
|
52
|
-
it_behaves_like
|
53
|
-
|
54
|
-
|
55
|
-
|
34
|
+
it_behaves_like "a cleanroom getter", :project
|
35
|
+
it_behaves_like "a cleanroom setter", :name, %{name 'libxml2'}
|
36
|
+
it_behaves_like "a cleanroom setter", :description, %{description 'The XML magician'}
|
37
|
+
it_behaves_like "a cleanroom setter", :maintainer, %{maintainer 'Captain Jack <sparrow@chef.io>'}
|
38
|
+
it_behaves_like "a cleanroom setter", :dependency, %{dependency 'libxslt'}
|
39
|
+
it_behaves_like "a cleanroom setter", :source, %{source url: 'https://source.example.com'}
|
40
|
+
it_behaves_like "a cleanroom setter", :default_version, %{default_version '1.2.3'}
|
41
|
+
it_behaves_like "a cleanroom setter", :version, %{version '1.2.3'}
|
42
|
+
it_behaves_like "a cleanroom setter", :license, %{license 'Apache 2.0'}
|
43
|
+
it_behaves_like "a cleanroom setter", :license_file, %{license_file 'LICENSES/artistic.txt'}
|
44
|
+
it_behaves_like "a cleanroom setter", :skip_transitive_dependency_licensing, %{skip_transitive_dependency_licensing true}
|
45
|
+
it_behaves_like "a cleanroom setter", :whitelist_file, %{whitelist_file '/opt/whatever'}
|
46
|
+
it_behaves_like "a cleanroom setter", :relative_path, %{relative_path '/path/to/extracted'}
|
47
|
+
it_behaves_like "a cleanroom setter", :build, %|build {}|
|
48
|
+
it_behaves_like "a cleanroom getter", :project_dir
|
49
|
+
it_behaves_like "a cleanroom getter", :build_dir
|
50
|
+
it_behaves_like "a cleanroom getter", :install_dir
|
51
|
+
it_behaves_like "a cleanroom getter", :with_standard_compiler_flags
|
52
|
+
it_behaves_like "a cleanroom setter", :with_embedded_path, %|with_embedded_path({ 'foo' => 'bar' })|
|
53
|
+
it_behaves_like "a cleanroom setter", :prepend_path, %|prepend_path({ 'foo' => 'bar' })|
|
54
|
+
|
55
|
+
context "when a source_uri is present" do
|
56
|
+
let(:uri) { URI.parse("http://example.com/foo.tar.gz") }
|
56
57
|
before { allow(subject).to receive(:source_uri).and_return(uri) }
|
57
58
|
|
58
|
-
it_behaves_like
|
59
|
+
it_behaves_like "a cleanroom getter", :project_file
|
59
60
|
end
|
60
61
|
|
61
|
-
context
|
62
|
+
context "when no license is present" do
|
62
63
|
it "sets the defaults" do
|
63
|
-
expect(subject.license).to eq (
|
64
|
+
expect(subject.license).to eq ("Unspecified")
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
describe "with_standard_compiler_flags helper" do
|
68
69
|
context "on ubuntu" do
|
69
|
-
before { stub_ohai(platform:
|
70
|
+
before { stub_ohai(platform: "ubuntu", version: "12.04") }
|
70
71
|
|
71
72
|
it "sets the defaults" do
|
72
73
|
expect(subject.with_standard_compiler_flags).to eq(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
75
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
76
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
77
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
78
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
79
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
79
80
|
)
|
80
81
|
end
|
81
|
-
it
|
82
|
-
expect(subject.with_standard_compiler_flags(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
82
|
+
it "overrides LDFLAGS" do
|
83
|
+
expect(subject.with_standard_compiler_flags("LDFLAGS" => "foo")).to eq(
|
84
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
85
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
86
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
87
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
88
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
89
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
89
90
|
)
|
90
91
|
end
|
91
|
-
it
|
92
|
-
expect(subject.with_standard_compiler_flags(
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
it "overrides CFLAGS" do
|
93
|
+
expect(subject.with_standard_compiler_flags("CFLAGS" => "foo")).to eq(
|
94
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
95
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
96
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
97
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
98
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
99
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
99
100
|
)
|
100
101
|
end
|
101
|
-
it
|
102
|
-
expect(subject.with_standard_compiler_flags(
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
it "overrides CXXFLAGS" do
|
103
|
+
expect(subject.with_standard_compiler_flags("CXXFLAGS" => "foo")).to eq(
|
104
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
105
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
106
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
107
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
108
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
109
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
109
110
|
)
|
110
111
|
end
|
111
|
-
it
|
112
|
-
expect(subject.with_standard_compiler_flags(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
it "overrides CPPFLAGS" do
|
113
|
+
expect(subject.with_standard_compiler_flags("CPPFLAGS" => "foo")).to eq(
|
114
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
115
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
116
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
117
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
118
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
119
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
119
120
|
)
|
120
121
|
end
|
121
|
-
it
|
122
|
-
expect(subject.with_standard_compiler_flags(
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
it "preserves anything else" do
|
123
|
+
expect(subject.with_standard_compiler_flags("numberwang" => 4)).to eq(
|
124
|
+
"numberwang" => 4,
|
125
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
|
126
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
127
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
128
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
129
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
130
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
130
131
|
)
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
134
|
-
context
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
end
|
163
|
-
Config.project_root(project_root)
|
164
|
-
Config.solaris_linker_mapfile('files/mapfile/solaris')
|
165
|
-
allow(File).to receive(:exist?).and_return(true)
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'sets LD_OPTIONS correctly' do
|
169
|
-
expect(subject.with_standard_compiler_flags).to eq(
|
170
|
-
"CC" => "gcc -m64 -static-libgcc",
|
171
|
-
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
172
|
-
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
173
|
-
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
174
|
-
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
|
175
|
-
"LD_OPTIONS" => "-R/opt/project/embedded/lib",
|
176
|
-
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
177
|
-
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
178
|
-
)
|
179
|
-
end
|
180
|
-
end
|
135
|
+
context "on solaris_11" do
|
136
|
+
before do
|
137
|
+
stub_ohai(platform: "solaris2", version: "5.11") do |data|
|
138
|
+
# For some reason, this isn't set in Fauxhai
|
139
|
+
data["platform"] = "solaris2"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "sets the defaults" do
|
144
|
+
expect(subject.with_standard_compiler_flags).to eq(
|
145
|
+
"CC" => "gcc -m64 -static-libgcc",
|
146
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
147
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
148
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
149
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
|
150
|
+
"LD_OPTIONS" => "-R/opt/project/embedded/lib",
|
151
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
152
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when loader mapping file is specified" do
|
157
|
+
# Let the unit tests run on windows where auto-path translation occurs.
|
158
|
+
let(:project_root) { File.join(tmp_path, "/root/project") }
|
159
|
+
before do
|
160
|
+
stub_ohai(platform: "solaris2", version: "5.11") do |data|
|
161
|
+
# For some reason, this isn't set in Fauxhai
|
162
|
+
data["platform"] = "solaris2"
|
181
163
|
end
|
164
|
+
Config.project_root(project_root)
|
165
|
+
Config.solaris_linker_mapfile("files/mapfile/solaris")
|
166
|
+
allow(File).to receive(:exist?).and_return(true)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "sets LD_OPTIONS correctly" do
|
170
|
+
expect(subject.with_standard_compiler_flags).to eq(
|
171
|
+
"CC" => "gcc -m64 -static-libgcc",
|
172
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
173
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
174
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
175
|
+
"LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
|
176
|
+
"LD_OPTIONS" => "-R/opt/project/embedded/lib",
|
177
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
178
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
179
|
+
)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
182
183
|
|
183
|
-
context
|
184
|
+
context "on solaris_10" do
|
184
185
|
before do
|
185
|
-
stub_ohai(platform:
|
186
|
+
stub_ohai(platform: "solaris2", version: "5.10") do |data|
|
186
187
|
# For some reason, this isn't set in Fauxhai
|
187
|
-
data[
|
188
|
+
data["platform"] = "solaris2"
|
188
189
|
end
|
189
190
|
end
|
190
191
|
|
191
|
-
it
|
192
|
+
it "sets the defaults" do
|
192
193
|
expect(subject.with_standard_compiler_flags).to eq(
|
193
|
-
|
194
|
-
|
195
|
-
|
194
|
+
"CC" => "gcc -static-libgcc",
|
195
|
+
"LDFLAGS" => "-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
|
196
|
+
"CFLAGS" => "-I/opt/project/embedded/include",
|
196
197
|
"CXXFLAGS" => "-I/opt/project/embedded/include",
|
197
198
|
"CPPFLAGS" => "-I/opt/project/embedded/include",
|
198
|
-
|
199
|
-
|
200
|
-
|
199
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
200
|
+
"LD_OPTIONS" => "-R/opt/project/embedded/lib",
|
201
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
201
202
|
)
|
202
203
|
end
|
203
204
|
|
204
|
-
context
|
205
|
+
context "when loader mapping file is specified" do
|
205
206
|
# Let the unit tests run on windows where auto-path translation occurs.
|
206
|
-
let(:project_root) { File.join(tmp_path,
|
207
|
+
let(:project_root) { File.join(tmp_path, "/root/project") }
|
207
208
|
before do
|
208
|
-
stub_ohai(platform:
|
209
|
+
stub_ohai(platform: "solaris2", version: "5.10") do |data|
|
209
210
|
# For some reason, this isn't set in Fauxhai
|
210
|
-
data[
|
211
|
+
data["platform"] = "solaris2"
|
211
212
|
end
|
212
213
|
Config.project_root(project_root)
|
213
|
-
Config.solaris_linker_mapfile(
|
214
|
+
Config.solaris_linker_mapfile("files/mapfile/solaris")
|
214
215
|
allow(File).to receive(:exist?).and_return(true)
|
215
216
|
end
|
216
217
|
|
217
|
-
it
|
218
|
+
it "sets LD_OPTIONS correctly" do
|
218
219
|
expect(subject.with_standard_compiler_flags).to eq(
|
219
|
-
|
220
|
-
|
221
|
-
|
220
|
+
"CC" => "gcc -static-libgcc",
|
221
|
+
"LDFLAGS" => "-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
|
222
|
+
"CFLAGS" => "-I/opt/project/embedded/include",
|
222
223
|
"CXXFLAGS" => "-I/opt/project/embedded/include",
|
223
224
|
"CPPFLAGS" => "-I/opt/project/embedded/include",
|
224
|
-
|
225
|
-
|
226
|
-
|
225
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
226
|
+
"LD_OPTIONS" => "-R/opt/project/embedded/lib -M #{project_root}/files/mapfile/solaris",
|
227
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
227
228
|
)
|
228
229
|
end
|
229
230
|
end
|
230
231
|
end
|
231
232
|
|
232
|
-
context
|
233
|
-
before { stub_ohai(platform:
|
233
|
+
context "on mac_os_x" do
|
234
|
+
before { stub_ohai(platform: "mac_os_x", version: "10.9.2") }
|
234
235
|
|
235
|
-
it
|
236
|
+
it "sets the defaults" do
|
236
237
|
expect(subject.with_standard_compiler_flags).to eq(
|
237
|
-
|
238
|
-
|
238
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib",
|
239
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
239
240
|
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
240
241
|
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
241
|
-
|
242
|
-
|
242
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
243
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
243
244
|
)
|
244
245
|
end
|
245
246
|
end
|
246
247
|
|
247
|
-
context
|
248
|
+
context "on aix" do
|
248
249
|
before do
|
249
250
|
# There's no AIX in Fauxhai :(
|
250
|
-
stub_ohai(platform:
|
251
|
-
data[
|
251
|
+
stub_ohai(platform: "solaris2", version: "5.11") do |data|
|
252
|
+
data["platform"] = "aix"
|
252
253
|
end
|
253
254
|
end
|
254
255
|
|
255
|
-
it
|
256
|
+
it "sets the defaults" do
|
256
257
|
expect(subject.with_standard_compiler_flags).to eq(
|
257
|
-
|
258
|
-
|
259
|
-
|
258
|
+
"CC" => "xlc_r -q64",
|
259
|
+
"CXX" => "xlC_r -q64",
|
260
|
+
"CFLAGS" => "-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O",
|
260
261
|
"CXXFLAGS" => "-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O",
|
261
262
|
"CPPFLAGS" => "-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O",
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
263
|
+
"LDFLAGS" => "-q64 -L/opt/project/embedded/lib -Wl,-blibpath:/opt/project/embedded/lib:/usr/lib:/lib",
|
264
|
+
"LD" => "ld -b64",
|
265
|
+
"OBJECT_MODE" => "64",
|
266
|
+
"ARFLAGS" => "-X64 cru",
|
267
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
268
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
268
269
|
)
|
269
270
|
end
|
270
271
|
end
|
271
272
|
|
272
|
-
context
|
273
|
+
context "on freebsd 9" do
|
273
274
|
before do
|
274
|
-
stub_ohai(platform:
|
275
|
+
stub_ohai(platform: "freebsd", version: "9.2")
|
275
276
|
end
|
276
277
|
|
277
|
-
it
|
278
|
+
it "sets the defaults" do
|
278
279
|
expect(subject.with_standard_compiler_flags).to eq(
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
280
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
281
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
282
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
283
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib",
|
284
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
285
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
285
286
|
)
|
286
287
|
end
|
287
288
|
|
288
|
-
context
|
289
|
+
context "with gcc 4.9 installed" do
|
289
290
|
before do
|
290
|
-
allow(subject).to receive(:which).and_return(
|
291
|
+
allow(subject).to receive(:which).and_return("/usr/local/bin/gcc49")
|
291
292
|
end
|
292
293
|
|
293
|
-
it
|
294
|
+
it "sets the compiler args" do
|
294
295
|
expect(subject.with_standard_compiler_flags).to eq(
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
296
|
+
"CC" => "gcc49",
|
297
|
+
"CXX" => "g++49",
|
298
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
299
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
300
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
301
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib",
|
302
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
303
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig" )
|
303
304
|
end
|
304
305
|
end
|
305
306
|
end
|
306
307
|
|
307
|
-
context
|
308
|
+
context "on freebsd 10" do
|
308
309
|
before do
|
309
|
-
stub_ohai(platform:
|
310
|
+
stub_ohai(platform: "freebsd", version: "10.0")
|
310
311
|
end
|
311
312
|
|
312
|
-
it
|
313
|
+
it "Clang as the default compiler" do
|
313
314
|
expect(subject.with_standard_compiler_flags).to eq(
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
315
|
+
"CC" => "clang",
|
316
|
+
"CXX" => "clang++",
|
317
|
+
"CFLAGS" => "-I/opt/project/embedded/include -O2",
|
318
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -O2",
|
319
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -O2",
|
320
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib",
|
321
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
322
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
322
323
|
)
|
323
324
|
end
|
324
325
|
end
|
325
326
|
|
326
|
-
context
|
327
|
+
context "on Windows" do
|
327
328
|
let(:win_arch_i386) { true }
|
328
329
|
|
329
330
|
before do
|
330
|
-
stub_ohai(platform:
|
331
|
+
stub_ohai(platform: "windows", version: "2012")
|
331
332
|
allow(subject).to receive(:windows_arch_i386?).and_return(win_arch_i386)
|
332
333
|
end
|
333
334
|
|
334
|
-
context
|
335
|
-
it
|
335
|
+
context "in 32-bit mode" do
|
336
|
+
it "sets the default" do
|
336
337
|
expect(subject.with_standard_compiler_flags).to eq(
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
)
|
344
|
-
end
|
345
|
-
|
346
|
-
it 'sets BFD flags if requested' do
|
347
|
-
expect(subject.with_standard_compiler_flags({}, bfd_flags: true)).to eq(
|
348
|
-
'CFLAGS' => '-I/opt/project/embedded/include -m32 -O3 -march=i686',
|
349
|
-
'CXXFLAGS' => '-I/opt/project/embedded/include -m32 -O3 -march=i686',
|
350
|
-
'CPPFLAGS' => '-I/opt/project/embedded/include -m32 -O3 -march=i686',
|
351
|
-
'LDFLAGS' => '-L/opt/project/embedded/lib -m32',
|
352
|
-
'RCFLAGS' => '--target=pe-i386',
|
353
|
-
'ARFLAGS' => '--target=pe-i386',
|
354
|
-
'LD_RUN_PATH' => '/opt/project/embedded/lib',
|
355
|
-
'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
|
338
|
+
"CFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
|
339
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
|
340
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
|
341
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib -m32 -fno-lto",
|
342
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
343
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
356
344
|
)
|
357
345
|
end
|
358
346
|
end
|
359
347
|
|
360
|
-
context
|
348
|
+
context "in 64-bit mode" do
|
361
349
|
let(:win_arch_i386) { false }
|
362
350
|
|
363
|
-
it
|
351
|
+
it "sets the default" do
|
364
352
|
expect(subject.with_standard_compiler_flags).to eq(
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
)
|
372
|
-
end
|
373
|
-
|
374
|
-
it 'sets BFD flags if requested' do
|
375
|
-
expect(subject.with_standard_compiler_flags({}, bfd_flags: true)).to eq(
|
376
|
-
'CFLAGS' => '-I/opt/project/embedded/include -m64 -O3 -march=x86-64',
|
377
|
-
'CXXFLAGS' => '-I/opt/project/embedded/include -m64 -O3 -march=x86-64',
|
378
|
-
'CPPFLAGS' => '-I/opt/project/embedded/include -m64 -O3 -march=x86-64',
|
379
|
-
'LDFLAGS' => '-L/opt/project/embedded/lib -m64',
|
380
|
-
'RCFLAGS' => '--target=pe-x86-64',
|
381
|
-
'ARFLAGS' => '--target=pe-x86-64',
|
382
|
-
'LD_RUN_PATH' => '/opt/project/embedded/lib',
|
383
|
-
'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
|
353
|
+
"CFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
|
354
|
+
"CXXFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
|
355
|
+
"CPPFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
|
356
|
+
"LDFLAGS" => "-L/opt/project/embedded/lib -m64 -fno-lto",
|
357
|
+
"LD_RUN_PATH" => "/opt/project/embedded/lib",
|
358
|
+
"PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
|
384
359
|
)
|
385
360
|
end
|
386
361
|
end
|
@@ -388,11 +363,11 @@ module Omnibus
|
|
388
363
|
|
389
364
|
end
|
390
365
|
|
391
|
-
describe
|
366
|
+
describe "path helpers" do
|
392
367
|
|
393
368
|
before do
|
394
|
-
stub_const(
|
395
|
-
stub_env(
|
369
|
+
stub_const("File::PATH_SEPARATOR", separator)
|
370
|
+
stub_env("PATH", path)
|
396
371
|
allow(project).to receive(:install_dir).and_return(install_dir)
|
397
372
|
end
|
398
373
|
|
@@ -400,109 +375,96 @@ module Omnibus
|
|
400
375
|
["#{install_dir}/bin", separator, "#{install_dir}/embedded/bin", separator, path].join
|
401
376
|
end
|
402
377
|
|
403
|
-
context
|
404
|
-
let(:separator) {
|
405
|
-
let(:path) {
|
406
|
-
let(:install_dir) {
|
378
|
+
context "on *Nix" do
|
379
|
+
let(:separator) { ":" }
|
380
|
+
let(:path) { "/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin" }
|
381
|
+
let(:install_dir) { "/opt/project" }
|
407
382
|
|
408
|
-
it
|
409
|
-
expect(subject.prepend_path(
|
410
|
-
[
|
383
|
+
it "prepends a path to PATH" do
|
384
|
+
expect(subject.prepend_path("/foo/bar")).to eq(
|
385
|
+
["/foo/bar", separator, path].join
|
411
386
|
)
|
412
387
|
end
|
413
388
|
|
414
|
-
it
|
389
|
+
it "prepends the embedded bin to PATH" do
|
415
390
|
expect(subject.with_embedded_path).to eq(
|
416
|
-
|
391
|
+
"PATH" => prepended_path
|
417
392
|
)
|
418
393
|
end
|
419
394
|
|
420
|
-
it
|
421
|
-
expect(subject.with_embedded_path(
|
422
|
-
|
423
|
-
|
395
|
+
it "with_embedded_path merges with a hash argument" do
|
396
|
+
expect(subject.with_embedded_path("numberwang" => 4)).to eq(
|
397
|
+
"numberwang" => 4,
|
398
|
+
"PATH" => prepended_path
|
424
399
|
)
|
425
400
|
end
|
426
401
|
|
427
|
-
it
|
428
|
-
expect(subject.
|
429
|
-
|
430
|
-
)
|
431
|
-
end
|
432
|
-
|
433
|
-
it 'prepends multiple paths to PATH' do
|
434
|
-
expect(subject.prepend_path('/foo/bar', '/foo/baz')).to eq(
|
435
|
-
['/foo/bar', separator, '/foo/baz', separator, path].join
|
402
|
+
it "prepends multiple paths to PATH" do
|
403
|
+
expect(subject.prepend_path("/foo/bar", "/foo/baz")).to eq(
|
404
|
+
["/foo/bar", separator, "/foo/baz", separator, path].join
|
436
405
|
)
|
437
406
|
end
|
438
407
|
end
|
439
408
|
|
440
|
-
context
|
409
|
+
context "on Windows" do
|
441
410
|
before do
|
442
|
-
stub_ohai(platform:
|
411
|
+
stub_ohai(platform: "windows", version: "2012")
|
443
412
|
end
|
444
413
|
|
445
|
-
let(:separator) {
|
446
|
-
let(:path) {
|
447
|
-
let(:install_dir) {
|
414
|
+
let(:separator) { ";" }
|
415
|
+
let(:path) { "c:/Ruby193/bin;c:/Windows/system32;c:/Windows;c:/Windows/System32/Wbem" }
|
416
|
+
let(:install_dir) { "c:/opt/project" }
|
448
417
|
let(:prepended_path_msys) do
|
449
418
|
[ "#{install_dir}/bin", separator, "#{install_dir}/embedded/bin", separator,
|
450
419
|
"#{install_dir}/embedded/msys/1.0/bin", separator, path].join
|
451
420
|
end
|
452
421
|
|
453
|
-
context
|
422
|
+
context "`Path` exists in the environment" do
|
454
423
|
before do
|
455
|
-
stub_env(
|
456
|
-
allow(ENV).to receive(:keys).and_return(%w
|
424
|
+
stub_env("Path", path)
|
425
|
+
allow(ENV).to receive(:keys).and_return(%w{ Path PATH })
|
457
426
|
end
|
458
427
|
|
459
|
-
it
|
428
|
+
it "returns a path key of `Path`" do
|
460
429
|
expect(subject.with_embedded_path).to eq(
|
461
|
-
|
430
|
+
"Path" => prepended_path
|
462
431
|
)
|
463
432
|
end
|
464
433
|
end
|
465
434
|
|
466
|
-
context
|
435
|
+
context "`Path` does not exist in the environment" do
|
467
436
|
before do
|
468
|
-
allow(ENV).to receive(:keys).and_return([
|
437
|
+
allow(ENV).to receive(:keys).and_return(["PATH"])
|
469
438
|
end
|
470
439
|
|
471
|
-
it
|
440
|
+
it "returns a path key of `PATH`" do
|
472
441
|
expect(subject.with_embedded_path).to eq(
|
473
|
-
|
474
|
-
)
|
475
|
-
end
|
476
|
-
|
477
|
-
it 'with_embedded_path accepts option to add msys to path' do
|
478
|
-
expect(subject.with_embedded_path({}, msys: true)).to eq(
|
479
|
-
'PATH' => prepended_path_msys
|
442
|
+
"PATH" => prepended_path
|
480
443
|
)
|
481
444
|
end
|
482
|
-
|
483
445
|
end
|
484
446
|
end
|
485
447
|
end
|
486
448
|
|
487
449
|
describe '#ohai' do
|
488
|
-
before { stub_ohai(platform:
|
450
|
+
before { stub_ohai(platform: "ubuntu", version: "12.04") }
|
489
451
|
|
490
|
-
it
|
452
|
+
it "is a DSL method" do
|
491
453
|
expect(subject).to have_exposed_method(:ohai)
|
492
454
|
end
|
493
455
|
|
494
|
-
it
|
456
|
+
it "delegates to the Ohai class" do
|
495
457
|
expect(subject.ohai).to be(Ohai)
|
496
458
|
end
|
497
459
|
end
|
498
460
|
|
499
461
|
describe "#manifest_entry" do
|
500
462
|
let(:a_source) do
|
501
|
-
{ url:
|
502
|
-
md5:
|
463
|
+
{ url: "http://example.com/",
|
464
|
+
md5: "abcd1234" }
|
503
465
|
end
|
504
466
|
|
505
|
-
let(:manifest_entry) {Omnibus::ManifestEntry.new("software", {locked_version: "1.2.8", locked_source: a_source})}
|
467
|
+
let(:manifest_entry) { Omnibus::ManifestEntry.new("software", { locked_version: "1.2.8", locked_source: a_source }) }
|
506
468
|
let(:manifest) do
|
507
469
|
m = Omnibus::Manifest.new
|
508
470
|
m.add(:software, manifest_entry)
|
@@ -510,25 +472,25 @@ module Omnibus
|
|
510
472
|
|
511
473
|
let(:project_with_manifest) do
|
512
474
|
described_class.new(project, nil, manifest).evaluate do
|
513
|
-
name
|
514
|
-
default_version
|
515
|
-
source url:
|
516
|
-
|
475
|
+
name "software"
|
476
|
+
default_version "1.2.3"
|
477
|
+
source url: "http://example.com/",
|
478
|
+
md5: "abcd1234"
|
517
479
|
end
|
518
480
|
end
|
519
481
|
|
520
482
|
let(:project_without_manifest) do
|
521
483
|
described_class.new(project, nil, nil).evaluate do
|
522
|
-
name
|
523
|
-
default_version
|
524
|
-
source url:
|
525
|
-
|
484
|
+
name "software"
|
485
|
+
default_version "1.2.3"
|
486
|
+
source url: "http://example.com/",
|
487
|
+
md5: "abcd1234"
|
526
488
|
end
|
527
489
|
end
|
528
490
|
|
529
491
|
let(:another_project) do
|
530
492
|
described_class.new(project, nil, manifest).evaluate do
|
531
|
-
name
|
493
|
+
name "ruroh"
|
532
494
|
end
|
533
495
|
end
|
534
496
|
|
@@ -550,99 +512,99 @@ module Omnibus
|
|
550
512
|
end
|
551
513
|
|
552
514
|
it "raises an error if it was given a manifest but can't find it's entry" do
|
553
|
-
expect{another_project.manifest_entry}.to raise_error(Manifest::MissingManifestEntry)
|
515
|
+
expect { another_project.manifest_entry }.to raise_error(Manifest::MissingManifestEntry)
|
554
516
|
end
|
555
517
|
end
|
556
518
|
|
557
519
|
describe '#<=>' do
|
558
|
-
let(:zlib) { described_class.new(project).tap { |s| s.name(
|
559
|
-
let(:erchef) { described_class.new(project).tap { |s| s.name(
|
560
|
-
let(:bacon) { described_class.new(project).tap { |s| s.name(
|
520
|
+
let(:zlib) { described_class.new(project).tap { |s| s.name("zlib") } }
|
521
|
+
let(:erchef) { described_class.new(project).tap { |s| s.name("erchef") } }
|
522
|
+
let(:bacon) { described_class.new(project).tap { |s| s.name("bacon") } }
|
561
523
|
|
562
|
-
it
|
524
|
+
it "compares projects by name" do
|
563
525
|
list = [zlib, erchef, bacon]
|
564
|
-
expect(list.sort.map(&:name)).to eq(%w
|
526
|
+
expect(list.sort.map(&:name)).to eq(%w{bacon erchef zlib})
|
565
527
|
end
|
566
528
|
end
|
567
529
|
|
568
530
|
describe '#whitelist_file' do
|
569
|
-
it
|
531
|
+
it "appends to the whitelist_files array" do
|
570
532
|
expect(subject.whitelist_files.size).to eq(0)
|
571
533
|
subject.whitelist_file(/foo\/bar/)
|
572
534
|
expect(subject.whitelist_files.size).to eq(1)
|
573
535
|
end
|
574
536
|
|
575
|
-
it
|
576
|
-
subject.whitelist_file
|
537
|
+
it "converts Strings to Regexp instances" do
|
538
|
+
subject.whitelist_file "foo/bar"
|
577
539
|
expect(subject.whitelist_files.size).to eq(1)
|
578
540
|
expect(subject.whitelist_files.first).to be_kind_of(Regexp)
|
579
541
|
end
|
580
542
|
end
|
581
543
|
|
582
|
-
context
|
583
|
-
context
|
584
|
-
it
|
585
|
-
expect(subject.version).to eq(
|
586
|
-
expect(subject.source).to eq(url:
|
544
|
+
context "testing repo-level version overrides" do
|
545
|
+
context "without overrides" do
|
546
|
+
it "returns the original values" do
|
547
|
+
expect(subject.version).to eq("1.2.3")
|
548
|
+
expect(subject.source).to eq(url: "http://example.com/", md5: "abcd1234")
|
587
549
|
end
|
588
550
|
end
|
589
551
|
|
590
|
-
context
|
591
|
-
before { project.override(:chaos_monkey, version:
|
552
|
+
context "with overrides for different software" do
|
553
|
+
before { project.override(:chaos_monkey, version: "1.2.8") }
|
592
554
|
|
593
|
-
it
|
594
|
-
expect(subject.version).to eq(
|
555
|
+
it "does not change the software" do
|
556
|
+
expect(subject.version).to eq("1.2.3")
|
595
557
|
end
|
596
558
|
end
|
597
559
|
|
598
|
-
context
|
599
|
-
context
|
600
|
-
let(:version) {
|
601
|
-
before { project.override(:software, version:
|
560
|
+
context "with overrides for this software" do
|
561
|
+
context "version" do
|
562
|
+
let(:version) { "2.0.0.pre" }
|
563
|
+
before { project.override(:software, version: "2.0.0.pre") }
|
602
564
|
|
603
|
-
it
|
565
|
+
it "returns the correct version" do
|
604
566
|
expect(subject.version).to eq(version)
|
605
567
|
end
|
606
568
|
end
|
607
569
|
|
608
|
-
context
|
609
|
-
let(:source) { { url:
|
570
|
+
context "source" do
|
571
|
+
let(:source) { { url: "http://new.example.com", md5: "defg5678" } }
|
610
572
|
before { project.override(:software, source: source) }
|
611
573
|
|
612
|
-
it
|
574
|
+
it "returns the correct source" do
|
613
575
|
expect(subject.source).to eq(source)
|
614
576
|
end
|
615
577
|
end
|
616
578
|
end
|
617
579
|
end
|
618
580
|
|
619
|
-
context
|
581
|
+
context "when software source is a github spec" do
|
620
582
|
let(:source) do
|
621
583
|
{
|
622
|
-
github:
|
584
|
+
github: "chef/ohai",
|
623
585
|
}
|
624
586
|
end
|
625
587
|
|
626
|
-
it
|
588
|
+
it "fetches from a fully expanded git path" do
|
627
589
|
expect(subject.source).to eq(git: "https://github.com/chef/ohai.git")
|
628
590
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", git: "https://github.com/chef/ohai.git").and_return("1.2.8")
|
629
591
|
subject.send(:fetcher)
|
630
592
|
end
|
631
593
|
|
632
|
-
context
|
594
|
+
context "and override source is a git spec" do
|
633
595
|
before { project.override(:software, source: { git: "https://blah.com/git.git" }) }
|
634
596
|
|
635
|
-
it
|
597
|
+
it "fetches from the override path" do
|
636
598
|
expect(subject.source).to eq(git: "https://blah.com/git.git")
|
637
599
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", git: "https://blah.com/git.git").and_return("1.2.8")
|
638
600
|
subject.send(:fetcher)
|
639
601
|
end
|
640
602
|
end
|
641
603
|
|
642
|
-
context
|
604
|
+
context "and override source is a github spec" do
|
643
605
|
before { project.override(:software, source: { github: "a/b" }) }
|
644
606
|
|
645
|
-
it
|
607
|
+
it "fetches from the override path" do
|
646
608
|
expect(subject.source).to eq(git: "https://github.com/a/b.git")
|
647
609
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", git: "https://github.com/a/b.git").and_return("1.2.8")
|
648
610
|
subject.send(:fetcher)
|
@@ -650,23 +612,23 @@ module Omnibus
|
|
650
612
|
end
|
651
613
|
end
|
652
614
|
|
653
|
-
context
|
615
|
+
context "when software source is a git spec" do
|
654
616
|
let(:source) do
|
655
617
|
{
|
656
|
-
git: "https://blah.com/git.git"
|
618
|
+
git: "https://blah.com/git.git",
|
657
619
|
}
|
658
620
|
end
|
659
621
|
|
660
|
-
it
|
622
|
+
it "fetches from the git spec" do
|
661
623
|
expect(subject.source).to eq(git: "https://blah.com/git.git")
|
662
624
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", git: "https://blah.com/git.git").and_return("1.2.8")
|
663
625
|
subject.send(:fetcher)
|
664
626
|
end
|
665
627
|
|
666
|
-
context
|
628
|
+
context "and override source is a github spec" do
|
667
629
|
before { project.override(:software, source: { github: "a/b" }) }
|
668
630
|
|
669
|
-
it
|
631
|
+
it "fetches from the override path" do
|
670
632
|
expect(subject.source).to eq(git: "https://github.com/a/b.git")
|
671
633
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", git: "https://github.com/a/b.git").and_return("1.2.8")
|
672
634
|
subject.send(:fetcher)
|
@@ -679,105 +641,105 @@ module Omnibus
|
|
679
641
|
expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", source).and_return("1.2.8")
|
680
642
|
end
|
681
643
|
|
682
|
-
context
|
644
|
+
context "when given a source url to an archive" do
|
683
645
|
let(:source) do
|
684
646
|
{
|
685
|
-
url:
|
686
|
-
md5:
|
647
|
+
url: "http://example.com/foo.tar.gz",
|
648
|
+
md5: "abcd1234",
|
687
649
|
}
|
688
650
|
end
|
689
651
|
|
690
|
-
context
|
691
|
-
let(:rel_path) {
|
652
|
+
context "when relative_path is the same as name" do
|
653
|
+
let(:rel_path) { "software" }
|
692
654
|
|
693
|
-
it
|
655
|
+
it "ignores back-compat and leaves fetch_dir alone" do
|
694
656
|
subject.send(:fetcher)
|
695
657
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
|
696
658
|
end
|
697
659
|
|
698
|
-
it
|
660
|
+
it "sets the fetcher project_dir to fetch_dir" do
|
699
661
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software"))
|
700
662
|
end
|
701
663
|
end
|
702
664
|
|
703
|
-
context
|
704
|
-
let(:rel_path) {
|
665
|
+
context "when relative_path is different from name" do
|
666
|
+
let(:rel_path) { "foo" }
|
705
667
|
|
706
|
-
it
|
668
|
+
it "ignores back-compat and leaves fetch_dir alone" do
|
707
669
|
subject.send(:fetcher)
|
708
670
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
|
709
671
|
end
|
710
672
|
|
711
|
-
it
|
673
|
+
it "sets the fetcher project_dir to fetch_dir" do
|
712
674
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software"))
|
713
675
|
end
|
714
676
|
end
|
715
677
|
end
|
716
678
|
|
717
|
-
context
|
679
|
+
context "when given source url is not an archive" do
|
718
680
|
let(:source) do
|
719
681
|
{
|
720
|
-
url:
|
721
|
-
md5:
|
682
|
+
url: "http://example.com/foo.txt",
|
683
|
+
md5: "abcd1234",
|
722
684
|
}
|
723
685
|
end
|
724
686
|
|
725
|
-
context
|
726
|
-
let(:rel_path) {
|
687
|
+
context "when relative_path is the same as name" do
|
688
|
+
let(:rel_path) { "software" }
|
727
689
|
|
728
|
-
it
|
690
|
+
it "for back-compat, changes fetch_dir" do
|
729
691
|
subject.send(:fetcher)
|
730
692
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
|
731
693
|
end
|
732
694
|
|
733
|
-
it
|
695
|
+
it "sets the fetcher project_dir to project_dir" do
|
734
696
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
|
735
697
|
end
|
736
698
|
end
|
737
699
|
|
738
|
-
context
|
739
|
-
let(:rel_path) {
|
700
|
+
context "when relative_path is different from name" do
|
701
|
+
let(:rel_path) { "foo" }
|
740
702
|
|
741
|
-
it
|
703
|
+
it "ignores back-compat and leaves fetch_dir alone" do
|
742
704
|
subject.send(:fetcher)
|
743
705
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
|
744
706
|
end
|
745
707
|
|
746
|
-
it
|
708
|
+
it "sets the fetcher project_dir to project_dir" do
|
747
709
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
|
748
710
|
end
|
749
711
|
end
|
750
712
|
end
|
751
713
|
|
752
|
-
context
|
714
|
+
context "when given source is a git repo" do
|
753
715
|
let(:source) do
|
754
716
|
{
|
755
|
-
git:
|
717
|
+
git: "http://example.com/my/git/repo",
|
756
718
|
}
|
757
719
|
end
|
758
720
|
|
759
|
-
context
|
760
|
-
let(:rel_path) {
|
721
|
+
context "when relative_path is the same as name" do
|
722
|
+
let(:rel_path) { "software" }
|
761
723
|
|
762
|
-
it
|
724
|
+
it "for back-compat, changes fetch_dir" do
|
763
725
|
subject.send(:fetcher)
|
764
726
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
|
765
727
|
end
|
766
728
|
|
767
|
-
it
|
729
|
+
it "sets the fetcher project_dir to project_dir" do
|
768
730
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
|
769
731
|
end
|
770
732
|
end
|
771
733
|
|
772
|
-
context
|
773
|
-
let(:rel_path) {
|
734
|
+
context "when relative_path is different from name" do
|
735
|
+
let(:rel_path) { "foo" }
|
774
736
|
|
775
|
-
it
|
737
|
+
it "ignores back-compat and leaves fetch_dir alone" do
|
776
738
|
subject.send(:fetcher)
|
777
739
|
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
|
778
740
|
end
|
779
741
|
|
780
|
-
it
|
742
|
+
it "sets the fetcher project_dir to project_dir" do
|
781
743
|
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
|
782
744
|
end
|
783
745
|
end
|
@@ -791,7 +753,7 @@ module Omnibus
|
|
791
753
|
it 'canonicalize_source(github: "chef/chef", submodules: true) yields git: "https://github.com/chef/chef.git", submodules: true' do
|
792
754
|
expect(subject.send(:canonicalize_source, github: "chef/chef", submodules: true)).to eq(git: "https://github.com/chef/chef.git", submodules: true)
|
793
755
|
end
|
794
|
-
it
|
756
|
+
it "canonicalize_source does not overwrite the original" do
|
795
757
|
original = { github: "chef/chef", submodules: true }
|
796
758
|
expect(subject.send(:canonicalize_source, original)).to eq(git: "https://github.com/chef/chef.git", submodules: true)
|
797
759
|
expect(original).to eq(github: "chef/chef", submodules: true)
|
@@ -799,8 +761,8 @@ module Omnibus
|
|
799
761
|
end
|
800
762
|
|
801
763
|
describe '#shasum' do
|
802
|
-
context
|
803
|
-
let(:path) {
|
764
|
+
context "when a filepath is given" do
|
765
|
+
let(:path) { "/software.rb" }
|
804
766
|
let(:file) { double(File) }
|
805
767
|
|
806
768
|
before { subject.instance_variable_set(:@filepath, path) }
|
@@ -814,16 +776,16 @@ module Omnibus
|
|
814
776
|
.and_return(file)
|
815
777
|
end
|
816
778
|
|
817
|
-
it
|
818
|
-
expect(subject.shasum).to eq(
|
779
|
+
it "returns the correct shasum" do
|
780
|
+
expect(subject.shasum).to eq("69dcce6da5580abe1da581e3f09d81e13ac676c48790eb0aa44d0ca2f93a16de")
|
819
781
|
end
|
820
782
|
end
|
821
783
|
|
822
|
-
context
|
784
|
+
context "when a filepath is not given" do
|
823
785
|
before { subject.send(:remove_instance_variable, :@filepath) }
|
824
786
|
|
825
|
-
it
|
826
|
-
expect(subject.shasum).to eq(
|
787
|
+
it "returns the correct shasum" do
|
788
|
+
expect(subject.shasum).to eq("acd88f56f17b7cbc146f351a9265b652bcf96d544821e7bc1e9663c80617276d")
|
827
789
|
end
|
828
790
|
end
|
829
791
|
end
|