autoproj 1.7.21.b1 → 1.7.21.b2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/autoproj_bootstrap +691 -513
- data/lib/autoproj/default.osdeps +4 -2
- data/lib/autoproj/manifest.rb +1 -2
- data/lib/autoproj/osdeps.rb +688 -516
- data/lib/autoproj/version.rb +1 -1
- data/test/package_managers/test_gem.rb +151 -0
- data/test/test_os_dependencies.rb +441 -0
- metadata +8 -4
data/lib/autoproj/version.rb
CHANGED
@@ -0,0 +1,151 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
2
|
+
require 'test/unit'
|
3
|
+
require 'autoproj'
|
4
|
+
require 'flexmock/test_unit'
|
5
|
+
|
6
|
+
class TC_OSDependencies_Gem < Test::Unit::TestCase
|
7
|
+
include Autoproj
|
8
|
+
FOUND_PACKAGES = Autoproj::OSDependencies::FOUND_PACKAGES
|
9
|
+
FOUND_NONEXISTENT = Autoproj::OSDependencies::FOUND_NONEXISTENT
|
10
|
+
|
11
|
+
attr_reader :gem_manager
|
12
|
+
attr_reader :gem_fetcher
|
13
|
+
attr_reader :gem_spec
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Autoproj::OSDependencies.operating_system = [['test', 'debian', 'default'], ['v1.0', 'v1', 'default']]
|
17
|
+
|
18
|
+
@gem_manager = PackageManagers::GemManager.new
|
19
|
+
@gem_fetcher = flexmock("fake gem fetcher")
|
20
|
+
gem_manager.gem_fetcher = gem_fetcher
|
21
|
+
@gem_spec = flexmock(Gem::Specification)
|
22
|
+
Autobuild.programs['gem'] = 'mygem'
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
super
|
28
|
+
PackageManagers::GemManager.with_prerelease = false
|
29
|
+
PackageManagers::GemManager.with_doc = false
|
30
|
+
Autobuild.programs['gem'] = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_filter_uptodate_packages_passes_prerelease_flag
|
34
|
+
fake_installed_package = flexmock("fake installed pgk0", :version => Gem::Version.new("1.0.0"))
|
35
|
+
PackageManagers::GemManager.with_prerelease = true
|
36
|
+
|
37
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0.9'))
|
38
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0.9')).and_return(fake_installed_package)
|
39
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, true).
|
40
|
+
and_return([[["pkg0", Gem::Version.new("1.1.0")], nil]])
|
41
|
+
assert_equal [['pkg0', '>= 0.9']], gem_manager.filter_uptodate_packages([['pkg0', '>= 0.9']])
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_filter_uptodate_packages_with_no_installed_package
|
45
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0'))
|
46
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0')).and_raise(Gem::LoadError)
|
47
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, false).
|
48
|
+
and_return([[["pkg0", Gem::Version.new("1.0.0")], nil]])
|
49
|
+
assert_equal [['pkg0']], gem_manager.filter_uptodate_packages([['pkg0']])
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_filter_uptodate_packages_passes_version_specification
|
53
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0.9'))
|
54
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0.9')).and_raise(Gem::LoadError)
|
55
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, false).
|
56
|
+
and_return([[["pkg0", Gem::Version.new("1.0.0")], nil]])
|
57
|
+
assert_equal [['pkg0', '>= 0.9']], gem_manager.filter_uptodate_packages([['pkg0', '>= 0.9']])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_filter_uptodate_packages_with_outdated_package
|
61
|
+
fake_installed_package = flexmock("fake installed pgk0", :version => Gem::Version.new("1.0.0"))
|
62
|
+
|
63
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0.9'))
|
64
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0.9')).and_return(fake_installed_package)
|
65
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, false).
|
66
|
+
and_return([[["pkg0", Gem::Version.new("1.1.0")], nil]])
|
67
|
+
assert_equal [['pkg0', '>= 0.9']], gem_manager.filter_uptodate_packages([['pkg0', '>= 0.9']])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_filter_uptodate_packages_with_same_package
|
71
|
+
fake_installed_package = flexmock("fake installed pgk0", :version => Gem::Version.new("1.0.0"))
|
72
|
+
|
73
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0'))
|
74
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0')).and_return(fake_installed_package)
|
75
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, false).
|
76
|
+
and_return([[["pkg0", Gem::Version.new("1.0.0")], nil]])
|
77
|
+
assert_equal [], gem_manager.filter_uptodate_packages([['pkg0']])
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_filter_uptodate_packages_with_newer_installed_package
|
81
|
+
fake_installed_package = flexmock("fake installed pgk0", :version => Gem::Version.new("1.1.0"))
|
82
|
+
|
83
|
+
dep = Gem::Dependency.new("pkg0", Gem::Requirement.new('>= 0.9'))
|
84
|
+
gem_spec.should_receive(:find_by_name).with('pkg0', Gem::Requirement.new('>= 0.9')).and_return(fake_installed_package)
|
85
|
+
gem_fetcher.should_receive("find_matching").with(dep, true, true, false).
|
86
|
+
and_return([[["pkg0", Gem::Version.new("1.0.0")], nil]])
|
87
|
+
assert_equal [], gem_manager.filter_uptodate_packages([['pkg0', '>= 0.9']])
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_install_packages
|
91
|
+
PackageManagers::GemManager.with_prerelease = false
|
92
|
+
PackageManagers::GemManager.with_doc = false
|
93
|
+
subprocess = flexmock(Autobuild::Subprocess)
|
94
|
+
|
95
|
+
packages = [['pkg0'], ['pkg1', '>= 0.5'], ['pkg2'], ['pkg3', '>= 0.9']]
|
96
|
+
subprocess.should_receive(:run).
|
97
|
+
with(any, any, 'mygem', 'install', '--no-rdoc', '--no-ri', 'pkg0', 'pkg2').once
|
98
|
+
subprocess.should_receive(:run).
|
99
|
+
with(any, any, 'mygem', 'install', '--no-rdoc', '--no-ri', 'pkg1', '-v', '>= 0.5').once
|
100
|
+
subprocess.should_receive(:run).
|
101
|
+
with(any, any, 'mygem', 'install', '--no-rdoc', '--no-ri', 'pkg3', '-v', '>= 0.9').once
|
102
|
+
gem_manager.install(packages)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_install_packages_with_doc
|
106
|
+
PackageManagers::GemManager.with_prerelease = false
|
107
|
+
PackageManagers::GemManager.with_doc = true
|
108
|
+
subprocess = flexmock(Autobuild::Subprocess)
|
109
|
+
|
110
|
+
packages = [['pkg0']]
|
111
|
+
subprocess.should_receive(:run).
|
112
|
+
with(any, any, 'mygem', 'install', 'pkg0').once
|
113
|
+
gem_manager.install([['pkg0']])
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_install_packages_with_prerelease
|
117
|
+
PackageManagers::GemManager.with_prerelease = true
|
118
|
+
PackageManagers::GemManager.with_doc = true
|
119
|
+
subprocess = flexmock(Autobuild::Subprocess)
|
120
|
+
|
121
|
+
subprocess.should_receive(:run).
|
122
|
+
with(any, any, 'mygem', 'install', '--prerelease', 'pkg0').once
|
123
|
+
gem_manager.install([['pkg0']])
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_install_packages_disabled_and_silent
|
127
|
+
PackageManagers::GemManager.with_prerelease = true
|
128
|
+
PackageManagers::GemManager.with_doc = true
|
129
|
+
subprocess = flexmock(Autobuild::Subprocess)
|
130
|
+
gem_manager.enabled = false
|
131
|
+
gem_manager.silent = true
|
132
|
+
|
133
|
+
subprocess.should_receive(:run).never
|
134
|
+
flexmock(STDIN).should_receive(:readline).never.and_return
|
135
|
+
gem_manager.install([['pkg0']])
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_install_packages_disabled_and_not_silent
|
139
|
+
PackageManagers::GemManager.with_prerelease = true
|
140
|
+
PackageManagers::GemManager.with_doc = true
|
141
|
+
subprocess = flexmock(Autobuild::Subprocess)
|
142
|
+
gem_manager.enabled = false
|
143
|
+
gem_manager.silent = false
|
144
|
+
|
145
|
+
subprocess.should_receive(:run).never
|
146
|
+
flexmock(STDIN).should_receive(:readline).once.and_return
|
147
|
+
gem_manager.install([['pkg0']])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
|
@@ -0,0 +1,441 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../', File.dirname(__FILE__))
|
3
|
+
require 'test/unit'
|
4
|
+
require 'autoproj'
|
5
|
+
require 'flexmock/test_unit'
|
6
|
+
|
7
|
+
require 'test/package_managers/test_gem'
|
8
|
+
|
9
|
+
class TC_OSDependencies < Test::Unit::TestCase
|
10
|
+
include Autoproj
|
11
|
+
FOUND_PACKAGES = Autoproj::OSDependencies::FOUND_PACKAGES
|
12
|
+
FOUND_NONEXISTENT = Autoproj::OSDependencies::FOUND_NONEXISTENT
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Autoproj::OSDependencies.operating_system = [['test', 'debian', 'default'], ['v1.0', 'v1', 'default']]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_supported_operating_system
|
19
|
+
Autoproj::OSDependencies.operating_system = [['test', 'debian', 'default'], ['v1.0', 'v1', 'default']]
|
20
|
+
assert(Autoproj::OSDependencies.supported_operating_system?)
|
21
|
+
Autoproj::OSDependencies.operating_system = [['test', 'default'], ['v1.0', 'v1', 'default']]
|
22
|
+
assert(!Autoproj::OSDependencies.supported_operating_system?)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_osdep(data)
|
26
|
+
osdeps = OSDependencies.new(data)
|
27
|
+
# Mock the package handlers
|
28
|
+
osdeps.os_package_handler = flexmock(PackageManagers::Manager.new)
|
29
|
+
osdeps.os_package_handler.should_receive('names').and_return(['apt-dpkg'])
|
30
|
+
osdeps.package_handlers.clear
|
31
|
+
osdeps.package_handlers['apt-dpkg'] = osdeps.os_package_handler
|
32
|
+
osdeps.package_handlers['gem'] = flexmock(PackageManagers::Manager.new)
|
33
|
+
osdeps.package_handlers['gem'].should_receive('names').and_return(['gem'])
|
34
|
+
flexmock(osdeps)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_resolve_package_calls_specific_formatting
|
38
|
+
data = { 'pkg' => {
|
39
|
+
'test' => {
|
40
|
+
'v1.0' => 'pkg1.0 blabla',
|
41
|
+
'v1.1' => 'pkg1.1 bloblo',
|
42
|
+
'default' => 'pkgdef'
|
43
|
+
}
|
44
|
+
} }
|
45
|
+
osdeps = create_osdep(data)
|
46
|
+
osdeps.os_package_handler.should_receive(:parse_package_entry).
|
47
|
+
and_return { |arg| arg.split(" ") }.once
|
48
|
+
|
49
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, [['pkg1.0', 'blabla']]]]
|
50
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_resolve_specific_os_name_and_version_single_package
|
54
|
+
data = { 'pkg' => {
|
55
|
+
'test' => {
|
56
|
+
'v1.0' => 'pkg1.0',
|
57
|
+
'v1.1' => 'pkg1.1',
|
58
|
+
'default' => 'pkgdef'
|
59
|
+
}
|
60
|
+
} }
|
61
|
+
osdeps = create_osdep(data)
|
62
|
+
|
63
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1.0']]]
|
64
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_resolve_specific_os_name_and_version_package_list
|
68
|
+
data = { 'pkg' => {
|
69
|
+
'test' => {
|
70
|
+
'v1.0' => ['pkg1.0', 'other_pkg'],
|
71
|
+
'v1.1' => 'pkg1.1',
|
72
|
+
'default' => 'pkgdef'
|
73
|
+
}
|
74
|
+
} }
|
75
|
+
osdeps = create_osdep(data)
|
76
|
+
|
77
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1.0', 'other_pkg']]]
|
78
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_resolve_specific_os_name_and_version_ignore
|
82
|
+
data = { 'pkg' => {
|
83
|
+
'test' => {
|
84
|
+
'v1.0' => 'ignore',
|
85
|
+
'v1.1' => 'pkg1.1',
|
86
|
+
'default' => 'pkgdef'
|
87
|
+
}
|
88
|
+
} }
|
89
|
+
osdeps = create_osdep(data)
|
90
|
+
|
91
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, []]]
|
92
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_resolve_specific_os_name_and_version_fallback
|
96
|
+
data = { 'pkg' => {
|
97
|
+
'test' => {
|
98
|
+
'v1.1' => 'pkg1.1',
|
99
|
+
'default' => 'pkgdef'
|
100
|
+
}
|
101
|
+
} }
|
102
|
+
osdeps = create_osdep(data)
|
103
|
+
|
104
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkgdef']]]
|
105
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_resolve_specific_os_name_and_version_nonexistent
|
109
|
+
data = { 'pkg' => {
|
110
|
+
'test' => {
|
111
|
+
'v1.0' => 'nonexistent',
|
112
|
+
'v1.1' => 'pkg1.1',
|
113
|
+
'default' => 'pkgdef'
|
114
|
+
}
|
115
|
+
} }
|
116
|
+
osdeps = create_osdep(data)
|
117
|
+
|
118
|
+
expected = [[osdeps.os_package_handler, FOUND_NONEXISTENT, []]]
|
119
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_resolve_specific_os_name_and_version_not_found
|
123
|
+
data = { 'pkg' => {
|
124
|
+
'test' => { 'v1.1' => 'pkg1.1', }
|
125
|
+
} }
|
126
|
+
osdeps = create_osdep(data)
|
127
|
+
assert_equal [], osdeps.resolve_package('pkg')
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_resolve_specific_os_name_single_package
|
131
|
+
data = { 'pkg' => { 'test' => 'pkg1.0', 'other_test' => 'pkg1.1', 'default' => 'pkgdef' } }
|
132
|
+
osdeps = create_osdep(data)
|
133
|
+
|
134
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1.0']]]
|
135
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_resolve_specific_os_name_package_list
|
139
|
+
data = { 'pkg' => { 'test' => ['pkg1.0', 'other_pkg'], 'other_test' => 'pkg1.1', 'default' => 'pkgdef' } }
|
140
|
+
osdeps = create_osdep(data)
|
141
|
+
|
142
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1.0', 'other_pkg']]]
|
143
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_resolve_specific_os_name_ignore
|
147
|
+
data = { 'pkg' => { 'test' => 'ignore', 'other_test' => 'pkg1.1', 'default' => 'pkgdef' } }
|
148
|
+
osdeps = create_osdep(data)
|
149
|
+
|
150
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, []]]
|
151
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_resolve_specific_os_name_fallback
|
155
|
+
data = { 'pkg' => { 'other_test' => 'pkg1.1', 'default' => 'pkgdef' } }
|
156
|
+
osdeps = create_osdep(data)
|
157
|
+
|
158
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['pkgdef']]]
|
159
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_resolve_specific_os_name_and_version_nonexistent
|
163
|
+
data = { 'pkg' => { 'test' => 'nonexistent', 'other_test' => 'pkg1.1' } }
|
164
|
+
osdeps = create_osdep(data)
|
165
|
+
|
166
|
+
expected = [[osdeps.os_package_handler, FOUND_NONEXISTENT, []]]
|
167
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_resolve_specific_os_name_and_version_not_found
|
171
|
+
data = { 'pkg' => { 'other_test' => 'pkg1.1' } }
|
172
|
+
osdeps = create_osdep(data)
|
173
|
+
|
174
|
+
assert_equal [], osdeps.resolve_package('pkg')
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_resolve_os_name_global_and_specific_packages
|
178
|
+
data = { 'pkg' => [
|
179
|
+
'global_pkg1', 'global_pkg2',
|
180
|
+
{ 'test' => 'pkg1.1',
|
181
|
+
'other_test' => 'pkg1.1',
|
182
|
+
'default' => 'nonexistent'
|
183
|
+
}
|
184
|
+
]}
|
185
|
+
osdeps = create_osdep(data)
|
186
|
+
|
187
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2', 'pkg1.1']]]
|
188
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_resolve_os_name_global_and_specific_does_not_exist
|
192
|
+
data = { 'pkg' => [
|
193
|
+
'global_pkg1', 'global_pkg2',
|
194
|
+
{
|
195
|
+
'other_test' => 'pkg1.1',
|
196
|
+
}
|
197
|
+
]}
|
198
|
+
osdeps = create_osdep(data)
|
199
|
+
|
200
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2']]]
|
201
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_resolve_os_name_global_and_nonexistent
|
205
|
+
data = { 'pkg' => [
|
206
|
+
'global_pkg1', 'global_pkg2',
|
207
|
+
{ 'test' => 'nonexistent',
|
208
|
+
'other_test' => 'pkg1.1'
|
209
|
+
}
|
210
|
+
]}
|
211
|
+
osdeps = create_osdep(data)
|
212
|
+
|
213
|
+
expected = [[osdeps.os_package_handler, FOUND_NONEXISTENT, ['global_pkg1', 'global_pkg2']]]
|
214
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_resolve_os_name_global_and_ignore
|
218
|
+
data = { 'pkg' => [
|
219
|
+
'global_pkg1', 'global_pkg2',
|
220
|
+
{ 'test' => 'ignore',
|
221
|
+
'other_test' => 'pkg1.1'
|
222
|
+
}
|
223
|
+
]}
|
224
|
+
osdeps = create_osdep(data)
|
225
|
+
|
226
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2']]]
|
227
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_resolve_os_version_global_and_specific_packages
|
231
|
+
data = { 'pkg' => [
|
232
|
+
'global_pkg1', 'global_pkg2',
|
233
|
+
{ 'test' => ['pkg0', 'pkg1', { 'v1.0' => 'pkg1.0' }],
|
234
|
+
'other_test' => 'pkg1.1',
|
235
|
+
'default' => 'nonexistent'
|
236
|
+
}
|
237
|
+
]}
|
238
|
+
osdeps = create_osdep(data)
|
239
|
+
|
240
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2', 'pkg0', 'pkg1', 'pkg1.0']]]
|
241
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_resolve_os_version_global_and_specific_nonexistent
|
245
|
+
data = { 'pkg' => [
|
246
|
+
'global_pkg1', 'global_pkg2',
|
247
|
+
{ 'test' => ['pkg0', 'pkg1', { 'v1.0' => 'nonexistent' }],
|
248
|
+
'other_test' => 'pkg1.1',
|
249
|
+
'default' => 'nonexistent'
|
250
|
+
}
|
251
|
+
]}
|
252
|
+
osdeps = create_osdep(data)
|
253
|
+
|
254
|
+
expected = [[osdeps.os_package_handler, FOUND_NONEXISTENT, ['global_pkg1', 'global_pkg2', 'pkg0', 'pkg1']]]
|
255
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_resolve_os_version_global_and_specific_ignore
|
259
|
+
data = { 'pkg' => [
|
260
|
+
'global_pkg1', 'global_pkg2',
|
261
|
+
{ 'test' => ['pkg0', 'pkg1', { 'v1.0' => 'ignore' }],
|
262
|
+
'other_test' => 'pkg1.1',
|
263
|
+
'default' => 'nonexistent'
|
264
|
+
}
|
265
|
+
]}
|
266
|
+
osdeps = create_osdep(data)
|
267
|
+
|
268
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2', 'pkg0', 'pkg1']]]
|
269
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_resolve_os_version_global_and_specific_does_not_exist
|
273
|
+
data = { 'pkg' => [
|
274
|
+
'global_pkg1', 'global_pkg2',
|
275
|
+
{ 'test' => ['pkg0', 'pkg1', { 'v1.1' => 'pkg1.1' }],
|
276
|
+
'other_test' => 'pkg1.1',
|
277
|
+
'default' => 'nonexistent'
|
278
|
+
}
|
279
|
+
]}
|
280
|
+
osdeps = create_osdep(data)
|
281
|
+
|
282
|
+
expected = [[osdeps.os_package_handler, FOUND_PACKAGES, ['global_pkg1', 'global_pkg2', 'pkg0', 'pkg1']]]
|
283
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_resolve_osindep_packages_global
|
287
|
+
data = { 'pkg' => 'gem' }
|
288
|
+
osdeps = create_osdep(data)
|
289
|
+
expected = [[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['pkg']]]
|
290
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
291
|
+
|
292
|
+
data = { 'pkg' => { 'gem' => 'gempkg' }}
|
293
|
+
osdeps = create_osdep(data)
|
294
|
+
expected = [[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg']]]
|
295
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
296
|
+
|
297
|
+
data = { 'pkg' => { 'gem' => ['gempkg', 'gempkg1'] }}
|
298
|
+
osdeps = create_osdep(data)
|
299
|
+
expected = [[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg', 'gempkg1']]]
|
300
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_resolve_osindep_packages_specific
|
304
|
+
data = { 'pkg' => ['gem', { 'test' => { 'gem' => 'gempkg' } } ] }
|
305
|
+
osdeps = create_osdep(data)
|
306
|
+
expected = [[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['pkg', 'gempkg']]]
|
307
|
+
assert_equal expected, osdeps.resolve_package('pkg')
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_availability_of
|
311
|
+
osdeps = flexmock(OSDependencies.new)
|
312
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
313
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1']],
|
314
|
+
[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg1']]])
|
315
|
+
assert_equal OSDependencies::AVAILABLE, osdeps.availability_of('pkg0')
|
316
|
+
|
317
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
318
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, []],
|
319
|
+
[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg1']]])
|
320
|
+
assert_equal OSDependencies::AVAILABLE, osdeps.availability_of('pkg0')
|
321
|
+
|
322
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
323
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, []],
|
324
|
+
[osdeps.package_handlers['gem'], FOUND_PACKAGES, []]])
|
325
|
+
assert_equal OSDependencies::IGNORE, osdeps.availability_of('pkg0')
|
326
|
+
|
327
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
328
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1']],
|
329
|
+
[osdeps.package_handlers['gem'], FOUND_NONEXISTENT, []]])
|
330
|
+
assert_equal OSDependencies::NONEXISTENT, osdeps.availability_of('pkg0')
|
331
|
+
|
332
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return([])
|
333
|
+
assert_equal OSDependencies::WRONG_OS, osdeps.availability_of('pkg0')
|
334
|
+
|
335
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(nil)
|
336
|
+
assert_equal OSDependencies::NO_PACKAGE, osdeps.availability_of('pkg0')
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_has_p
|
340
|
+
osdeps = flexmock(OSDependencies.new)
|
341
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
342
|
+
and_return(OSDependencies::AVAILABLE)
|
343
|
+
assert(osdeps.has?('pkg0'))
|
344
|
+
|
345
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
346
|
+
and_return(OSDependencies::IGNORE)
|
347
|
+
assert(osdeps.has?('pkg0'))
|
348
|
+
|
349
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
350
|
+
and_return(OSDependencies::UNKNOWN_OS)
|
351
|
+
assert(!osdeps.has?('pkg0'))
|
352
|
+
|
353
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
354
|
+
and_return(OSDependencies::WRONG_OS)
|
355
|
+
assert(!osdeps.has?('pkg0'))
|
356
|
+
|
357
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
358
|
+
and_return(OSDependencies::NONEXISTENT)
|
359
|
+
assert(!osdeps.has?('pkg0'))
|
360
|
+
|
361
|
+
osdeps.should_receive(:availability_of).with('pkg0').once.
|
362
|
+
and_return(OSDependencies::NO_PACKAGE)
|
363
|
+
assert(!osdeps.has?('pkg0'))
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_resolve_os_dependencies
|
367
|
+
osdeps = flexmock(OSDependencies.new)
|
368
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
369
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg0']]])
|
370
|
+
osdeps.should_receive(:resolve_package).with('pkg1').once.and_return(
|
371
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1']],
|
372
|
+
[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg1']]])
|
373
|
+
osdeps.should_receive(:resolve_package).with('pkg2').once.and_return(
|
374
|
+
[[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg2']]])
|
375
|
+
expected =
|
376
|
+
[[osdeps.os_package_handler, ['pkg0', 'pkg1']],
|
377
|
+
[osdeps.package_handlers['gem'], ['gempkg1', 'gempkg2']]]
|
378
|
+
assert_equal expected, osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2'])
|
379
|
+
|
380
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
381
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg0']]])
|
382
|
+
osdeps.should_receive(:resolve_package).with('pkg1').once.and_return(
|
383
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, []]])
|
384
|
+
osdeps.should_receive(:resolve_package).with('pkg2').once.and_return(
|
385
|
+
[[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg2']]])
|
386
|
+
expected =
|
387
|
+
[[osdeps.os_package_handler, ['pkg0']],
|
388
|
+
[osdeps.package_handlers['gem'], ['gempkg2']]]
|
389
|
+
assert_equal expected, osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2'])
|
390
|
+
|
391
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(nil)
|
392
|
+
osdeps.should_receive(:resolve_package).with('pkg1').never
|
393
|
+
osdeps.should_receive(:resolve_package).with('pkg2').never
|
394
|
+
assert_raises(ConfigError) { osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2']) }
|
395
|
+
|
396
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
397
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg0']]])
|
398
|
+
osdeps.should_receive(:resolve_package).with('pkg1').once.and_return(
|
399
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1']],
|
400
|
+
[osdeps.package_handlers['gem'], FOUND_PACKAGES, ['gempkg1']]])
|
401
|
+
osdeps.should_receive(:resolve_package).with('pkg2').once.and_return(nil)
|
402
|
+
expected =
|
403
|
+
[[osdeps.os_package_handler, ['pkg0']],
|
404
|
+
[osdeps.package_handlers['gem'], ['gempkg1', 'gempkg2']]]
|
405
|
+
assert_raises(ConfigError) { osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2']) }
|
406
|
+
|
407
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
408
|
+
[[osdeps.os_package_handler, FOUND_NONEXISTENT, ['pkg0']]])
|
409
|
+
osdeps.should_receive(:resolve_package).with('pkg1').never
|
410
|
+
osdeps.should_receive(:resolve_package).with('pkg2').never
|
411
|
+
assert_raises(ConfigError) { osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2']) }
|
412
|
+
|
413
|
+
osdeps.should_receive(:resolve_package).with('pkg0').once.and_return(
|
414
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg0']]])
|
415
|
+
osdeps.should_receive(:resolve_package).with('pkg1').once.and_return(
|
416
|
+
[[osdeps.os_package_handler, FOUND_PACKAGES, ['pkg1']],
|
417
|
+
[osdeps.package_handlers['gem'], FOUND_NONEXISTENT, ['gempkg1']]])
|
418
|
+
osdeps.should_receive(:resolve_package).with('pkg2').never
|
419
|
+
assert_raises(ConfigError) { osdeps.resolve_os_dependencies(['pkg0', 'pkg1', 'pkg2']) }
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_install
|
423
|
+
osdeps = create_osdep(Hash.new)
|
424
|
+
osdeps.should_receive(:resolve_os_dependencies).
|
425
|
+
once.with(['pkg0', 'pkg1', 'pkg2'].to_set).
|
426
|
+
and_return([[osdeps.os_package_handler, ['os0.1', 'os0.2', 'os1']],
|
427
|
+
[osdeps.package_handlers['gem'], [['gem2', '>= 0.9']]]])
|
428
|
+
osdeps.os_package_handler.should_receive(:filter_uptodate_packages).
|
429
|
+
with(['os0.1', 'os0.2', 'os1']).and_return(['os0.1', 'os1']).once
|
430
|
+
# Do not add filter_uptodate_packages to the gem handler to check that
|
431
|
+
# #install deals with that just fine
|
432
|
+
osdeps.os_package_handler.should_receive(:install).
|
433
|
+
with(['os0.1', 'os1'])
|
434
|
+
osdeps.package_handlers['gem'].should_receive(:install).
|
435
|
+
with([['gem2', '>= 0.9']])
|
436
|
+
|
437
|
+
osdeps.osdeps_mode = 'all'
|
438
|
+
osdeps.install(['pkg0', 'pkg1', 'pkg2'])
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|