datawire_mdk 2.0.5
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.
- checksums.yaml +7 -0
- data/lib/datawire-quark-core.rb +1213 -0
- data/lib/datawire_mdk_md.rb +54752 -0
- data/lib/mdk.rb +962 -0
- data/lib/mdk_discovery.rb +1518 -0
- data/lib/mdk_discovery/protocol.rb +818 -0
- data/lib/mdk_discovery/synapse.rb +267 -0
- data/lib/mdk_introspection.rb +281 -0
- data/lib/mdk_introspection/aws.rb +101 -0
- data/lib/mdk_introspection/kubernetes.rb +125 -0
- data/lib/mdk_protocol.rb +1255 -0
- data/lib/mdk_runtime.rb +2135 -0
- data/lib/mdk_runtime/actors.rb +457 -0
- data/lib/mdk_runtime/files.rb +575 -0
- data/lib/mdk_runtime/promise.rb +814 -0
- data/lib/mdk_tracing.rb +369 -0
- data/lib/mdk_tracing/api.rb +188 -0
- data/lib/mdk_tracing/protocol.rb +850 -0
- data/lib/mdk_util.rb +141 -0
- data/lib/quark.rb +3684 -0
- data/lib/quark/behaviors.rb +494 -0
- data/lib/quark/concurrent.rb +1250 -0
- data/lib/quark/error.rb +84 -0
- data/lib/quark/logging.rb +278 -0
- data/lib/quark/mock.rb +1223 -0
- data/lib/quark/os.rb +286 -0
- data/lib/quark/reflect.rb +489 -0
- data/lib/quark/spi.rb +130 -0
- data/lib/quark/spi_api.rb +489 -0
- data/lib/quark/spi_api_tracing.rb +1426 -0
- data/lib/quark/test.rb +766 -0
- metadata +142 -0
data/lib/quark/test.rb
ADDED
@@ -0,0 +1,766 @@
|
|
1
|
+
# Quark 1.0.406 run at 2016-08-31 13:21:53.028839
|
2
|
+
module Quark
|
3
|
+
def self.quark; Quark; end
|
4
|
+
module Quark
|
5
|
+
def self.test; Test; end
|
6
|
+
module Test
|
7
|
+
require "datawire-quark-core"
|
8
|
+
require_relative 'reflect' # 1 () ()
|
9
|
+
require_relative '../datawire_mdk_md' # 0 () ('quark',)
|
10
|
+
require_relative '../quark' # 0 () ('quark',)
|
11
|
+
require_relative 'concurrent' # 1 () ()
|
12
|
+
|
13
|
+
|
14
|
+
def self.TestInitializer; TestInitializer; end
|
15
|
+
class TestInitializer < ::DatawireQuarkCore::QuarkObject
|
16
|
+
extend ::DatawireQuarkCore::Static
|
17
|
+
|
18
|
+
static quark_test_TestInitializer_ref: -> { nil }
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
def initialize()
|
23
|
+
self.__init_fields__
|
24
|
+
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
def getValue()
|
32
|
+
|
33
|
+
return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.test.Test }
|
34
|
+
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def _getClass()
|
39
|
+
|
40
|
+
return "quark.test.TestInitializer"
|
41
|
+
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def _getField(name)
|
46
|
+
|
47
|
+
return nil
|
48
|
+
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def _setField(name, value)
|
53
|
+
|
54
|
+
nil
|
55
|
+
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
def __init_fields__()
|
60
|
+
|
61
|
+
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
TestInitializer.unlazy_statics
|
68
|
+
|
69
|
+
def self.red(str)
|
70
|
+
|
71
|
+
return (("\u001b[31;1m") + (str)) + ("\u001b[0m")
|
72
|
+
|
73
|
+
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.green(str)
|
78
|
+
|
79
|
+
return (("\u001b[32;1m") + (str)) + ("\u001b[0m")
|
80
|
+
|
81
|
+
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.bold(str)
|
86
|
+
|
87
|
+
return (("\u001b[1m") + (str)) + ("\u001b[0m")
|
88
|
+
|
89
|
+
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.heading(str)
|
94
|
+
|
95
|
+
padding = "="
|
96
|
+
target_width = 78
|
97
|
+
res = (((padding) + (" ")) + (str)) + (" ")
|
98
|
+
count = ((target_width) - ((res).size)) / ((padding).size)
|
99
|
+
block = (padding) * [0, ((count) / (2))].max
|
100
|
+
extra = ""
|
101
|
+
if (((count) % (2)) == (1))
|
102
|
+
extra = padding
|
103
|
+
end
|
104
|
+
return ::Quark.quark.test.bold(((((block) + (res)) + (block)) + (extra)).strip)
|
105
|
+
|
106
|
+
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.Test; Test; end
|
111
|
+
class Test < ::DatawireQuarkCore::QuarkObject
|
112
|
+
attr_accessor :name, :checks, :successes, :failures
|
113
|
+
extend ::DatawireQuarkCore::Static
|
114
|
+
|
115
|
+
static ctx: -> { ::DatawireQuarkCore::TLS.new(::Quark.quark.test.TestInitializer.new()) }
|
116
|
+
static quark_test_Test_ref: -> { nil }
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
def initialize(name)
|
121
|
+
|
122
|
+
self.__init_fields__
|
123
|
+
(self).name = name
|
124
|
+
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
def self.current()
|
132
|
+
|
133
|
+
return ::Quark.quark.test.Test.ctx.getValue()
|
134
|
+
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
|
138
|
+
def match(filters)
|
139
|
+
|
140
|
+
if (((filters) == (nil)) || (((filters).size) == (0)))
|
141
|
+
return true
|
142
|
+
end
|
143
|
+
idx = 0
|
144
|
+
while ((idx) < ((filters).size)) do
|
145
|
+
filter = (filters)[idx]
|
146
|
+
if ((((@name).index(filter) or -1)) >= (0))
|
147
|
+
return true
|
148
|
+
end
|
149
|
+
idx = (idx) + (1)
|
150
|
+
end
|
151
|
+
return false
|
152
|
+
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
|
156
|
+
def start()
|
157
|
+
|
158
|
+
::Quark.quark.test.Test.ctx.setValue(self)
|
159
|
+
|
160
|
+
nil
|
161
|
+
end
|
162
|
+
|
163
|
+
def stop()
|
164
|
+
|
165
|
+
result = (((((@name) + (" [")) + ((@checks).to_s)) + (" checks, ")) + (((@failures).size).to_s)) + (" failures]")
|
166
|
+
if (((@failures).size) > (0))
|
167
|
+
::DatawireQuarkCore.print(::Quark.quark.test.red(result))
|
168
|
+
else
|
169
|
+
::DatawireQuarkCore.print(::Quark.quark.test.bold(result))
|
170
|
+
end
|
171
|
+
idx = 0
|
172
|
+
while ((idx) < ((@successes).size)) do
|
173
|
+
::DatawireQuarkCore.print(::Quark.quark.test.green((" PASS: ") + ((@successes)[idx])))
|
174
|
+
idx = (idx) + (1)
|
175
|
+
end
|
176
|
+
idx = 0
|
177
|
+
while ((idx) < ((@failures).size)) do
|
178
|
+
::DatawireQuarkCore.print(::Quark.quark.test.red((" FAIL: ") + ((@failures)[idx])))
|
179
|
+
idx = (idx) + (1)
|
180
|
+
end
|
181
|
+
::Quark.quark.test.Test.ctx.setValue(nil)
|
182
|
+
|
183
|
+
nil
|
184
|
+
end
|
185
|
+
|
186
|
+
def check(value, message)
|
187
|
+
|
188
|
+
@checks = (@checks) + (1)
|
189
|
+
if (value)
|
190
|
+
(@successes) << (message)
|
191
|
+
else
|
192
|
+
(@failures) << (message)
|
193
|
+
end
|
194
|
+
return value
|
195
|
+
|
196
|
+
nil
|
197
|
+
end
|
198
|
+
|
199
|
+
def fail(message)
|
200
|
+
|
201
|
+
self.check(false, message)
|
202
|
+
|
203
|
+
nil
|
204
|
+
end
|
205
|
+
|
206
|
+
def run()
|
207
|
+
|
208
|
+
nil
|
209
|
+
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def _getClass()
|
214
|
+
|
215
|
+
return "quark.test.Test"
|
216
|
+
|
217
|
+
nil
|
218
|
+
end
|
219
|
+
|
220
|
+
def _getField(name)
|
221
|
+
|
222
|
+
if ((name) == ("ctx"))
|
223
|
+
return ::Quark.quark.test.Test.ctx
|
224
|
+
end
|
225
|
+
if ((name) == ("name"))
|
226
|
+
return (self).name
|
227
|
+
end
|
228
|
+
if ((name) == ("checks"))
|
229
|
+
return (self).checks
|
230
|
+
end
|
231
|
+
if ((name) == ("successes"))
|
232
|
+
return (self).successes
|
233
|
+
end
|
234
|
+
if ((name) == ("failures"))
|
235
|
+
return (self).failures
|
236
|
+
end
|
237
|
+
return nil
|
238
|
+
|
239
|
+
nil
|
240
|
+
end
|
241
|
+
|
242
|
+
def _setField(name, value)
|
243
|
+
|
244
|
+
if ((name) == ("ctx"))
|
245
|
+
::Quark.quark.test.Test.ctx = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::TLS }
|
246
|
+
end
|
247
|
+
if ((name) == ("name"))
|
248
|
+
(self).name = ::DatawireQuarkCore.cast(value) { ::String }
|
249
|
+
end
|
250
|
+
if ((name) == ("checks"))
|
251
|
+
(self).checks = ::DatawireQuarkCore.cast(value) { ::Integer }
|
252
|
+
end
|
253
|
+
if ((name) == ("successes"))
|
254
|
+
(self).successes = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
255
|
+
end
|
256
|
+
if ((name) == ("failures"))
|
257
|
+
(self).failures = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
258
|
+
end
|
259
|
+
|
260
|
+
nil
|
261
|
+
end
|
262
|
+
|
263
|
+
def __init_fields__()
|
264
|
+
|
265
|
+
self.name = nil
|
266
|
+
self.checks = 0
|
267
|
+
self.successes = ::DatawireQuarkCore::List.new([])
|
268
|
+
self.failures = ::DatawireQuarkCore::List.new([])
|
269
|
+
|
270
|
+
nil
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
end
|
275
|
+
Test.unlazy_statics
|
276
|
+
|
277
|
+
def self.SafeMethodCaller; SafeMethodCaller; end
|
278
|
+
class SafeMethodCaller < ::DatawireQuarkCore::QuarkObject
|
279
|
+
attr_accessor :method, :test
|
280
|
+
extend ::DatawireQuarkCore::Static
|
281
|
+
|
282
|
+
static useSafeCalls: -> { true }
|
283
|
+
static quark_test_SafeMethodCaller_ref: -> { nil }
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
def initialize(method, test)
|
288
|
+
|
289
|
+
self.__init_fields__
|
290
|
+
(self).method = method
|
291
|
+
(self).test = test
|
292
|
+
|
293
|
+
nil
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
def call(ignore)
|
300
|
+
|
301
|
+
@method.invoke(@test, ::DatawireQuarkCore::List.new([]))
|
302
|
+
return true
|
303
|
+
|
304
|
+
nil
|
305
|
+
end
|
306
|
+
|
307
|
+
def self.callMethod(method, test)
|
308
|
+
|
309
|
+
if (::Quark.quark.test.SafeMethodCaller.useSafeCalls)
|
310
|
+
callable = ::Quark.quark.test.SafeMethodCaller.new(method, test)
|
311
|
+
return ::DatawireQuarkCore.cast(::Quark.quark.concurrent.Context.runtime().callSafely(callable, false)) { ::Object }
|
312
|
+
end
|
313
|
+
method.invoke(test, ::DatawireQuarkCore::List.new([]))
|
314
|
+
return true
|
315
|
+
|
316
|
+
nil
|
317
|
+
end
|
318
|
+
|
319
|
+
def _getClass()
|
320
|
+
|
321
|
+
return "quark.test.SafeMethodCaller"
|
322
|
+
|
323
|
+
nil
|
324
|
+
end
|
325
|
+
|
326
|
+
def _getField(name)
|
327
|
+
|
328
|
+
if ((name) == ("useSafeCalls"))
|
329
|
+
return ::Quark.quark.test.SafeMethodCaller.useSafeCalls
|
330
|
+
end
|
331
|
+
if ((name) == ("method"))
|
332
|
+
return (self).method
|
333
|
+
end
|
334
|
+
if ((name) == ("test"))
|
335
|
+
return (self).test
|
336
|
+
end
|
337
|
+
return nil
|
338
|
+
|
339
|
+
nil
|
340
|
+
end
|
341
|
+
|
342
|
+
def _setField(name, value)
|
343
|
+
|
344
|
+
if ((name) == ("useSafeCalls"))
|
345
|
+
::Quark.quark.test.SafeMethodCaller.useSafeCalls = ::DatawireQuarkCore.cast(value) { ::Object }
|
346
|
+
end
|
347
|
+
if ((name) == ("method"))
|
348
|
+
(self).method = ::DatawireQuarkCore.cast(value) { ::Quark.quark.reflect.Method }
|
349
|
+
end
|
350
|
+
if ((name) == ("test"))
|
351
|
+
(self).test = value
|
352
|
+
end
|
353
|
+
|
354
|
+
nil
|
355
|
+
end
|
356
|
+
|
357
|
+
def __init_fields__()
|
358
|
+
|
359
|
+
self.method = nil
|
360
|
+
self.test = nil
|
361
|
+
|
362
|
+
nil
|
363
|
+
end
|
364
|
+
|
365
|
+
|
366
|
+
end
|
367
|
+
SafeMethodCaller.unlazy_statics
|
368
|
+
|
369
|
+
def self.MethodTest; MethodTest; end
|
370
|
+
class MethodTest < ::Quark.quark.test.Test
|
371
|
+
attr_accessor :klass, :method
|
372
|
+
extend ::DatawireQuarkCore::Static
|
373
|
+
|
374
|
+
static quark_test_MethodTest_ref: -> { nil }
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
def initialize(klass, method)
|
379
|
+
|
380
|
+
super(((klass.getName()) + (".")) + (method.getName()))
|
381
|
+
(self).klass = klass
|
382
|
+
(self).method = method
|
383
|
+
|
384
|
+
nil
|
385
|
+
end
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
def run()
|
391
|
+
|
392
|
+
setup = @klass.getMethod("setup")
|
393
|
+
teardown = @klass.getMethod("teardown")
|
394
|
+
test = @klass.construct(::DatawireQuarkCore::List.new([]))
|
395
|
+
if ((setup) != (nil))
|
396
|
+
if (!(::Quark.quark.test.SafeMethodCaller.callMethod(setup, test)))
|
397
|
+
::Quark.quark.test.fail("setup invocation crashed")
|
398
|
+
end
|
399
|
+
end
|
400
|
+
if (!(::Quark.quark.test.SafeMethodCaller.callMethod(@method, test)))
|
401
|
+
::Quark.quark.test.fail("test invocation crashed")
|
402
|
+
end
|
403
|
+
if ((teardown) != (nil))
|
404
|
+
if (!(::Quark.quark.test.SafeMethodCaller.callMethod(teardown, test)))
|
405
|
+
::Quark.quark.test.fail("teardown invocation crashed")
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
nil
|
410
|
+
end
|
411
|
+
|
412
|
+
def _getClass()
|
413
|
+
|
414
|
+
return "quark.test.MethodTest"
|
415
|
+
|
416
|
+
nil
|
417
|
+
end
|
418
|
+
|
419
|
+
def _getField(name)
|
420
|
+
|
421
|
+
if ((name) == ("ctx"))
|
422
|
+
return ::Quark.quark.test.Test.ctx
|
423
|
+
end
|
424
|
+
if ((name) == ("name"))
|
425
|
+
return (self).name
|
426
|
+
end
|
427
|
+
if ((name) == ("checks"))
|
428
|
+
return (self).checks
|
429
|
+
end
|
430
|
+
if ((name) == ("successes"))
|
431
|
+
return (self).successes
|
432
|
+
end
|
433
|
+
if ((name) == ("failures"))
|
434
|
+
return (self).failures
|
435
|
+
end
|
436
|
+
if ((name) == ("klass"))
|
437
|
+
return (self).klass
|
438
|
+
end
|
439
|
+
if ((name) == ("method"))
|
440
|
+
return (self).method
|
441
|
+
end
|
442
|
+
return nil
|
443
|
+
|
444
|
+
nil
|
445
|
+
end
|
446
|
+
|
447
|
+
def _setField(name, value)
|
448
|
+
|
449
|
+
if ((name) == ("ctx"))
|
450
|
+
::Quark.quark.test.Test.ctx = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::TLS }
|
451
|
+
end
|
452
|
+
if ((name) == ("name"))
|
453
|
+
(self).name = ::DatawireQuarkCore.cast(value) { ::String }
|
454
|
+
end
|
455
|
+
if ((name) == ("checks"))
|
456
|
+
(self).checks = ::DatawireQuarkCore.cast(value) { ::Integer }
|
457
|
+
end
|
458
|
+
if ((name) == ("successes"))
|
459
|
+
(self).successes = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
460
|
+
end
|
461
|
+
if ((name) == ("failures"))
|
462
|
+
(self).failures = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
463
|
+
end
|
464
|
+
if ((name) == ("klass"))
|
465
|
+
(self).klass = ::DatawireQuarkCore.cast(value) { ::Quark.quark.reflect.QuarkClass }
|
466
|
+
end
|
467
|
+
if ((name) == ("method"))
|
468
|
+
(self).method = ::DatawireQuarkCore.cast(value) { ::Quark.quark.reflect.Method }
|
469
|
+
end
|
470
|
+
|
471
|
+
nil
|
472
|
+
end
|
473
|
+
|
474
|
+
def __init_fields__()
|
475
|
+
|
476
|
+
super
|
477
|
+
self.klass = nil
|
478
|
+
self.method = nil
|
479
|
+
|
480
|
+
nil
|
481
|
+
end
|
482
|
+
|
483
|
+
|
484
|
+
end
|
485
|
+
MethodTest.unlazy_statics
|
486
|
+
|
487
|
+
def self.check(value, message)
|
488
|
+
|
489
|
+
return ::Quark.quark.test.Test.current().check(value, message)
|
490
|
+
|
491
|
+
|
492
|
+
nil
|
493
|
+
end
|
494
|
+
|
495
|
+
def self.checkEqual(expected, actual)
|
496
|
+
|
497
|
+
return ::Quark.quark.test.Test.current().check((expected) == (actual), ((("expected ") + ((expected).to_s)) + (" got ")) + ((actual).to_s))
|
498
|
+
|
499
|
+
|
500
|
+
nil
|
501
|
+
end
|
502
|
+
|
503
|
+
def self.fail(message)
|
504
|
+
|
505
|
+
::Quark.quark.test.Test.current().check(false, message)
|
506
|
+
|
507
|
+
|
508
|
+
nil
|
509
|
+
end
|
510
|
+
|
511
|
+
def self.checkOneOf(expected, actual)
|
512
|
+
|
513
|
+
message = "Expected one of ["
|
514
|
+
idx = 0
|
515
|
+
success = false
|
516
|
+
while ((idx) < ((expected).size)) do
|
517
|
+
if ((idx) != (0))
|
518
|
+
message = (message) + (", ")
|
519
|
+
end
|
520
|
+
message = (message) + (((expected)[idx]).to_s)
|
521
|
+
if (((expected)[idx]) == (actual))
|
522
|
+
success = true
|
523
|
+
end
|
524
|
+
idx = (idx) + (1)
|
525
|
+
end
|
526
|
+
message = ((message) + ("] got ")) + ((actual).to_s)
|
527
|
+
return ::Quark.quark.test.check(success, message)
|
528
|
+
|
529
|
+
|
530
|
+
nil
|
531
|
+
end
|
532
|
+
|
533
|
+
def self.Harness; Harness; end
|
534
|
+
class Harness < ::DatawireQuarkCore::QuarkObject
|
535
|
+
attr_accessor :pkg, :tests, :filtered
|
536
|
+
extend ::DatawireQuarkCore::Static
|
537
|
+
|
538
|
+
static quark_List_quark_test_Test__ref: -> { nil }
|
539
|
+
static quark_test_Harness_ref: -> { nil }
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
def initialize(pkg)
|
544
|
+
|
545
|
+
self.__init_fields__
|
546
|
+
(self).pkg = pkg
|
547
|
+
|
548
|
+
nil
|
549
|
+
end
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
def collect(filters)
|
555
|
+
|
556
|
+
names = ::DatawireQuarkCore::List.new((::Quark.quark.reflect.QuarkClass.classes).keys)
|
557
|
+
(names).sort!
|
558
|
+
idx = 0
|
559
|
+
pfx = (@pkg) + (".")
|
560
|
+
while ((idx) < ((names).size)) do
|
561
|
+
name = (names)[idx]
|
562
|
+
if (((name).start_with?(pfx)) && ((name).end_with?("Test")))
|
563
|
+
klass = ::Quark.quark.reflect.QuarkClass.get(name)
|
564
|
+
methods = klass.getMethods()
|
565
|
+
jdx = 0
|
566
|
+
while ((jdx) < ((methods).size)) do
|
567
|
+
meth = (methods)[jdx]
|
568
|
+
mname = meth.getName()
|
569
|
+
if (((mname).start_with?("test")) && (((meth.getParameters()).size) == (0)))
|
570
|
+
test = ::Quark.quark.test.MethodTest.new(klass, meth)
|
571
|
+
if (test.match(filters))
|
572
|
+
(@tests) << (test)
|
573
|
+
else
|
574
|
+
@filtered = (@filtered) + (1)
|
575
|
+
end
|
576
|
+
end
|
577
|
+
jdx = (jdx) + (1)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
idx = (idx) + (1)
|
581
|
+
end
|
582
|
+
|
583
|
+
nil
|
584
|
+
end
|
585
|
+
|
586
|
+
def list()
|
587
|
+
|
588
|
+
idx = 0
|
589
|
+
while ((idx) < ((@tests).size)) do
|
590
|
+
test = (@tests)[idx]
|
591
|
+
::DatawireQuarkCore.print((test).name)
|
592
|
+
idx = (idx) + (1)
|
593
|
+
end
|
594
|
+
|
595
|
+
nil
|
596
|
+
end
|
597
|
+
|
598
|
+
##
|
599
|
+
# Run the tests, return number of failures.
|
600
|
+
|
601
|
+
def run()
|
602
|
+
|
603
|
+
::DatawireQuarkCore.print(::Quark.quark.test.heading("starting tests"))
|
604
|
+
idx = 0
|
605
|
+
failures = 0
|
606
|
+
while ((idx) < ((@tests).size)) do
|
607
|
+
test = (@tests)[idx]
|
608
|
+
test.start()
|
609
|
+
test.run()
|
610
|
+
test.stop()
|
611
|
+
if ((((test).failures).size) > (0))
|
612
|
+
failures = (failures) + (1)
|
613
|
+
end
|
614
|
+
idx = (idx) + (1)
|
615
|
+
end
|
616
|
+
passed = ((@tests).size) - (failures)
|
617
|
+
::DatawireQuarkCore.print(::Quark.quark.test.heading("stopping tests"))
|
618
|
+
result = ((((((("Total: ") + ((((@tests).size) + (@filtered)).to_s)) + (", Filtered: ")) + ((@filtered).to_s)) + (", Passed: ")) + ((passed).to_s)) + (", Failed: ")) + ((failures).to_s)
|
619
|
+
if ((failures) > (0))
|
620
|
+
::DatawireQuarkCore.print(::Quark.quark.test.red(result))
|
621
|
+
else
|
622
|
+
::DatawireQuarkCore.print(::Quark.quark.test.green(result))
|
623
|
+
end
|
624
|
+
return failures
|
625
|
+
|
626
|
+
nil
|
627
|
+
end
|
628
|
+
|
629
|
+
def json_report()
|
630
|
+
|
631
|
+
::DatawireQuarkCore.print("=============================== json report ===============================")
|
632
|
+
idx = 0
|
633
|
+
report = ::DatawireQuarkCore::JSONObject.new
|
634
|
+
while ((idx) < ((@tests).size)) do
|
635
|
+
item = ::DatawireQuarkCore::JSONObject.new
|
636
|
+
test = (@tests)[idx]
|
637
|
+
f = 0
|
638
|
+
failures = ::DatawireQuarkCore::JSONObject.new
|
639
|
+
while ((f) < (((test).failures).size)) do
|
640
|
+
failures.setListItem(f, ::DatawireQuarkCore::JSONObject.new.setString(((test).failures)[f]))
|
641
|
+
f = (f) + (1)
|
642
|
+
end
|
643
|
+
(item).setObjectItem(("name"), (::DatawireQuarkCore::JSONObject.new.setString((test).name)))
|
644
|
+
(item).setObjectItem(("checks"), (::DatawireQuarkCore::JSONObject.new.setNumber((test).checks)))
|
645
|
+
(item).setObjectItem(("failures"), (failures))
|
646
|
+
report.setListItem(idx, item)
|
647
|
+
idx = (idx) + (1)
|
648
|
+
end
|
649
|
+
::DatawireQuarkCore.print(report.toString())
|
650
|
+
|
651
|
+
nil
|
652
|
+
end
|
653
|
+
|
654
|
+
def _getClass()
|
655
|
+
|
656
|
+
return "quark.test.Harness"
|
657
|
+
|
658
|
+
nil
|
659
|
+
end
|
660
|
+
|
661
|
+
def _getField(name)
|
662
|
+
|
663
|
+
if ((name) == ("pkg"))
|
664
|
+
return (self).pkg
|
665
|
+
end
|
666
|
+
if ((name) == ("tests"))
|
667
|
+
return (self).tests
|
668
|
+
end
|
669
|
+
if ((name) == ("filtered"))
|
670
|
+
return (self).filtered
|
671
|
+
end
|
672
|
+
return nil
|
673
|
+
|
674
|
+
nil
|
675
|
+
end
|
676
|
+
|
677
|
+
def _setField(name, value)
|
678
|
+
|
679
|
+
if ((name) == ("pkg"))
|
680
|
+
(self).pkg = ::DatawireQuarkCore.cast(value) { ::String }
|
681
|
+
end
|
682
|
+
if ((name) == ("tests"))
|
683
|
+
(self).tests = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
684
|
+
end
|
685
|
+
if ((name) == ("filtered"))
|
686
|
+
(self).filtered = ::DatawireQuarkCore.cast(value) { ::Integer }
|
687
|
+
end
|
688
|
+
|
689
|
+
nil
|
690
|
+
end
|
691
|
+
|
692
|
+
def __init_fields__()
|
693
|
+
|
694
|
+
self.pkg = nil
|
695
|
+
self.tests = ::DatawireQuarkCore::List.new([])
|
696
|
+
self.filtered = 0
|
697
|
+
|
698
|
+
nil
|
699
|
+
end
|
700
|
+
|
701
|
+
|
702
|
+
end
|
703
|
+
Harness.unlazy_statics
|
704
|
+
|
705
|
+
def self.testPackages(packages, filters, emitJson)
|
706
|
+
|
707
|
+
h = ::Quark.quark.test.Harness.new("")
|
708
|
+
total_failures = 0
|
709
|
+
idx = 0
|
710
|
+
while ((idx) < ((packages).size)) do
|
711
|
+
(h).pkg = (packages)[idx]
|
712
|
+
h.collect(filters)
|
713
|
+
idx = (idx) + (1)
|
714
|
+
end
|
715
|
+
total_failures = h.run()
|
716
|
+
if (emitJson)
|
717
|
+
h.json_report()
|
718
|
+
end
|
719
|
+
return total_failures
|
720
|
+
|
721
|
+
|
722
|
+
nil
|
723
|
+
end
|
724
|
+
|
725
|
+
def self.run(args)
|
726
|
+
|
727
|
+
pkg = (args)[0]
|
728
|
+
filters = ::DatawireQuarkCore::List.new([])
|
729
|
+
list = false
|
730
|
+
json = false
|
731
|
+
idx = 1
|
732
|
+
while ((idx) < ((args).size)) do
|
733
|
+
arg = (args)[idx]
|
734
|
+
if ((arg) == ("-l"))
|
735
|
+
list = true
|
736
|
+
else
|
737
|
+
if ((arg) == ("--json"))
|
738
|
+
json = true
|
739
|
+
else
|
740
|
+
if ((arg) == ("--unsafe"))
|
741
|
+
::Quark.quark.test.SafeMethodCaller.useSafeCalls = false
|
742
|
+
else
|
743
|
+
(filters) << (arg)
|
744
|
+
end
|
745
|
+
end
|
746
|
+
end
|
747
|
+
idx = (idx) + (1)
|
748
|
+
end
|
749
|
+
if (list)
|
750
|
+
h = ::Quark.quark.test.Harness.new(pkg)
|
751
|
+
h.collect(filters)
|
752
|
+
h.list()
|
753
|
+
else
|
754
|
+
::DatawireQuarkCore.print(::Quark.quark.test.bold(("Running: ") + ((args).join(" "))))
|
755
|
+
failures = ::Quark.quark.test.testPackages(::DatawireQuarkCore::List.new([pkg]), filters, json)
|
756
|
+
if ((failures) > (0))
|
757
|
+
::Quark.quark.concurrent.Context.runtime().fail("Test run failed.")
|
758
|
+
end
|
759
|
+
end
|
760
|
+
|
761
|
+
|
762
|
+
nil
|
763
|
+
end
|
764
|
+
end # module Test
|
765
|
+
end # module Quark
|
766
|
+
end # module Quark
|