RDI 0.1.0.20091020
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +3 -0
- data/ChangeLog +46 -0
- data/Credits +21 -0
- data/LICENSE +31 -0
- data/README +18 -0
- data/TODO +17 -0
- data/lib/rdi/Installer.rb +678 -0
- data/lib/rdi/Model/ContextModifier.rb +20 -0
- data/lib/rdi/Model/DependencyDescription.rb +154 -0
- data/lib/rdi/Model/DependencyUserChoice.rb +202 -0
- data/lib/rdi/Model/Installer.rb +24 -0
- data/lib/rdi/Model/LocationSelector.rb +16 -0
- data/lib/rdi/Model/ProgressView.rb +16 -0
- data/lib/rdi/Model/Tester.rb +20 -0
- data/lib/rdi/Model/View.rb +16 -0
- data/lib/rdi/Plugins/ContextModifiers/GemPath.desc.rb +13 -0
- data/lib/rdi/Plugins/ContextModifiers/GemPath.rb +106 -0
- data/lib/rdi/Plugins/ContextModifiers/LibraryPath.rb +74 -0
- data/lib/rdi/Plugins/ContextModifiers/RubyLoadPath.rb +76 -0
- data/lib/rdi/Plugins/ContextModifiers/SystemPath.rb +74 -0
- data/lib/rdi/Plugins/GemCommon.rb +127 -0
- data/lib/rdi/Plugins/Installers/Download.rb +72 -0
- data/lib/rdi/Plugins/Installers/DownloadAndInstall.desc.rb +11 -0
- data/lib/rdi/Plugins/Installers/DownloadAndInstall.rb +54 -0
- data/lib/rdi/Plugins/Installers/Gem.desc.rb +13 -0
- data/lib/rdi/Plugins/Installers/Gem.rb +67 -0
- data/lib/rdi/Plugins/Installers/Icons/Download.png +0 -0
- data/lib/rdi/Plugins/Installers/Icons/DownloadAndInstall.png +0 -0
- data/lib/rdi/Plugins/Installers/Icons/Gem.png +0 -0
- data/lib/rdi/Plugins/Installers/Yum.rb +52 -0
- data/lib/rdi/Plugins/ProgressViews/SimpleWxGUI.desc.rb +13 -0
- data/lib/rdi/Plugins/ProgressViews/SimpleWxGUI.rb +58 -0
- data/lib/rdi/Plugins/ProgressViews/Text.rb +68 -0
- data/lib/rdi/Plugins/RubyGemsDepDesc.rb +41 -0
- data/lib/rdi/Plugins/Testers/Binaries.rb +56 -0
- data/lib/rdi/Plugins/Testers/DynamicLibraries.rb +56 -0
- data/lib/rdi/Plugins/Testers/RubyRequires.rb +76 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/DependenciesLoaderDialog.rb +147 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/DependencyPanel.rb +301 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/Dependency.png +0 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/Ignore.png +0 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/ValidKO.png +0 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/ValidOK.png +0 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/LocationSelectors/Directory.desc.rb +13 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI/LocationSelectors/Directory.rb +45 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI.desc.rb +13 -0
- data/lib/rdi/Plugins/Views/SimpleWxGUI.rb +60 -0
- data/lib/rdi/Plugins/Views/Text/LocationSelectors/Directory.rb +44 -0
- data/lib/rdi/Plugins/Views/Text.rb +257 -0
- data/lib/rdi/Plugins/WxCommon.rb +69 -0
- data/lib/rdi/Plugins/WxRubyDepDesc.rb +36 -0
- data/lib/rdi/rdi.rb +8 -0
- data/test/Common.rb +796 -0
- data/test/Flows/BasicFlows.rb +114 -0
- data/test/Flows/UIFlows.rb +460 -0
- data/test/Plugins/ContextModifiers/GemPath.rb +44 -0
- data/test/Plugins/ContextModifiers/LibraryPath.rb +36 -0
- data/test/Plugins/ContextModifiers/RubyLoadPath.rb +36 -0
- data/test/Plugins/ContextModifiers/SystemPath.rb +36 -0
- data/test/Plugins/Installers/Download.rb +65 -0
- data/test/Plugins/Installers/DownloadAndInstall.rb +73 -0
- data/test/Plugins/Installers/Gem.rb +79 -0
- data/test/Plugins/LocationSelectors/Directory.rb +34 -0
- data/test/Plugins/Testers/Binaries.rb +46 -0
- data/test/Plugins/Testers/DynamicLibraries.rb +46 -0
- data/test/Plugins/Testers/RubyRequires.rb +48 -0
- data/test/Plugins/Views/SimpleWxGUI.rb +190 -0
- data/test/Plugins/Views/Text.rb +112 -0
- data/test/Plugins/WxEnv.rb +58 -0
- data/test/Plugins/WxEnvApp.rb +53 -0
- data/test/Repository/Binaries/DummyBinary +1 -0
- data/test/Repository/Libraries/DummyLibrary.so +1 -0
- data/test/Repository/RubyGems/DummyGem-0.0.1.20090828.gem +0 -0
- data/test/Repository/RubyGems/GemsSources/DummyGem/DummyGem.gemspec.rb +23 -0
- data/test/Repository/RubyGems/GemsSources/DummyGem/lib/DummyGemMain.rb +5 -0
- data/test/Repository/RubyLibraries/DummyRubyLib.rb +1 -0
- data/test/run.rb +23 -0
- metadata +145 -0
data/test/Common.rb
ADDED
@@ -0,0 +1,796 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
|
3
|
+
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
|
+
#++
|
5
|
+
|
6
|
+
# This file is intended to be required by every test case.
|
7
|
+
|
8
|
+
require 'RUtilAnts/Logging'
|
9
|
+
RUtilAnts::Logging::initializeLogging("#{File.dirname(__FILE__)}/../lib", 'http://sourceforge.net/tracker/?group_id=274498&atid=1166448', true)
|
10
|
+
require 'RUtilAnts/URLAccess'
|
11
|
+
RUtilAnts::URLAccess::initializeURLAccess
|
12
|
+
require 'RUtilAnts/Platform'
|
13
|
+
RUtilAnts::Platform::initializePlatform
|
14
|
+
|
15
|
+
require 'tmpdir'
|
16
|
+
require 'test/unit'
|
17
|
+
require 'rdi/rdi'
|
18
|
+
require 'rdi/Model/View'
|
19
|
+
require 'rdi/Model/ProgressView'
|
20
|
+
require 'rdi/Model/LocationSelector'
|
21
|
+
|
22
|
+
module RDI
|
23
|
+
|
24
|
+
module Test
|
25
|
+
|
26
|
+
# Mute progress view
|
27
|
+
class MuteProgressView < RDI::Model::ProgressView
|
28
|
+
|
29
|
+
# Setup the progress and call the client code to execute inside
|
30
|
+
#
|
31
|
+
# Parameters:
|
32
|
+
# * _CodeBlock_: The code to execute during this progression:
|
33
|
+
# ** *ioProgressView* (_Object_): The progress view that will receive notifications of progression (can be nil if no progression view available)
|
34
|
+
def setupProgress
|
35
|
+
yield(nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class RDITestCase < ::Test::Unit::TestCase
|
41
|
+
|
42
|
+
# Get a simple description to use in these test cases
|
43
|
+
#
|
44
|
+
# Return:
|
45
|
+
# * <em>RDI::Model::DependencyDescription</em>: The description
|
46
|
+
def getSimpleDesc
|
47
|
+
return RDI::Model::DependencyDescription.new('DummyBinary').addDescription( {
|
48
|
+
:Testers => [
|
49
|
+
{
|
50
|
+
:Type => 'Binaries',
|
51
|
+
:Content => [ 'DummyBinary' ]
|
52
|
+
}
|
53
|
+
],
|
54
|
+
:Installers => [
|
55
|
+
{
|
56
|
+
:Type => 'Download',
|
57
|
+
:Content => "#{@RepositoryDir}/Binaries/DummyBinary",
|
58
|
+
:ContextModifiers => [
|
59
|
+
{
|
60
|
+
:Type => 'SystemPath',
|
61
|
+
:Content => '%INSTALLDIR%'
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
]
|
66
|
+
} )
|
67
|
+
end
|
68
|
+
|
69
|
+
# Get another simple description to use in these test cases
|
70
|
+
#
|
71
|
+
# Return:
|
72
|
+
# * <em>RDI::Model::DependencyDescription</em>: The description
|
73
|
+
def getSimpleDesc2
|
74
|
+
return RDI::Model::DependencyDescription.new('DummyLibrary').addDescription( {
|
75
|
+
:Testers => [
|
76
|
+
{
|
77
|
+
:Type => 'DynamicLibraries',
|
78
|
+
:Content => [ 'DummyLibrary.so' ]
|
79
|
+
}
|
80
|
+
],
|
81
|
+
:Installers => [
|
82
|
+
{
|
83
|
+
:Type => 'Download',
|
84
|
+
:Content => "#{@RepositoryDir}/Libraries/DummyLibrary.so",
|
85
|
+
:ContextModifiers => [
|
86
|
+
{
|
87
|
+
:Type => 'LibraryPath',
|
88
|
+
:Content => '%INSTALLDIR%'
|
89
|
+
}
|
90
|
+
]
|
91
|
+
}
|
92
|
+
]
|
93
|
+
} )
|
94
|
+
end
|
95
|
+
|
96
|
+
# Get a simple description using 2 Installers
|
97
|
+
#
|
98
|
+
# Return:
|
99
|
+
# * <em>RDI::Model::DependencyDescription</em>: The description
|
100
|
+
def get2InstallersDesc
|
101
|
+
return RDI::Model::DependencyDescription.new('DummyBinary2').addDescription( {
|
102
|
+
:Testers => [
|
103
|
+
{
|
104
|
+
:Type => 'Binaries',
|
105
|
+
:Content => [ 'DummyBinary' ]
|
106
|
+
}
|
107
|
+
],
|
108
|
+
:Installers => [
|
109
|
+
{
|
110
|
+
:Type => 'Download',
|
111
|
+
:Content => "#{@RepositoryDir}/Binaries/DummyBinary",
|
112
|
+
:ContextModifiers => [
|
113
|
+
{
|
114
|
+
:Type => 'SystemPath',
|
115
|
+
:Content => '%INSTALLDIR%'
|
116
|
+
}
|
117
|
+
]
|
118
|
+
},
|
119
|
+
{
|
120
|
+
:Type => 'Download',
|
121
|
+
:Content => "#{@RepositoryDir}/Binaries/../Binaries/DummyBinary",
|
122
|
+
:ContextModifiers => [
|
123
|
+
{
|
124
|
+
:Type => 'SystemPath',
|
125
|
+
:Content => '%INSTALLDIR%'
|
126
|
+
}
|
127
|
+
]
|
128
|
+
}
|
129
|
+
]
|
130
|
+
} )
|
131
|
+
end
|
132
|
+
|
133
|
+
# Constructor
|
134
|
+
def setup
|
135
|
+
@RepositoryDir = File.expand_path("#{File.dirname(__FILE__)}/Repository")
|
136
|
+
@Installer = nil
|
137
|
+
# Silent user interaction of logging
|
138
|
+
@MessagesStack = []
|
139
|
+
setLogMessagesStack(@MessagesStack)
|
140
|
+
@ErrorsStack = []
|
141
|
+
setLogErrorsStack(@ErrorsStack)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Define a dummy test case to avoid errors during run of this class
|
145
|
+
# TODO: Remove this method
|
146
|
+
def testDummy_BaseClass
|
147
|
+
end
|
148
|
+
|
149
|
+
# Setup an applicative directory and an installer
|
150
|
+
#
|
151
|
+
# Parameters:
|
152
|
+
# * *CodeBlock*: The code called once the application is ready
|
153
|
+
def setupAppDir
|
154
|
+
# Get an image of the context, as we will put it back after the testing
|
155
|
+
lSystemPath = $rUtilAnts_Platform_Info.getSystemExePath.clone
|
156
|
+
lLibsPath = $rUtilAnts_Platform_Info.getSystemLibsPath.clone
|
157
|
+
lLoadPath = $LOAD_PATH.clone
|
158
|
+
lGemsPath = nil
|
159
|
+
if (defined?(Gem) != nil)
|
160
|
+
lGemsPath = Gem.path.clone
|
161
|
+
if (defined?(Gem.clearCache_RDI))
|
162
|
+
Gem.clearCache_RDI
|
163
|
+
end
|
164
|
+
end
|
165
|
+
# Create the application root directory for testing
|
166
|
+
lAppRootDir = "#{Dir.tmpdir}/RDITest/#{self.class.to_s.gsub(/:/,'_')}"
|
167
|
+
# If the application dir exists, clean it first
|
168
|
+
if (File.exists?(lAppRootDir))
|
169
|
+
FileUtils::rm_rf(lAppRootDir)
|
170
|
+
end
|
171
|
+
FileUtils::mkdir_p(lAppRootDir)
|
172
|
+
# Create the installer
|
173
|
+
@Installer = RDI::Installer.new(lAppRootDir)
|
174
|
+
# Register the mute progress view
|
175
|
+
@Installer.registerNewPlugin(
|
176
|
+
'ProgressViews',
|
177
|
+
'MuteProgressView',
|
178
|
+
nil,
|
179
|
+
nil,
|
180
|
+
RDI::Test::MuteProgressView,
|
181
|
+
nil
|
182
|
+
)
|
183
|
+
# And set it as the default progress view
|
184
|
+
@Installer.setDefaultOptions( {
|
185
|
+
:PreferredProgressViews => [ 'MuteProgressView' ]
|
186
|
+
} )
|
187
|
+
|
188
|
+
# Call the test code
|
189
|
+
yield
|
190
|
+
@Installer = nil
|
191
|
+
# Remove the temporary application root dir
|
192
|
+
FileUtils::rm_rf(lAppRootDir)
|
193
|
+
# Put back the context
|
194
|
+
$rUtilAnts_Platform_Info.setSystemExePath(lSystemPath)
|
195
|
+
$rUtilAnts_Platform_Info.setSystemLibsPath(lLibsPath)
|
196
|
+
$LOAD_PATH.replace(lLoadPath)
|
197
|
+
if (defined?(Gem) != nil)
|
198
|
+
Gem.clear_paths
|
199
|
+
lGemsPath.each do |iDir|
|
200
|
+
if (!Gem.path.include?(iDir))
|
201
|
+
Gem.path << iDir
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Setup a regresion UI before calling some code
|
208
|
+
#
|
209
|
+
# Parameters:
|
210
|
+
# * *iClassName* (_String_): Class name of the View to be used
|
211
|
+
# * *iLocationSelectorClassName* (_String_): Class name of the location selector [optional = nil]
|
212
|
+
def setupRegressionUI(iClassName, iLocationSelectorClassName = nil)
|
213
|
+
# Add a View plugin
|
214
|
+
@Installer.registerNewPlugin(
|
215
|
+
'Views',
|
216
|
+
'RegressionUI',
|
217
|
+
nil,
|
218
|
+
nil,
|
219
|
+
iClassName,
|
220
|
+
nil
|
221
|
+
)
|
222
|
+
# Add the location selector
|
223
|
+
if (iLocationSelectorClassName != nil)
|
224
|
+
@Installer.registerNewPlugin(
|
225
|
+
'LocationSelectors_RegressionUI',
|
226
|
+
'Directory',
|
227
|
+
nil,
|
228
|
+
nil,
|
229
|
+
iLocationSelectorClassName,
|
230
|
+
nil
|
231
|
+
)
|
232
|
+
end
|
233
|
+
yield
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
# Module defining methods that test a given Tester
|
239
|
+
# The setup of classes including this module should define
|
240
|
+
# @TesterPluginName
|
241
|
+
# getTestContent
|
242
|
+
# installTestContent
|
243
|
+
# uninstallTestContent
|
244
|
+
module RDITestCase_Testers
|
245
|
+
|
246
|
+
# Test that the API is correctly defined
|
247
|
+
def testAPI
|
248
|
+
setupAppDir do
|
249
|
+
@Installer.accessPlugin('Testers', @TesterPluginName) do |ioPlugin|
|
250
|
+
assert(ioPlugin.is_a?(RDI::Model::Tester))
|
251
|
+
assert(ioPlugin.respond_to?(:isContentResolved?))
|
252
|
+
assert(ioPlugin.respond_to?(:getAffectingContextModifiers))
|
253
|
+
# Test that returned Affecting Context Modifiers are valid.
|
254
|
+
lAvailableCMs = @Installer.getPluginNames('ContextModifiers')
|
255
|
+
ioPlugin.getAffectingContextModifiers.each do |iCMName|
|
256
|
+
assert_equal(true, lAvailableCMs.include?(iCMName))
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# Test that the dependency does not exist in an empty project
|
263
|
+
def testMissingDep
|
264
|
+
setupAppDir do
|
265
|
+
@Installer.accessPlugin('Testers', @TesterPluginName) do |ioPlugin|
|
266
|
+
lContent = getTestContent
|
267
|
+
assert_equal(false, ioPlugin.isContentResolved?(lContent))
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# Test that once installed, it detects the dependency as being present
|
273
|
+
def testExistingDep
|
274
|
+
setupAppDir do
|
275
|
+
@Installer.accessPlugin('Testers', @TesterPluginName) do |ioPlugin|
|
276
|
+
lContent = getTestContent
|
277
|
+
installTestContent
|
278
|
+
assert_equal(true, ioPlugin.isContentResolved?(lContent))
|
279
|
+
uninstallTestContent
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
# Module defining methods that test a given Installer
|
287
|
+
# The setup of classes including this module should define
|
288
|
+
# @InstallerPluginName
|
289
|
+
# getTestContent
|
290
|
+
# verifyInstalledContent
|
291
|
+
# uninstallTestContent
|
292
|
+
# getOtherLocation
|
293
|
+
module RDITestCase_Installers
|
294
|
+
|
295
|
+
# Test that the API is correctly defined
|
296
|
+
def testAPI
|
297
|
+
setupAppDir do
|
298
|
+
@Installer.accessPlugin('Installers', @InstallerPluginName) do |ioPlugin|
|
299
|
+
assert(ioPlugin.is_a?(RDI::Model::Installer))
|
300
|
+
assert(ioPlugin.respond_to?(:getPossibleDestinations))
|
301
|
+
assert(ioPlugin.respond_to?(:installDependency))
|
302
|
+
lDestinations = ioPlugin.getPossibleDestinations
|
303
|
+
assert(lDestinations.is_a?(Array))
|
304
|
+
assert(lDestinations.size > 0)
|
305
|
+
assert(lDestinations[0][0] != DEST_OTHER)
|
306
|
+
lDestinations.each do |iDestination|
|
307
|
+
assert(iDestination.is_a?(Array))
|
308
|
+
assert(iDestination.size == 2)
|
309
|
+
iFlavour, iLocation = iDestination
|
310
|
+
assert(iFlavour.is_a?(Fixnum))
|
311
|
+
if (iFlavour == DEST_OTHER)
|
312
|
+
# Check that this selector location name exists for every GUI we have
|
313
|
+
assert(iLocation.is_a?(String))
|
314
|
+
@Installer.getPluginNames('Views').each do |iViewName|
|
315
|
+
assert(@Installer.getPluginNames("LocationSelectors_#{iViewName}").include?(iLocation))
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
# Test that installing works correctly
|
324
|
+
def testInstallDep
|
325
|
+
setupAppDir do
|
326
|
+
@Installer.accessPlugin('Installers', @InstallerPluginName) do |ioPlugin|
|
327
|
+
lContent = getTestContent
|
328
|
+
# Test installation on every possible location
|
329
|
+
ioPlugin.getPossibleDestinations.each do |iDestination|
|
330
|
+
iFlavour, iLocation = iDestination
|
331
|
+
lLocation = iLocation
|
332
|
+
if (iFlavour == DEST_OTHER)
|
333
|
+
# Use a temporary location
|
334
|
+
lLocation = getOtherLocation
|
335
|
+
end
|
336
|
+
assert_equal(false, verifyInstalledContent(lLocation))
|
337
|
+
# Install the test content
|
338
|
+
ioPlugin.installDependency(lContent, lLocation)
|
339
|
+
# Verify
|
340
|
+
assert_equal(true, verifyInstalledContent(lLocation))
|
341
|
+
# Remove
|
342
|
+
uninstallTestContent(lLocation)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
# Module defining methods that test a given ContextModifier
|
351
|
+
# The setup of classes including this module should define
|
352
|
+
# @ContextModifierPluginName
|
353
|
+
# getTestLocation
|
354
|
+
module RDITestCase_ContextModifiers
|
355
|
+
|
356
|
+
# Test that the API is correctly defined
|
357
|
+
def testAPI
|
358
|
+
setupAppDir do
|
359
|
+
@Installer.accessPlugin('ContextModifiers', @ContextModifierPluginName) do |ioPlugin|
|
360
|
+
assert(ioPlugin.is_a?(RDI::Model::ContextModifier))
|
361
|
+
assert(ioPlugin.respond_to?(:getLocationSelectorName))
|
362
|
+
assert(ioPlugin.respond_to?(:transformContentWithInstallEnv))
|
363
|
+
assert(ioPlugin.respond_to?(:isLocationInContext?))
|
364
|
+
assert(ioPlugin.respond_to?(:addLocationToContext))
|
365
|
+
assert(ioPlugin.respond_to?(:removeLocationFromContext))
|
366
|
+
# Check that the location selector name exists for every view we have.
|
367
|
+
lLocationSelectorName = ioPlugin.getLocationSelectorName
|
368
|
+
assert(lLocationSelectorName.is_a?(String))
|
369
|
+
@Installer.getPluginNames('Views').each do |iViewName|
|
370
|
+
assert(@Installer.getPluginNames("LocationSelectors_#{iViewName}").include?(lLocationSelectorName))
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
# Test missing location
|
377
|
+
def testMissingLocation
|
378
|
+
setupAppDir do
|
379
|
+
@Installer.accessPlugin('ContextModifiers', @ContextModifierPluginName) do |ioPlugin|
|
380
|
+
lLocation = getTestLocation
|
381
|
+
assert_equal(false, ioPlugin.isLocationInContext?(lLocation))
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# Test that adding locations works correctly
|
387
|
+
def testAddLocation
|
388
|
+
setupAppDir do
|
389
|
+
@Installer.accessPlugin('ContextModifiers', @ContextModifierPluginName) do |ioPlugin|
|
390
|
+
lLocation = getTestLocation
|
391
|
+
assert_equal(false, ioPlugin.isLocationInContext?(lLocation))
|
392
|
+
ioPlugin.addLocationToContext(lLocation)
|
393
|
+
assert_equal(true, ioPlugin.isLocationInContext?(lLocation))
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
# Test that removing locations works correctly
|
399
|
+
def testRemoveLocation
|
400
|
+
setupAppDir do
|
401
|
+
@Installer.accessPlugin('ContextModifiers', @ContextModifierPluginName) do |ioPlugin|
|
402
|
+
lLocation = getTestLocation
|
403
|
+
assert_equal(false, ioPlugin.isLocationInContext?(lLocation))
|
404
|
+
ioPlugin.addLocationToContext(lLocation)
|
405
|
+
assert_equal(true, ioPlugin.isLocationInContext?(lLocation))
|
406
|
+
ioPlugin.removeLocationFromContext(lLocation)
|
407
|
+
assert_equal(false, ioPlugin.isLocationInContext?(lLocation))
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
end
|
413
|
+
|
414
|
+
# Module defining methods that test a given View
|
415
|
+
# The setup of classes including this module should define
|
416
|
+
# @ViewPluginName
|
417
|
+
module RDITestCase_Views
|
418
|
+
|
419
|
+
# Constants, along with the type of object following it
|
420
|
+
# Nothing
|
421
|
+
ACTION_LOCATE = 0
|
422
|
+
# Nothing
|
423
|
+
ACTION_IGNORE = 1
|
424
|
+
# Integer: Installer's index
|
425
|
+
# Integer: Destination's index
|
426
|
+
# Object: Install location (if needed - nil otherwise)
|
427
|
+
ACTION_INSTALL = 2
|
428
|
+
# Nothing
|
429
|
+
ACTION_APPLY = 3
|
430
|
+
# String: ContextModifier name
|
431
|
+
# Object: Location
|
432
|
+
ACTION_SELECT_AFFECTING_CONTEXTMODIFIER = 4
|
433
|
+
|
434
|
+
# An action is the triplet
|
435
|
+
# [ Integer, String, Object ]
|
436
|
+
# [ ActionID, DepID, Parameters ]
|
437
|
+
|
438
|
+
# Test that the API is correctly defined
|
439
|
+
def testAPI
|
440
|
+
setupAppDir do
|
441
|
+
@Installer.accessPlugin('Views', @ViewPluginName) do |ioPlugin|
|
442
|
+
assert(ioPlugin.is_a?(RDI::Model::View))
|
443
|
+
assert(ioPlugin.respond_to?(:execute))
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
# Default implementation for initScenario
|
449
|
+
# To be rewritten by each View plugin test suite
|
450
|
+
#
|
451
|
+
# Parameters:
|
452
|
+
# * *ioPlugin* (_Object_): The View plugin
|
453
|
+
# * *iScenario* (<em>list<[Integer,String,Object]></em>): The scenario
|
454
|
+
# * *iMissingDependencies* (<em>list<DependencyDescription></em>): The missing dependencies list
|
455
|
+
def initScenario(ioPlugin, iScenario, iMissingDependencies)
|
456
|
+
# Display it to the user for him to perform the actions
|
457
|
+
lActionsStr = []
|
458
|
+
lIdxAction = 1
|
459
|
+
iScenario.each do |iActionInfo|
|
460
|
+
iAction, iDepID, iParameters = iActionInfo
|
461
|
+
lStr = "[#{iDepID}] - "
|
462
|
+
case iAction
|
463
|
+
when ACTION_LOCATE
|
464
|
+
lStr += 'Choose Locate'
|
465
|
+
when ACTION_IGNORE
|
466
|
+
lStr += 'Choose Ignore'
|
467
|
+
when ACTION_INSTALL
|
468
|
+
if (iParameters[2] == nil)
|
469
|
+
lStr += "Choose Installer n.#{iParameters[0]}, Destination n.#{iParameters[1]}"
|
470
|
+
else
|
471
|
+
lStr += "Choose Installer n.#{iParameters[0]}, Destination n.#{iParameters[1]}, Location: #{iParameters[2]}"
|
472
|
+
end
|
473
|
+
when ACTION_APPLY
|
474
|
+
lStr = 'Apply'
|
475
|
+
when ACTION_SELECT_AFFECTING_CONTEXTMODIFIER
|
476
|
+
lStr += "Choose Locate ContextModifier #{iParameters[0]} using Location: #{iParameters[1]}"
|
477
|
+
else
|
478
|
+
logBug "Unknown Action: #{iAction}"
|
479
|
+
end
|
480
|
+
lActionsStr << "#{lIdxAction} - #{lStr}"
|
481
|
+
lIdxAction += 1
|
482
|
+
end
|
483
|
+
# Remove the logging silent mode before displaying
|
484
|
+
setLogMessagesStack(nil)
|
485
|
+
logMsg "Please perform the following:\n#{lActionsStr.join("\n")}"
|
486
|
+
end
|
487
|
+
|
488
|
+
# Default implementation for finalScenario
|
489
|
+
# To be rewritten by each View plugin test suite
|
490
|
+
#
|
491
|
+
# Parameters:
|
492
|
+
# * *ioPlugin* (_Object_): The View plugin
|
493
|
+
def finalScenario(ioPlugin)
|
494
|
+
# Nothing to do
|
495
|
+
end
|
496
|
+
|
497
|
+
# Default implementation for executeScenario
|
498
|
+
# To be rewritten by each View plugin test suite
|
499
|
+
#
|
500
|
+
# Parameters:
|
501
|
+
# * *ioPlugin* (_Object_): The View plugin
|
502
|
+
# * *ioInstaller* (_Installer_): The RDI installer
|
503
|
+
# * *iMissingDependencies* (<em>list<DependencyDescription></em>): The missing dependencies list
|
504
|
+
# Return:
|
505
|
+
# * <em>list<DependencyUserChoice></em>: The corresponding user choices
|
506
|
+
def executeScenario(ioPlugin, ioInstaller, iMissingDependencies)
|
507
|
+
return ioPlugin.execute(ioInstaller, iMissingDependencies)
|
508
|
+
end
|
509
|
+
|
510
|
+
# Setup a fake selector that always return a given value
|
511
|
+
#
|
512
|
+
# Parameters:
|
513
|
+
# * *iSelectorName* (_String_): Name of the selector to modify
|
514
|
+
# * *iLocation* (_Object_): Location to always give
|
515
|
+
# * _CodeBlock_: The code to be executed once the fake selector is in place
|
516
|
+
def setupFakeSelector(iSelectorName, iLocation)
|
517
|
+
@Installer.accessPlugin("LocationSelectors_#{@ViewPluginName}", iSelectorName) do |ioLSPlugin|
|
518
|
+
# Replace temporarily its getNewLocation method
|
519
|
+
ioLSPlugin.class.module_eval('alias :getNewLocation_ORG :getNewLocation')
|
520
|
+
# Define the new one
|
521
|
+
ioLSPlugin.class.module_eval('
|
522
|
+
def getNewLocation
|
523
|
+
return $RDI_Regression_Location
|
524
|
+
end
|
525
|
+
')
|
526
|
+
$RDI_Regression_Location = iLocation
|
527
|
+
# Use it
|
528
|
+
yield
|
529
|
+
# Put back the old method
|
530
|
+
ioLSPlugin.class.module_eval('
|
531
|
+
remove_method :getNewLocation
|
532
|
+
alias :getNewLocation :getNewLocation_ORG
|
533
|
+
')
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
# Get the dependency user choices from a scenario.
|
538
|
+
# This is used to then compare if View plugins behave correctly
|
539
|
+
#
|
540
|
+
# Parameters:
|
541
|
+
# * *iMissingDependencies* (<em>list<DependencyDescription></em>): The missing dependencies list
|
542
|
+
# * *iScenario* (<em>list<[Integer,String,Object]></em>): The scenario
|
543
|
+
# Return:
|
544
|
+
# * <em>list<DependencyUserChoice></em>: The corresponding user choices
|
545
|
+
def getUserChoicesFromScenario(iMissingDependencies, iScenario)
|
546
|
+
rDepsUserChoices = []
|
547
|
+
|
548
|
+
# First, initialize them
|
549
|
+
# Create also a map that makes retrieving user choices based on DepID easier
|
550
|
+
# map< String, DependencyUserChoice >
|
551
|
+
lDepsUserChoicesIndex = {}
|
552
|
+
iMissingDependencies.each do |iDepDesc|
|
553
|
+
lDepUserChoice = RDI::Model::DependencyUserChoice.new(@Installer, @ViewPluginName, iDepDesc)
|
554
|
+
rDepsUserChoices << lDepUserChoice
|
555
|
+
lDepsUserChoicesIndex[iDepDesc.ID] = lDepUserChoice
|
556
|
+
end
|
557
|
+
# Then modify them based on the scenario
|
558
|
+
iScenario.each do |iActionInfo|
|
559
|
+
iAction, iDepID, iParameters = iActionInfo
|
560
|
+
# First, find the correct dependency user choice
|
561
|
+
lDepUserChoice = nil
|
562
|
+
if (iDepID != nil)
|
563
|
+
lDepUserChoice = lDepsUserChoicesIndex[iDepID]
|
564
|
+
end
|
565
|
+
case iAction
|
566
|
+
when ACTION_LOCATE
|
567
|
+
lDepUserChoice.setLocate
|
568
|
+
when ACTION_IGNORE
|
569
|
+
lDepUserChoice.setIgnore
|
570
|
+
when ACTION_INSTALL
|
571
|
+
lDepUserChoice.setInstaller(iParameters[0], iParameters[1])
|
572
|
+
if (iParameters[2] != nil)
|
573
|
+
# Make sure the LocationSelector returns iParameters[2]
|
574
|
+
# Get the name of the selector
|
575
|
+
@Installer.accessPlugin('Installers', lDepUserChoice.DepDesc.Installers[iParameters[0]][0]) do |iInstallPlugin|
|
576
|
+
lSelectorName = iInstallPlugin.PossibleDestinations[iParameters[1]][1]
|
577
|
+
setupFakeSelector(lSelectorName, iParameters[2]) do
|
578
|
+
lDepUserChoice.selectOtherInstallLocation(lSelectorName)
|
579
|
+
end
|
580
|
+
end
|
581
|
+
end
|
582
|
+
when ACTION_APPLY
|
583
|
+
break
|
584
|
+
when ACTION_SELECT_AFFECTING_CONTEXTMODIFIER
|
585
|
+
# Make sure the LocationSelector returns iParameters[1]
|
586
|
+
@Installer.accessPlugin('ContextModifiers', iParameters[0]) do |ioCMPlugin|
|
587
|
+
# Get the name of LocationSelector class to use
|
588
|
+
lLocationSelectorName = ioCMPlugin.LocationSelectorName
|
589
|
+
setupFakeSelector(lLocationSelectorName, iParameters[1]) do
|
590
|
+
lDepUserChoice.affectContextModifier(iParameters[0])
|
591
|
+
end
|
592
|
+
end
|
593
|
+
else
|
594
|
+
logBug "Unknown Action: #{iAction}"
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
return rDepsUserChoices
|
599
|
+
end
|
600
|
+
|
601
|
+
# Launches a scenario test
|
602
|
+
#
|
603
|
+
# Parameters:
|
604
|
+
# * *iMissingDependencies* (<em>list<DependencyDescription></em>): The missing dependencies list
|
605
|
+
# * *iScenario* (<em>list<[Integer,String,Object]></em>): The scenario
|
606
|
+
def launchScenario(iMissingDependencies, iScenario)
|
607
|
+
setupAppDir do
|
608
|
+
lUserChoices = nil
|
609
|
+
@Installer.accessPlugin('Views', @ViewPluginName) do |ioPlugin|
|
610
|
+
# Create the scenario and prepare it to be run
|
611
|
+
initScenario(ioPlugin, iScenario, iMissingDependencies)
|
612
|
+
# Execute it
|
613
|
+
lUserChoices = executeScenario(ioPlugin, @Installer, iMissingDependencies )
|
614
|
+
# Finalize the scenario
|
615
|
+
finalScenario(ioPlugin)
|
616
|
+
# Check generic parameters from the scenario
|
617
|
+
assert_equal(lUserChoices, getUserChoicesFromScenario(iMissingDependencies, iScenario))
|
618
|
+
end
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
622
|
+
# Test installing everything by default
|
623
|
+
def testDefaultInstall
|
624
|
+
launchScenario( [ getSimpleDesc ], [
|
625
|
+
[ ACTION_APPLY, nil, nil ]
|
626
|
+
] )
|
627
|
+
end
|
628
|
+
|
629
|
+
# Test installing everything by default for 2 dependencies
|
630
|
+
def testDefaultInstall2Deps
|
631
|
+
launchScenario( [ getSimpleDesc, getSimpleDesc2 ], [
|
632
|
+
[ ACTION_APPLY, nil, nil ]
|
633
|
+
] )
|
634
|
+
end
|
635
|
+
|
636
|
+
# Test ignoring
|
637
|
+
def testIgnore
|
638
|
+
launchScenario( [ getSimpleDesc ], [
|
639
|
+
[ ACTION_IGNORE, 'DummyBinary', nil ],
|
640
|
+
[ ACTION_APPLY, nil, nil ]
|
641
|
+
] )
|
642
|
+
end
|
643
|
+
|
644
|
+
# Test ignoring 1 of 2 deps
|
645
|
+
def testIgnore1Of2Deps
|
646
|
+
launchScenario( [ getSimpleDesc, getSimpleDesc2 ], [
|
647
|
+
[ ACTION_IGNORE, 'DummyLibrary', nil ],
|
648
|
+
[ ACTION_APPLY, nil, nil ]
|
649
|
+
] )
|
650
|
+
end
|
651
|
+
|
652
|
+
# Test install to a different location
|
653
|
+
def testInstallDest
|
654
|
+
launchScenario( [ getSimpleDesc ], [
|
655
|
+
[ ACTION_INSTALL, 'DummyBinary', [ 0, 1, nil ] ],
|
656
|
+
[ ACTION_APPLY, nil, nil ]
|
657
|
+
] )
|
658
|
+
end
|
659
|
+
|
660
|
+
# Test install to a different location 1 of 2 deps
|
661
|
+
def testInstallDest1Of2Deps
|
662
|
+
launchScenario( [ getSimpleDesc, getSimpleDesc2 ], [
|
663
|
+
[ ACTION_INSTALL, 'DummyLibrary', [ 0, 1, nil ] ],
|
664
|
+
[ ACTION_APPLY, nil, nil ]
|
665
|
+
] )
|
666
|
+
end
|
667
|
+
|
668
|
+
# Test install to another location to be choosen
|
669
|
+
def testInstallOtherLocation
|
670
|
+
# Get the index of the DEST_OTHER destination
|
671
|
+
lIdxDest = 0
|
672
|
+
lDesc = getSimpleDesc
|
673
|
+
setupAppDir do
|
674
|
+
@Installer.accessPlugin('Installers', lDesc.Installers[0][0]) do |iPlugin|
|
675
|
+
iPlugin.PossibleDestinations.each do |iDestInfo|
|
676
|
+
iFlavour, iLocation = iDestInfo
|
677
|
+
if (iFlavour == DEST_OTHER)
|
678
|
+
# Found it
|
679
|
+
break
|
680
|
+
end
|
681
|
+
lIdxDest += 1
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
launchScenario( [ lDesc ], [
|
686
|
+
[ ACTION_INSTALL, 'DummyBinary', [ 0, lIdxDest, 'OtherLocation' ] ],
|
687
|
+
[ ACTION_APPLY, nil, nil ]
|
688
|
+
] )
|
689
|
+
end
|
690
|
+
|
691
|
+
# Test install to another location to be choosen of 1 of 2 deps
|
692
|
+
def testInstallOtherLocation1Of2Deps
|
693
|
+
# Get the index of the DEST_OTHER destination
|
694
|
+
lIdxDest = 0
|
695
|
+
lDesc = getSimpleDesc2
|
696
|
+
setupAppDir do
|
697
|
+
@Installer.accessPlugin('Installers', lDesc.Installers[0][0]) do |iPlugin|
|
698
|
+
iPlugin.PossibleDestinations.each do |iDestInfo|
|
699
|
+
iFlavour, iLocation = iDestInfo
|
700
|
+
if (iFlavour == DEST_OTHER)
|
701
|
+
# Found it
|
702
|
+
break
|
703
|
+
end
|
704
|
+
lIdxDest += 1
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
launchScenario( [ getSimpleDesc, lDesc ], [
|
709
|
+
[ ACTION_INSTALL, 'DummyLibrary', [ 0, lIdxDest, 'OtherLocation' ] ],
|
710
|
+
[ ACTION_APPLY, nil, nil ]
|
711
|
+
] )
|
712
|
+
end
|
713
|
+
|
714
|
+
# Test install using another installer
|
715
|
+
def testInstallOtherInstaller
|
716
|
+
launchScenario( [ get2InstallersDesc ], [
|
717
|
+
[ ACTION_INSTALL, 'DummyBinary2', [ 1, 0, nil ] ],
|
718
|
+
[ ACTION_APPLY, nil, nil ]
|
719
|
+
] )
|
720
|
+
end
|
721
|
+
|
722
|
+
# Test install using another installer for 1 of 2 deps
|
723
|
+
def testInstallOtherInstaller1Of2Deps
|
724
|
+
launchScenario( [ getSimpleDesc, get2InstallersDesc ], [
|
725
|
+
[ ACTION_INSTALL, 'DummyBinary2', [ 1, 0, nil ] ],
|
726
|
+
[ ACTION_APPLY, nil, nil ]
|
727
|
+
] )
|
728
|
+
end
|
729
|
+
|
730
|
+
# Test locate using a given ContextModifier
|
731
|
+
def testLocateWithCM
|
732
|
+
launchScenario( [ getSimpleDesc ], [
|
733
|
+
[ ACTION_LOCATE, 'DummyBinary', nil ],
|
734
|
+
[ ACTION_SELECT_AFFECTING_CONTEXTMODIFIER, 'DummyBinary', [ 'SystemPath', "#{@RepositoryDir}/Binaries" ] ],
|
735
|
+
[ ACTION_APPLY, nil, nil ]
|
736
|
+
] )
|
737
|
+
end
|
738
|
+
|
739
|
+
# Test locate using a given ContextModifier for 1 of 2 deps
|
740
|
+
def testLocateWithCM1Of2Deps
|
741
|
+
launchScenario( [ getSimpleDesc, getSimpleDesc2 ], [
|
742
|
+
[ ACTION_LOCATE, 'DummyBinary', nil ],
|
743
|
+
[ ACTION_SELECT_AFFECTING_CONTEXTMODIFIER, 'DummyBinary', [ 'SystemPath', "#{@RepositoryDir}/Binaries" ] ],
|
744
|
+
[ ACTION_APPLY, nil, nil ]
|
745
|
+
] )
|
746
|
+
end
|
747
|
+
|
748
|
+
# Test locate using a given ContextModifier with an invalid Location
|
749
|
+
def testLocateWithCMBadLocation
|
750
|
+
launchScenario( [ getSimpleDesc ], [
|
751
|
+
[ ACTION_LOCATE, 'DummyBinary', nil ],
|
752
|
+
[ ACTION_SELECT_AFFECTING_CONTEXTMODIFIER, 'DummyBinary', [ 'SystemPath', "#{@RepositoryDir}/BadBinaries" ] ],
|
753
|
+
[ ACTION_APPLY, nil, nil ]
|
754
|
+
] )
|
755
|
+
end
|
756
|
+
|
757
|
+
# Test locate using a given ContextModifier with an invalid Location for 1 of 2 deps
|
758
|
+
def testLocateWithCMBadLocation1Of2Deps
|
759
|
+
launchScenario( [ getSimpleDesc, getSimpleDesc2 ], [
|
760
|
+
[ ACTION_LOCATE, 'DummyBinary', nil ],
|
761
|
+
[ ACTION_SELECT_AFFECTING_CONTEXTMODIFIER, 'DummyBinary', [ 'SystemPath', "#{@RepositoryDir}/BadBinaries" ] ],
|
762
|
+
[ ACTION_APPLY, nil, nil ]
|
763
|
+
] )
|
764
|
+
end
|
765
|
+
|
766
|
+
end
|
767
|
+
|
768
|
+
# Module defining methods that test a given LocationSelector
|
769
|
+
# The setup of classes including this module should define
|
770
|
+
# @LocationSelectorPluginName
|
771
|
+
module RDITestCase_LocationSelectors
|
772
|
+
|
773
|
+
# Test that the API is correctly defined
|
774
|
+
def testAPI
|
775
|
+
setupAppDir do
|
776
|
+
# Check that each view defines it
|
777
|
+
# Get the list of views
|
778
|
+
@Installer.getPluginNames('Views').each do |iViewName|
|
779
|
+
# Install the dependencies automatically before calling the plugin (we don't want to ask the user about it)
|
780
|
+
lInstallMethod = "installDep_#{iViewName}".to_sym
|
781
|
+
if (respond_to?(lInstallMethod))
|
782
|
+
send(lInstallMethod)
|
783
|
+
end
|
784
|
+
@Installer.accessPlugin("LocationSelectors_#{iViewName}", @LocationSelectorPluginName) do |ioPlugin|
|
785
|
+
assert(ioPlugin.is_a?(RDI::Model::LocationSelector))
|
786
|
+
assert(ioPlugin.respond_to?(:getNewLocation))
|
787
|
+
end
|
788
|
+
end
|
789
|
+
end
|
790
|
+
end
|
791
|
+
|
792
|
+
end
|
793
|
+
|
794
|
+
end
|
795
|
+
|
796
|
+
end
|