fhlow 1.91.0
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/bin/fhlow +186 -0
- data/lib/module_cmdparse/cmdparse.rb +480 -0
- data/lib/module_cmdparse/cmdparse/wrappers/optparse.rb +65 -0
- data/lib/module_config/config.rb +67 -0
- data/lib/module_config/configexception.rb +18 -0
- data/lib/module_config/configitems/complex.rb +71 -0
- data/lib/module_config/configitems/complexpackage.rb +67 -0
- data/lib/module_config/configitems/complexunit.rb +76 -0
- data/lib/module_config/configitems/simple.rb +56 -0
- data/lib/module_config/configitems/simplearchitecture.rb +52 -0
- data/lib/module_config/configitems/simplepackage.rb +47 -0
- data/lib/module_config/configitems/simpleunit.rb +53 -0
- data/lib/module_config/configs.test +24 -0
- data/lib/module_config/item.rb +34 -0
- data/lib/module_config/itemfactory.rb +55 -0
- data/lib/module_config/section.rb +69 -0
- data/lib/module_config/test.flw +20 -0
- data/lib/module_config/test.rb +85 -0
- data/lib/module_config/tmp +3 -0
- data/lib/module_config/unittests/config_1.flw +14 -0
- data/lib/module_config/unittests/config_1_fixed.flw +14 -0
- data/lib/module_config/unittests/config_2.flw +15 -0
- data/lib/module_config/unittests/config_3a.flw +16 -0
- data/lib/module_config/unittests/config_3b.flw +15 -0
- data/lib/module_config/unittests/config_test.rb +579 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configexception_rb.html +647 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complex_rb.html +700 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexpackage_rb.html +694 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexunit_rb.html +704 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simple_rb.html +685 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simplepackage_rb.html +676 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simpleunit_rb.html +682 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-item_rb.html +663 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-itemfactory_rb.html +687 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-myconfig_rb.html +687 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-section_rb.html +692 -0
- data/lib/module_config/unittests/coverage/index.html +689 -0
- data/lib/module_fhlow/fhlowexception.rb +55 -0
- data/lib/module_fhlow/leaf.rb +197 -0
- data/lib/module_fhlow/leaf.rb~ +202 -0
- data/lib/module_fhlow/leaffactory.rb +97 -0
- data/lib/module_fhlow/leafs/Package.rb +55 -0
- data/lib/module_fhlow/leafs/Unit.rb +152 -0
- data/lib/module_fhlow/log.rb +100 -0
- data/lib/module_fhlow/node.rb +206 -0
- data/lib/module_fhlow/pen.rb +101 -0
- data/lib/module_fhlow/plugin.rb +54 -0
- data/lib/module_fhlow/pluginpool.rb +81 -0
- data/lib/module_fhlow/rootnode.rb +98 -0
- data/lib/module_fhlow/test.rb +15 -0
- data/lib/module_term/ansicolor.rb +102 -0
- data/tests/testsuite.rb +20 -0
- metadata +106 -0
@@ -0,0 +1,579 @@
|
|
1
|
+
###################### environment setup ##############################################
|
2
|
+
# Tries to detect the root directory of the actual fhlow root directory by parsing
|
3
|
+
# the string provided by 'Dir.pwd'.
|
4
|
+
|
5
|
+
def detectFhlowRootDir(_dir = Dir.pwd)
|
6
|
+
|
7
|
+
if _dir == ""
|
8
|
+
print ",-----------------------------------------------------------------+\n"
|
9
|
+
print "| ERROR: your actual working dir is not inside a fhlow structure! |\n"
|
10
|
+
print "`-----------------------------------------------------------------+\n"
|
11
|
+
exit
|
12
|
+
elsif Dir.entries(_dir).include?("flw")
|
13
|
+
return _dir+"/"
|
14
|
+
else
|
15
|
+
return detectFhlowRootDir(_dir.gsub(/(.*)\/\w*[\/]*/,'\1'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# add the fhlow lib dir to $: so ruby can find all the files
|
20
|
+
$:.unshift(detectFhlowRootDir+"flw/core/lib")
|
21
|
+
|
22
|
+
Dir.glob(detectFhlowRootDir+"flw/core/lib/module_*") { |entry| $:.unshift(entry) if File.directory?(entry) }
|
23
|
+
|
24
|
+
|
25
|
+
#######################################################################################
|
26
|
+
|
27
|
+
require 'test/unit'
|
28
|
+
require 'myconfig'
|
29
|
+
require 'configitems/simple'
|
30
|
+
require 'configitems/simpleunit'
|
31
|
+
require 'configitems/simplepackage'
|
32
|
+
require 'configitems/complex'
|
33
|
+
require 'configitems/complexpackage'
|
34
|
+
require 'configitems/complexunit'
|
35
|
+
|
36
|
+
class TC_config_test < Test::Unit::TestCase
|
37
|
+
|
38
|
+
def test_simple
|
39
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
40
|
+
Config::Simple.new("bla bla bla");
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
44
|
+
Config::Simple.new("bla ? bla");
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
48
|
+
Config::Simple.new("bla =");
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
52
|
+
s = Config::Simple.new(".1.1.1.1 = .1.1.1.1.1")
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
56
|
+
s = Config::Simple.new("... = ...")
|
57
|
+
end
|
58
|
+
|
59
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
60
|
+
s = Config::Simple.new("1.1.1.1. = 1.1.1.1.1;;;;")
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_nothing_raised() do
|
64
|
+
s = Config::Simple.new("SomeThing = Nothing")
|
65
|
+
s = Config::Simple.new("SomeThing = OtherValue")
|
66
|
+
s = Config::Simple.new("1234 = 1234")
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
s = Config::Simple.new("SomeThing = Nothing")
|
71
|
+
s1 = Config::Simple.new("SomeThing = OtherValue")
|
72
|
+
s2 = Config::Simple.new("1234 = 1234")
|
73
|
+
|
74
|
+
assert_raise(Config::ConfigMergeException) do
|
75
|
+
s.merge(s2)
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_nothing_raised() do
|
79
|
+
s.merge(s1)
|
80
|
+
end
|
81
|
+
|
82
|
+
assert_equal(s1.value, s.value)
|
83
|
+
|
84
|
+
assert_equal(/^\s*(\w+)\s*=\s*([\w,.;\s]+)\s*$/, Config::Simple.getRegex())
|
85
|
+
|
86
|
+
|
87
|
+
str = "ComplexUnits = {
|
88
|
+
1,2,3(bla);
|
89
|
+
4,5,6(bhv)
|
90
|
+
}
|
91
|
+
|
92
|
+
ComplexPackage = {
|
93
|
+
a,b,c;
|
94
|
+
d,e,f
|
95
|
+
}
|
96
|
+
|
97
|
+
Unit = blablablal(bla)
|
98
|
+
|
99
|
+
Package = asdfja
|
100
|
+
some = thing else"
|
101
|
+
|
102
|
+
|
103
|
+
assert_equal("Package = asdfja", Config::SimpleFactory.match(str).strip)
|
104
|
+
assert_equal("some = thing else", Config::SimpleFactory.match(str).strip)
|
105
|
+
assert_equal(nil, Config::SimpleFactory.match(str))
|
106
|
+
|
107
|
+
assert_equal(10, Config::SimpleFactory.priority)
|
108
|
+
|
109
|
+
assert_nothing_raised() do
|
110
|
+
s = Config::SimpleFactory.create("SomeThing = Nothing")
|
111
|
+
s = Config::SimpleFactory.create("SomeThing = OtherValue")
|
112
|
+
s = Config::SimpleFactory.create("1234 = 1234")
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_simpleunit
|
118
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
119
|
+
Config::SimpleUnit.new("bla bla Unit bla");
|
120
|
+
end
|
121
|
+
|
122
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
123
|
+
Config::SimpleUnit.new("bla ? bla(bhv)");
|
124
|
+
end
|
125
|
+
|
126
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
127
|
+
Config::SimpleUnit.new("blaUnit =(rtl)");
|
128
|
+
end
|
129
|
+
|
130
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
131
|
+
s = Config::SimpleUnit.new(".1.1.Unit1.1 = .1.1.1.1.1")
|
132
|
+
end
|
133
|
+
|
134
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
135
|
+
s = Config::SimpleUnit.new(".Unit.. = ...")
|
136
|
+
end
|
137
|
+
|
138
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
139
|
+
s = Config::SimpleUnit.new("1.1Unit.1.1. = 1.1.1.1.1(;;;;)")
|
140
|
+
end
|
141
|
+
|
142
|
+
s = nil
|
143
|
+
s1 = nil
|
144
|
+
s2 = nil
|
145
|
+
|
146
|
+
assert_nothing_raised() do
|
147
|
+
s = Config::SimpleUnit.new("UnitThing = Nothing(Bhv)")
|
148
|
+
s1 = Config::SimpleUnit.new("UnitThing = OtherValue(Rtl)")
|
149
|
+
s2 = Config::SimpleUnit.new("12Unit34 = 1234(45)")
|
150
|
+
end
|
151
|
+
|
152
|
+
assert_raise(Config::ConfigMergeException) do
|
153
|
+
s.merge(s2)
|
154
|
+
end
|
155
|
+
|
156
|
+
assert_nothing_raised() do
|
157
|
+
s.merge(s1)
|
158
|
+
end
|
159
|
+
|
160
|
+
assert_equal(s1.value, s.value)
|
161
|
+
|
162
|
+
assert_equal(/^\s*(\w*Unit\w*)\s*=\s*([\w,.;\s]+)\((.*)\)\s*$/, Config::SimpleUnit.getRegex())
|
163
|
+
|
164
|
+
|
165
|
+
str = "ComplexUnits = {
|
166
|
+
1,2,3(bla);
|
167
|
+
4,5,6(bhv)
|
168
|
+
}
|
169
|
+
|
170
|
+
ComplexPackage = {
|
171
|
+
a,b,c;
|
172
|
+
d,e,f
|
173
|
+
}
|
174
|
+
|
175
|
+
Unit = blablablal(bla)
|
176
|
+
|
177
|
+
Package = asdfja
|
178
|
+
some = thing else"
|
179
|
+
|
180
|
+
|
181
|
+
assert_equal("Unit = blablablal(bla)", Config::SimpleUnitFactory.match(str).strip)
|
182
|
+
assert_equal(nil, Config::SimpleUnitFactory.match(str))
|
183
|
+
|
184
|
+
assert_equal(0, Config::SimpleUnitFactory.priority)
|
185
|
+
|
186
|
+
assert_nothing_raised() do
|
187
|
+
s = Config::SimpleUnitFactory.create("SomeUnit = Nothing(Bhv, Rtl)")
|
188
|
+
assert_equal(s.value["archs"], ["Bhv", "Rtl"])
|
189
|
+
s = Config::SimpleUnitFactory.create("UnitThing = Other,Value(Rtl, Bla)")
|
190
|
+
s = Config::SimpleUnitFactory.create("12Unit34 = 1,2,3,4(2)")
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_simplepackage
|
196
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
197
|
+
Config::SimplePackage.new("bla bla Package bla");
|
198
|
+
end
|
199
|
+
|
200
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
201
|
+
Config::SimplePackage.new("bla ? bla");
|
202
|
+
end
|
203
|
+
|
204
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
205
|
+
Config::SimplePackage.new("blaPackage =");
|
206
|
+
end
|
207
|
+
|
208
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
209
|
+
s = Config::SimplePackage.new(".1.1.Package1.1 = .1.1.1.1.1")
|
210
|
+
end
|
211
|
+
|
212
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
213
|
+
s = Config::SimplePackage.new(".Package.. = ...")
|
214
|
+
end
|
215
|
+
|
216
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
217
|
+
s = Config::SimplePackage.new("1.1Package.1.1. = 1.1.1.1.1;;;;")
|
218
|
+
end
|
219
|
+
|
220
|
+
s = nil
|
221
|
+
s1 = nil
|
222
|
+
s2 = nil
|
223
|
+
|
224
|
+
assert_nothing_raised() do
|
225
|
+
s = Config::SimplePackage.new("PackageThing = Nothing")
|
226
|
+
s1 = Config::SimplePackage.new("PackageThing = OtherValue")
|
227
|
+
s2 = Config::SimplePackage.new("12Package34 = 1234")
|
228
|
+
end
|
229
|
+
|
230
|
+
assert_raise(Config::ConfigMergeException) do
|
231
|
+
s.merge(s2)
|
232
|
+
end
|
233
|
+
|
234
|
+
assert_nothing_raised() do
|
235
|
+
s.merge(s1)
|
236
|
+
end
|
237
|
+
|
238
|
+
assert_equal(s1.value, s.value)
|
239
|
+
|
240
|
+
assert_equal(/^\s*(\w*Package\w*)\s*=\s*([\w,.;\s]+)\s*$/, Config::SimplePackage.getRegex())
|
241
|
+
|
242
|
+
|
243
|
+
str = "ComplexPackages = {
|
244
|
+
1,2,3(bla);
|
245
|
+
4,5,6(bhv)
|
246
|
+
}
|
247
|
+
|
248
|
+
ComplexPackage = {
|
249
|
+
a,b,c;
|
250
|
+
d,e,f
|
251
|
+
}
|
252
|
+
|
253
|
+
Unit = blablablal(bla)
|
254
|
+
|
255
|
+
Package = asdfja
|
256
|
+
some = thing else"
|
257
|
+
|
258
|
+
|
259
|
+
assert_equal("Package = asdfja", Config::SimplePackageFactory.match(str).strip)
|
260
|
+
assert_equal(nil, Config::SimplePackageFactory.match(str))
|
261
|
+
|
262
|
+
assert_equal(0, Config::SimplePackageFactory.priority)
|
263
|
+
|
264
|
+
assert_nothing_raised() do
|
265
|
+
s = Config::SimplePackageFactory.create("SomePackage = Nothing")
|
266
|
+
s = Config::SimplePackageFactory.create("PackageThing = Other,Value")
|
267
|
+
s = Config::SimplePackageFactory.create("12Package34 = 1,2,3,4")
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_complex
|
273
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
274
|
+
Config::Complex.new("bla bla bla");
|
275
|
+
end
|
276
|
+
|
277
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
278
|
+
Config::Complex.new("bla =");
|
279
|
+
end
|
280
|
+
|
281
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
282
|
+
s = Config::Complex.new("... = { ... }")
|
283
|
+
end
|
284
|
+
|
285
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
286
|
+
s = Config::Complex.new("1.1.1.1. = { 1.1.1.1.1;;;; }")
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
291
|
+
s = Config::Complex.new("Complex = { something; 1324\n 1234 }")
|
292
|
+
end
|
293
|
+
|
294
|
+
s = nil
|
295
|
+
s1 = nil
|
296
|
+
s2 = nil
|
297
|
+
|
298
|
+
assert_nothing_raised() do
|
299
|
+
s = Config::Complex.new("ComplexThing = { No; thing }")
|
300
|
+
s1 = Config::Complex.new("ComplexThing = { Other; Value }")
|
301
|
+
s2 = Config::Complex.new("1234 = { 1; 2; 3; 4 }")
|
302
|
+
end
|
303
|
+
|
304
|
+
assert_raise(Config::ConfigMergeException) do
|
305
|
+
s.merge(s2)
|
306
|
+
end
|
307
|
+
|
308
|
+
assert_nothing_raised() do
|
309
|
+
s.merge(s1)
|
310
|
+
end
|
311
|
+
|
312
|
+
assert_equal(["Other", "Value", "No", "thing"], s.value)
|
313
|
+
|
314
|
+
assert_equal(/(\w+)\s*=(\s*|[\n]*)\{((\s*.+[;][\s\n]*)*(\s*.+[;]*[\s\n]*))\}/, Config::Complex.getRegex())
|
315
|
+
|
316
|
+
|
317
|
+
str = "ComplexUnitss = {
|
318
|
+
1,2,3(bla);
|
319
|
+
4,5,6(bhv)
|
320
|
+
}
|
321
|
+
|
322
|
+
ComplexPackage = {
|
323
|
+
a,b,c;
|
324
|
+
d,e,f
|
325
|
+
}
|
326
|
+
|
327
|
+
Unit = blablablal(bla)
|
328
|
+
|
329
|
+
Package = asdfja
|
330
|
+
some = thing else"
|
331
|
+
|
332
|
+
|
333
|
+
assert_equal("ComplexUnitss = {\n 1,2,3(bla);\n 4,5,6(bhv)\n }", Config::ComplexFactory.match(str).strip)
|
334
|
+
assert_equal("ComplexPackage = {\n a,b,c;\n d,e,f\n }", Config::ComplexFactory.match(str))
|
335
|
+
assert_equal(nil, Config::ComplexFactory.match(str))
|
336
|
+
|
337
|
+
assert_equal(11, Config::ComplexFactory.priority)
|
338
|
+
|
339
|
+
assert_nothing_raised() do
|
340
|
+
s = Config::ComplexFactory.create("ComplexPackages = {\n 1,2,3(bla);\n 4,5,6(bhv)\n }")
|
341
|
+
s = Config::ComplexFactory.create("ComplexPackage = {\n a,b,c;\n d,e,f\n }")
|
342
|
+
end
|
343
|
+
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_complexpackage
|
347
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
348
|
+
Config::ComplexPackage.new("bla bPackagela bla");
|
349
|
+
end
|
350
|
+
|
351
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
352
|
+
Config::ComplexPackage.new("blaPackage =");
|
353
|
+
end
|
354
|
+
|
355
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
356
|
+
s = Config::ComplexPackage.new("..Package. = { ... }")
|
357
|
+
end
|
358
|
+
|
359
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
360
|
+
s = Config::ComplexPackage.new("1.1Package.1.1. = { 1.1.1.1.1;;;; }")
|
361
|
+
end
|
362
|
+
|
363
|
+
|
364
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
365
|
+
s = Config::ComplexPackage.new("ComplexPackage = { something; 1324\n 1234 }")
|
366
|
+
end
|
367
|
+
|
368
|
+
s = nil
|
369
|
+
s1 = nil
|
370
|
+
s2 = nil
|
371
|
+
|
372
|
+
assert_nothing_raised() do
|
373
|
+
s = Config::ComplexPackage.new("ComplexPackageThing = { No; thing }")
|
374
|
+
s1 = Config::ComplexPackage.new("ComplexPackageThing = { Other; Value }")
|
375
|
+
s2 = Config::ComplexPackage.new("12Package34 = { 1; 2; 3; 4 }")
|
376
|
+
end
|
377
|
+
|
378
|
+
assert_raise(Config::ConfigMergeException) do
|
379
|
+
s.merge(s2)
|
380
|
+
end
|
381
|
+
|
382
|
+
assert_nothing_raised() do
|
383
|
+
s.merge(s1)
|
384
|
+
end
|
385
|
+
|
386
|
+
assert_equal(["Other", "Value", "No", "thing"], s.value)
|
387
|
+
|
388
|
+
assert_equal(/(\w*Package\w*)\s*=(\s*|[\n]*)\{((\s*[^\(\)]*[;][\s\n]*)*(\s*[^\(\)]*[;]*[\s\n]*))\}/, Config::ComplexPackage.getRegex())
|
389
|
+
|
390
|
+
|
391
|
+
str = "ComplexUnits = {
|
392
|
+
1,2,3(bla);
|
393
|
+
4,5,6(bhv)
|
394
|
+
}
|
395
|
+
|
396
|
+
ComplexPackage = {
|
397
|
+
a,b,c;
|
398
|
+
d,e,f
|
399
|
+
}
|
400
|
+
|
401
|
+
Unit = blablablal(bla)
|
402
|
+
|
403
|
+
Package = asdfja
|
404
|
+
some = thing else"
|
405
|
+
|
406
|
+
|
407
|
+
assert_equal("ComplexPackage = {\n a,b,c;\n d,e,f\n }", Config::ComplexPackageFactory.match(str))
|
408
|
+
assert_equal(nil, Config::ComplexPackageFactory.match(str))
|
409
|
+
|
410
|
+
assert_equal(0, Config::ComplexPackageFactory.priority)
|
411
|
+
|
412
|
+
assert_nothing_raised() do
|
413
|
+
s = Config::ComplexPackageFactory.create("ComplexPackage = {\n 1,2,3;\n 4,5,6\n }")
|
414
|
+
end
|
415
|
+
|
416
|
+
end
|
417
|
+
|
418
|
+
def test_complexunit
|
419
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
420
|
+
Config::ComplexUnit.new("bla bUnitla bla");
|
421
|
+
end
|
422
|
+
|
423
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
424
|
+
Config::ComplexUnit.new("blaUnit =");
|
425
|
+
end
|
426
|
+
|
427
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
428
|
+
s = Config::ComplexUnit.new("..Unit. = { ... }")
|
429
|
+
end
|
430
|
+
|
431
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
432
|
+
s = Config::ComplexUnit.new("1.1Unit.1.1. = { 1.1.1.1.1;;;; }")
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
437
|
+
s = Config::ComplexUnit.new("ComplexUnit = { something; 1324\n 1234 }")
|
438
|
+
end
|
439
|
+
|
440
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
441
|
+
s = Config::ComplexUnit.new("ComplexUnit = { something(bhv); 13(24);\n 1234 }")
|
442
|
+
end
|
443
|
+
|
444
|
+
assert_raise(Config::ConfigWrongFormatException) do
|
445
|
+
s = Config::ComplexUnit.new("ComplexUnit = { something; 13(24);\n 1234 }")
|
446
|
+
end
|
447
|
+
|
448
|
+
s = nil
|
449
|
+
s1 = nil
|
450
|
+
s2 = nil
|
451
|
+
|
452
|
+
assert_nothing_raised() do
|
453
|
+
s = Config::ComplexUnit.new("ComplexUnitThing = { No(arch); thing(itecture) }")
|
454
|
+
s1 = Config::ComplexUnit.new("ComplexUnitThing = { Other, Value(bhv, bla, 123) }")
|
455
|
+
s2 = Config::ComplexUnit.new("12Unit34 = { 1, 2(a); 3, 4(d) }")
|
456
|
+
end
|
457
|
+
|
458
|
+
assert_raise(Config::ConfigMergeException) do
|
459
|
+
s.merge(s2)
|
460
|
+
end
|
461
|
+
|
462
|
+
assert_nothing_raised() do
|
463
|
+
s.merge(s1)
|
464
|
+
end
|
465
|
+
|
466
|
+
assert_equal([ {"archs"=>["bhv", "bla", "123"], "deppath"=>"Other, Value"},
|
467
|
+
{"archs"=>["arch"], "deppath"=>"No"},
|
468
|
+
{"archs"=>["itecture"], "deppath"=>"thing"}],
|
469
|
+
s.value)
|
470
|
+
|
471
|
+
assert_equal(/(\w*Unit\w*)\s*=(\s*|[\n]*)\{((\s*.*[;][\s\n]*)*(\s*.*\(.*\)[;]*[\s\n]*))\}/, Config::ComplexUnit.getRegex())
|
472
|
+
|
473
|
+
|
474
|
+
str = "ComplexUnits = {
|
475
|
+
1,2,3(bla);
|
476
|
+
4,5,6(bhv)
|
477
|
+
}
|
478
|
+
|
479
|
+
ComplexPackage = {
|
480
|
+
a,b,c;
|
481
|
+
d,e,f
|
482
|
+
}
|
483
|
+
|
484
|
+
Unit = blablablal(bla)
|
485
|
+
|
486
|
+
Package = asdfja
|
487
|
+
some = thing else"
|
488
|
+
|
489
|
+
|
490
|
+
assert_equal("ComplexUnits = {\n 1,2,3(bla);\n 4,5,6(bhv)\n }", Config::ComplexUnitFactory.match(str))
|
491
|
+
assert_equal(nil, Config::ComplexUnitFactory.match(str))
|
492
|
+
|
493
|
+
assert_equal(0, Config::ComplexUnitFactory.priority)
|
494
|
+
|
495
|
+
assert_nothing_raised() do
|
496
|
+
s = Config::ComplexUnitFactory.create("ComplexUnit = {\n 1,2,3(bhv);\n 4,5,6(rtl, bhv)\n }")
|
497
|
+
end
|
498
|
+
|
499
|
+
end
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
=begin
|
505
|
+
# tests a file with an invalid value
|
506
|
+
def test_1
|
507
|
+
assert_raise(Fhlow::FhlowException) do
|
508
|
+
@conf = Config::Config.new("unittests/config_1.flw")
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
# tests a file with valid simple settings
|
513
|
+
def test_1_fixed
|
514
|
+
|
515
|
+
assert_nothing_raised(Exception) do
|
516
|
+
@conf = Config::Config.new("unittests/config_1_fixed.flw")
|
517
|
+
end
|
518
|
+
|
519
|
+
|
520
|
+
@conf["ep"].each { |x| p x }
|
521
|
+
|
522
|
+
assert_equal(@conf["ep"]["alias"], "yate")
|
523
|
+
assert_equal(@conf["ep"]["ep"], "true")
|
524
|
+
assert_equal(@conf["ep"]["gkclient"], "false")
|
525
|
+
assert_equal(@conf["ep"]["ident"], "yate")
|
526
|
+
|
527
|
+
assert_equal(@conf["gk"]["server"], "false")
|
528
|
+
|
529
|
+
assert_equal(@conf["incoming"]["called"], "8989989")
|
530
|
+
assert_equal(@conf["incoming"]["context"], "default")
|
531
|
+
|
532
|
+
assert_raise(Fhlow::FhlowException) { x = @conf["incoming"]["contex"] }
|
533
|
+
assert_raise(Fhlow::FhlowException) { x = @conf["incming"]["contex"] }
|
534
|
+
assert_raise(Fhlow::FhlowException) { x = @conf["incming"][""] }
|
535
|
+
assert_raise(Fhlow::FhlowException) { x = @conf[""]["adsfadsf"] }
|
536
|
+
assert_raise(Fhlow::FhlowException) { x = @conf[""][""] }
|
537
|
+
end
|
538
|
+
|
539
|
+
# tests a file with mixed (simple and complex) settings
|
540
|
+
def test_2
|
541
|
+
assert_nothing_raised(Exception) do
|
542
|
+
@conf = Config::Config.new("unittests/config_2.flw")
|
543
|
+
end
|
544
|
+
|
545
|
+
assert_equal(@conf["dependencies"]["foo"], "hallo")
|
546
|
+
assert_equal(@conf["dependencies"]["units"], ["Test, Wiese, Bauern", "blume, handy, hiphop"])
|
547
|
+
assert_equal(@conf["dependencies"]["test"], ["a, test, gogogo"])
|
548
|
+
end
|
549
|
+
|
550
|
+
#=begin
|
551
|
+
def test_2
|
552
|
+
@conf = Config::read("config_2.flw")
|
553
|
+
|
554
|
+
assert(@conf["dependencies", "foo") == "hallo", '@conf.value("dependencies", "gaga") != "hallo"')
|
555
|
+
|
556
|
+
x = @conf["dependencies", "units")
|
557
|
+
assert(@conf["dependencies", "units") == ["Test,Wiese,Bauern","blume,handy,hiphop"])
|
558
|
+
end
|
559
|
+
#=end
|
560
|
+
|
561
|
+
def test_3
|
562
|
+
assert_nothing_raised(Exception) do
|
563
|
+
@confa = Config::Config.new("unittests/config_3a.flw")
|
564
|
+
@confb = Config::Config.new("unittests/config_3b.flw")
|
565
|
+
end
|
566
|
+
|
567
|
+
@confa.merge(@confb)
|
568
|
+
|
569
|
+
assert_equal(@confa["section only in a"]["name"], "a")
|
570
|
+
assert_equal(@confa["section only in b"]["name"], "b")
|
571
|
+
assert_equal(@confa["common section"]["aname"], "a")
|
572
|
+
assert_equal(@confa["common section"]["bname"], "b")
|
573
|
+
assert_equal(@confa["common section"]["common"], "b")
|
574
|
+
assert_equal(@confa["common section"]["names"], ["kate", "kathy", "clair", "annonymous", "john", "jack", "karl"])
|
575
|
+
|
576
|
+
end
|
577
|
+
|
578
|
+
=end
|
579
|
+
end
|