Top Level Namespace
Defined Under Namespace
Modules: CRC, Generators, Kernel, MattiVerify, MobyBase, MobyBehaviour, MobyCommand, MobyController, MobyPlugin, MobyUtil, RDoc, ReportDataTable, TDriver, TDriverCustomErrorRecovery, TDriverErrorRecovery, TDriverReport, TDriverReportAPI, TDriverReportCreator, TDriverReportDataPresentation, TDriverReportFileCapture, TDriverReportJavascript, TDriverReportTestUnit, TDriverReportWriter, TDriverVerify
Classes: Exception, FalseClass, FileNotFoundError, Hash, MATTI, MobyStandardError, Numeric, Object, ReportCombine, ReportGraphGenerator, ReportJUnitXml, ReportingGroups, ReportingStatistics, String, TDriverErrorRecoverySettings, TDriverReportCrashFileCapture, TrueClass
Instance Method Summary
collapse
-
#change_attr_value(node, attribute_name, value) ⇒ Object
-
#change_value(path, attribute, value) ⇒ Object
-
#clean_e(ee) ⇒ Object
-
#collect_documented_features ⇒ Object
def collect_all_features.
-
#collect_feature_tests ⇒ Object
-
#create_global_reporter_hook_for_test_unit ⇒ Object
Report module which contains the Test::Unit report formatter.
-
#dump_hash_values(hash, path = "") ⇒ Object
-
#execute_tdriver_devtools ⇒ Object
-
#find_xml_element(document, name) ⇒ Object
require File.expand_path( File.join( File.dirname( __FILE__ ), ‘xml/xml’ ) ) require File.expand_path( File.join( File.dirname( __FILE__ ), ‘common’ ) ).
-
#generate_document_xml ⇒ Object
-
#help ⇒ Object
-
#load_templates ⇒ Object
-
#print_key(key, value) ⇒ Object
-
#process_behaviour_file(content) ⇒ Object
-
#process_behaviour_hash_file(content) ⇒ Object
-
#process_result_file(content) ⇒ Object
-
#qdoc_footer ⇒ Object
-
#qdoc_header(sut_type) ⇒ Object
-
#read_behaviour_hash_files(folder) ⇒ Object
-
#read_behaviour_xml_files(folder) ⇒ Object
-
#read_test_result_files(folder) ⇒ Object
-
#resolve_hash_path(hash, path_string) ⇒ Object
-
#safe_require(*paths) ⇒ Object
Instance Method Details
#change_attr_value(node, attribute_name, value) ⇒ Object
34
35
36
37
38
|
# File 'lib/tdriver/util/other/config.rb', line 34
def change_attr_value( node, attribute_name, value )
node.xml.attr( attribute_name, value.to_s )
end
|
#change_value(path, attribute, value) ⇒ Object
#clean_e(ee) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb', line 38
def clean_e( ee )
ce = ee.chomp
if ce[0, 1].to_s == "<"
ce = ce[si = ce.index(">")+1, ce.rindex("<") - si]
return ce
else
return ee
end
end
|
#collect_documented_features ⇒ Object
def collect_all_features
@behaviour_hashes.collect{ | module_name, methods |
methods.collect{ | method |
"%s#%s" % [ module_name, method ]
}
}.flatten
end
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 423
def collect_documented_features
behaviours = {}
@behaviours.each{ | behaviour |
file_name = behaviour[ :filename ]
behaviour_config = behaviour[:behaviours]["__config"] || {}
behaviour[:behaviours]["behaviours"].each{ | behaviour |
config = Hash[ behaviour.select{ | key, value | key != "methods" } ]
module_name = behaviour["module"].first
behaviour["methods"].each{ | method |
method["name"].each{ | method_name |
behaviours[ "%s#%s" % [ module_name, method_name ] ] = method.merge( "__file" => file_name, "__behaviour" => config.merge( behaviour_config ) )
}
}
}
}.flatten
behaviours
end
|
#collect_feature_tests ⇒ Object
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 459
def collect_feature_tests
result = {}
@feature_tests.collect{ | feature |
result[ ( feature["description"] || ["no feature test description"] ).first ] =
( feature["scenarios"] || [] ).collect{ | scenario |
step_results = ( scenario[ "step" ] || [] ).collect{ | step |
next if /^#/.match( step )
if /^.*\s{1}(\w+)$/.match( step )
$1
else
"unknown"
end
}
step_results.compact! unless step_results.nil?
unless scenario["example_step"].nil?
scenario["example_step"] = [ scenario["example_step"].join( "\n" ) ]
end
( scenario["example_step"] || [] ).collect{ | example |
begin
code = /"([^\"]*)"\s/m.match( example ).captures.first
status = /^.*\s{1}(\w+)$/m.match( example ).captures.to_a
if status.first.to_s.downcase == 'passed'
if ( step_results - status ).count > 0
status_literal = "failed"
$failed += 1
else
status_literal = "passed"
$passed += 1
end
else
if status.first.to_s.empty?
status_literal = "unknown"
$unknown += 1
else
status_literal = "failed"
$failed += 1
end
end
rescue Exception => exception
warn("Ambiguous 'example_step': %s (%s: %s)" % [ example.inspect, exception.class, exception.message ])
code = "Error while extracting the code from test"
status_literal = "unknown"
$unknown += 1
end
[
"example" => code,
"status" => status_literal,
"description" => ( scenario["description"] || "" )
]
}.flatten
}.flatten
}.flatten
result
end
|
#create_global_reporter_hook_for_test_unit ⇒ Object
Report module which contains the Test::Unit report formatter
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/tdriver/report/report_test_unit.rb', line 23
def create_global_reporter_hook_for_test_unit()
eval("
module Test #:nodoc:all
module Unit
module UI
module Console
class TestRunner
def create_mediator(suite)
# swap in TDriver custom mediator
return TDriverReportTestUnit::TestUnit.new(suite)
end
end #TestRunner
end #Console
end #UI
end #Unit
end #Test
")
end
|
#dump_hash_values(hash, path = "") ⇒ Object
169
170
171
|
# File 'lib/tdriver/util/other/config.rb', line 169
def dump_hash_values( hash, path = "" )
hash.keys.sort{ |a,b| a.to_s <=> b.to_s }.each{ | key | print_key( key, hash[ key ] ) }
end
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
# File 'lib/tdriver-devtools/tdriver-devtools.rb', line 230
def execute_tdriver_devtools
@optparse.parse!
case @options[ :generate ]
when :behaviours
$source = File.expand_path( ARGV[ 0 ] || @options[ :source ] )
$destination = File.expand_path( ARGV[ 1 ] || @options[ :destination ] )
destination_folder = File.expand_path( $destination )
if MobyUtil::FileHelper.folder_exist?( destination_folder )
if @options[ :delete ] == true
Dir.glob( File.join( destination_folder, '**', '**', '*.xml' ) ) do |entry|
begin
File.delete( entry )
rescue Exception => exception
warn("Unable to delete file %s (%s: %s)" % [ entry, exception.class, exception.message ] )
end
end
end
else
begin
MobyUtil::FileHelper.mkdir_path( destination_folder )
rescue Exception => exception
raise RuntimeError.new("Unable to create destination folder %s (%s: %s)" % [ destination_folder, exception.class, exception.message ])
end
end
require File.expand_path( File.join( File.dirname( __FILE__ ), 'behaviour/xml/generate.rb' ) )
puts ''
when :doc
$source = File.expand_path( ARGV[0] || @options[ :source ] )
$tests = File.expand_path( @options[ :tests ] )
$destination = File.expand_path( ARGV[1] || @options[ :destination ] )
destination_folder = File.dirname( $destination )
begin
unless MobyUtil::FileHelper.folder_exist?( destination_folder )
MobyUtil::FileHelper.mkdir_path( destination_folder )
end
rescue Exception => exception
raise RuntimeError.new("Unable to create destination folder %s (%s: %s)" % [ destination_folder, exception.class, exception.message ])
end
require File.expand_path( File.join( File.dirname( __FILE__ ), 'doc/generate.rb' ) )
when :both
destination_folder = @options[ :destination_behaviours ]
begin
unless MobyUtil::FileHelper.folder_exist?( destination_folder )
MobyUtil::FileHelper.mkdir_path( destination_folder )
else
if @options[ :delete ] == true
Dir.glob( File.join( destination_folder, '*.xml' ) ) do |entry|
begin
File.delete( entry )
rescue Exception => exception
warn("Unable to delete file %s (%s: %s)" % [ entry, exception.class, exception.message ] )
end
end
end
end
rescue Exception => exception
raise RuntimeError.new("Unable to create destination folder %s (%s: %s)" % [ destination_folder, exception.class, exception.message ])
end
$source = File.expand_path( ARGV[ 0 ] || @options[ :source ] )
$destination = destination_folder
require File.expand_path( File.join( File.dirname( __FILE__ ), 'behaviour/xml/generate.rb' ) )
$source = destination_folder
$tests = File.expand_path( @options[ :tests ] )
$destination = File.expand_path( ARGV[1] || @options[ :destination ] )
destination_folder = File.dirname( $destination )
begin
unless MobyUtil::FileHelper.folder_exist?( destination_folder )
MobyUtil::FileHelper.mkdir_path( destination_folder )
end
rescue Exception => exception
raise RuntimeError.new("Unable to create destination folder %s (%s: %s)" % [ destination_folder, exception.class, exception.message ])
end
require File.expand_path( File.join( File.dirname( __FILE__ ), 'doc/generate.rb' ) )
begin
FileUtils.cp( Dir.glob( File.expand_path( File.join( File.dirname( __FILE__ ), 'doc/xslt/*.xsl' ) ) ), destination_folder )
puts "Template XSLT file(s) copied to destination folder succesfully\n\n"
rescue Exception => exception
warn("Error while copying template xslt files to destination due to %s (%s)" % [ exception.message, exception.class ] )
end
if @options[:render] == true
begin
doc = Nokogiri::XML( open( $destination , 'r' ).read )
puts "Generating HTML output file(s) of documentation"
Dir.glob( File.expand_path( File.join( destination_folder, '*.xsl' ) ) ) do | template |
File.open(
File.join(
destination_folder,
"#{ File.basename( $destination ).gsub( File.extname( $destination ), '' ) }_#{ File.basename( template ).gsub( File.extname( template ), '' ) }.html"
),
'w'
){ | file |
file << Nokogiri::XSLT( open( template, 'r' ).read ).transform( doc )
}
end
rescue Exception => exception
warn("Error while geneating HTML files from template(s) due to %s (%s)" % [ exception.message, exception.class ] )
end
end
else
puts '', @optparse, ''
end
end
|
#find_xml_element(document, name) ⇒ Object
require File.expand_path( File.join( File.dirname( __FILE__ ), ‘xml/xml’ ) ) require File.expand_path( File.join( File.dirname( __FILE__ ), ‘common’ ) )
28
29
30
31
32
|
# File 'lib/tdriver/util/other/config.rb', line 28
def find_xml_element( document, name )
document.root.xpath( "/parameters/*[@name='#{ name }']" )
end
|
#generate_document_xml ⇒ Object
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 557
def generate_document_xml
doc = Nokogiri::XML::Builder.new{ | xml |
xml.documentation{
@documented_features.sort.each{ | feature_name, feature_documentation |
feature_documentation.default = ""
module_name, method_name = feature_name.split("#")
feature_type = feature_documentation[ "type" ].first
arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
}
@documented_features.sort.each{ | feature, feature_documentation |
module_name, method_name = feature.split("#")
feature_type = feature_documentation[ "type" ].first
arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
feature = "%s#%s" % [ module_name, method_name ]
feature_name = case feature_type
when "accessor"
[ method_name, method_name + "=" ]
when "writer"
[ method_name + "=" ]
when "reader", "method"
[ method_name ]
else
warn("Unknown feature type %s for %s" % [ feature_type, feature ] )
[ method_name ]
end
$features += 1
if feature_documentation["nodoc"][0].to_s.downcase == "true"
$features_nodoc += 1
next
end
xml.feature(
:type => feature_type,
:name => feature_name.join(";"),
:required_plugin => feature_documentation[ "__behaviour" ][ "plugin" ],
:sut_type => feature_documentation["__behaviour"][ "sut_type" ].join(";"),
:sut_version => feature_documentation["__behaviour"][ "version" ].join(";"),
:input_type => feature_documentation["__behaviour"][ "input_type" ].join(";"),
:object_type => feature_documentation["__behaviour"][ "object_type" ].join(";")
){
xml.behaviour(
:name => feature_documentation[ "__behaviour" ][ "name" ],
:module => module_name
)
if feature_documentation.has_key?( "deprecated" )
xml.deprecated( :version => feature_documentation[ "deprecated" ] )
end
xml.description( feature_documentation[ "description" ] )
xml.info( feature_documentation[ "info" ] )
feature_documentation[ "arguments" ] = [] if feature_documentation[ "arguments" ].kind_of?( String )
xml.arguments(
:count => arguments_count,
:optional => optional_arguments_count,
:described => feature_documentation[ "arguments" ].count,
:block => feature_documentation[ "arguments" ].select{ | arg | ( arg[ "type" ] || [] ).first == "block" }.count > 0
){
( feature_documentation[ "arguments" ] || [] ).each do | argument |
xml.argument(
:name => argument[ "name" ].first,
:optional => argument[ "optional" ].first,
:default => ( argument[ "default" ] || [] ).first,
:type => argument[ "type" ].first
){
( argument[ "types" ] || [{}] ).each{ | type |
type.each_pair do | argument_type, value |
xml.type!( :name => argument_type ){
xml.description( value[ "description" ] )
xml.example( value[ "example" ] )
}
end
}
}
end
}
xml.returns( :described => feature_documentation[ "returns" ].size ){
( feature_documentation[ "returns" ] || [{}] ).each do | return_value |
return_value.each_pair do | variable_type, value |
xml.type_( :name => variable_type ){
xml.description( value[ "description" ] || "" )
xml.example( value[ "example" ] || "" )
}
end
end
}
xml.exceptions( :described => feature_documentation[ "exceptions" ].size ){
( feature_documentation[ "exceptions" ] || [{}] ).each do | exception |
exception.each_pair do | exception_type, value |
xml.type_( :name => exception_type ){
xml.description( value[ "description" ] )
}
end
end
}
xml.tables{
( feature_documentation[ "tables" ] || [{}] ).each do | table |
xml.table( :name => table[ "name" ] ){
xml.title( table[ "title" ].to_s )
xml.description( table[ "description" ].to_s )
xml.{
( table[ "header" ] || [[]] ).first.each{ | item |
xml.item( item )
}
}
( table[ "row" ] || [] ).each{ | row |
xml.row{
row.each{ | item |
xml.item( item )
}
}
}
}
end
}
names = feature_name.collect{ | name |
feature.split("#").first + "#" + name
}
tests = names.collect{ | feature_test |
{ feature_test => @executed_tests[ feature_test ] || {} }
}.flatten
xml.tests(
:count => tests.count,
:passed => tests.select{ | scenario | scenario[ "status" ] == "passed" }.count,
:skipped => tests.select{ | scenario | scenario[ "status" ] == "skipped" }.count,
:failed => tests.select{ | scenario | scenario[ "status" ] == "failed" }.count
){
tests.each do | scenario |
scenario.each_pair do | scenario_name, scenarios |
scenarios.each do | scenario_value |
xml.scenario(
:type => ( feature_type == "accessor" ? ( ( scenario_name[-1] == ?= ) ? "writer" : "reader" ) : feature_type ),
:status => scenario_value[ "status" ]
){
xml.description( scenario_value[ "description" ] )
xml.example( scenario_value[ "example" ] )
}
end
end
end
}
}
}
}
}
doc.to_xml.to_s.gsub("<?xml version=\"1.0\"?>") do | head |
result = head
result << "\n"
result << "<?xml-stylesheet type=\"text/xsl\" href=\"template.xsl\"?>"
end
end
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/tdriver/util/other/config.rb', line 111
def help
=begin
Usage:
Products:
Options:
-a arch architecture [all] (arm, x86, all)
-c path custom scratchbox path [/scratchbox]
-d display debug messages
WARNING: may contain sensitive information such as password
-e create targets that use files.maemo.org as the repository
-f overwrite previously existing target if one exists
-h display help
-p pass password for the repository/rootstrap download
-r name release name [pre-release] (current, pre-release, previous)
you can use build number instead of release name
-s select the created target
-t prefix custom prefix for target names [maemoX]
target name will be \$prefix-\$arch
-u user username for the repository/rootstrap download
-A save authentication data into .netrc in your scratchbox home
WARNING: your username and password will be written
in cleartext into your scratchbox home .netrc
-C config use custom configuration as rootstrap [minimaldev]
configuration used will be \$arch-\$config
-D don't install debug links
-I don't install files to rootstrap
-P don't allow unauthenticated packages
-R don't install rootstrap
-S keep sources.list provided by rootstrap
-U save authentication data in sources.list
WARNING: your username and password will be written
in cleartext into your target's sources.list
=end
puts <<HELP
Usage:
tdriver-config read [path]
Example:
tdriver-config read - List keys from root level
tdriver-config read sut_qt - List keys from "sut_qt" hash
tdriver-config read sut_qt/keymap/kApp - Retrieve value of kApp
HELP
exit
end
|
#load_templates ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/tdriver-devtools/tests/feature_tests/generate.rb', line 39
def load_templates
Dir.glob( File.join( File.dirname( File.expand_path( __FILE__ ) ), 'templates', '*.template' ) ).each{ | file |
name = File.basename( file ).gsub( '.template', '' )
$templates[ name.to_sym ] = open( file, 'r' ).read
}
end
|
#print_key(key, value) ⇒ Object
165
166
167
|
# File 'lib/tdriver/util/other/config.rb', line 165
def print_key( key, value )
puts "%s %s" % [ "#{key} ".ljust(65, '.'), value.kind_of?( Hash ) ? "<Multiple values>" : "\"#{ value.to_s }\"" ]
end
|
#process_behaviour_file(content) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 86
def process_behaviour_file( content )
begin
doc = Nokogiri::XML::parse( content )
behaviour_config = Hash[ doc.root.attributes.collect{ | attribute | [ attribute.first, attribute.last.value ] } ]
rescue Exception => exception
abort("Error while parsing behaviour:\n#{ content }")
end
result = { "behaviours" => [], "__config" => behaviour_config }
doc.root.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^behaviour$/i
behaviour = {}
child.attributes.each{ | attribute |
behaviour[ attribute.first ] = attribute.last.value.split(";")
}
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^methods$/i
methods = []
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
method = {}
child.attributes.each{ | attribute |
method[ attribute.first ] = attribute.last.value.split(";")
}
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^deprecated$/i
method[ "deprecated" ] = child.attribute("version").value.to_s
when /^description$/i, /^info$/i
method[ child.name.to_s ] = child.inner_text
when /^arguments$/i
method[ "arguments_data" ] = {}
arguments = []
child.attributes.each{ | attribute |
method[ "arguments_data" ][ attribute.first ] = attribute.last.value
}
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
argument = { "types" => [] }
child.attributes.each{ | attribute |
argument[ attribute.first ] = attribute.last.value.split(";")
}
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^default$/
argument[ child.name.to_s ] = child.inner_text.to_s
when /^type$/
argument[ "types" ] << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
arguments << argument
}
method[ "arguments" ] = arguments
when /^returns$/i
returns = []
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^type$/
returns << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
method[ "returns" ] = returns
when /^exceptions$/i
exceptions = []
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^exception$/
exceptions << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
method[ "exceptions" ] = exceptions
when /^tables$/i
tables = []
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^table$/i
table = { "name" => child.attribute("name").value, "title" => "", "header" => [], "row" => [] }
child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
case child.name.to_s
when /^title$/i
table[ "title" ] = child.inner_text
when /^description$/i
table[ "description" ] = child.inner_text
when /^header$/i, /^row$/i
table[ child.name.to_s ] << child.children.select{ | node |
node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child |
child.inner_text
}
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
tables << table
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
method[ "tables" ] = tables
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
methods << method
}
behaviour[ "methods" ] = methods
when /^module$/i
behaviour[ child.name.to_s ] = child.attribute("name").value.split(";")
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
result[ "behaviours" ] << behaviour
when /^text$/i
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
}
result
end
|
#process_behaviour_hash_file(content) ⇒ Object
80
81
82
83
84
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 80
def process_behaviour_hash_file( content )
eval( content )
end
|
#process_result_file(content) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 13
def process_result_file( content )
result = { "__file" => @current_file }
content.gsub!( ' ', ' ' )
doc = Nokogiri::XML::parse( content )
doc.root.children.each{ | child |
if child.kind_of?( Nokogiri::XML::Element )
case child.name.to_s
when /^description$/i
result[ child.name.to_s ] = ( result[ child.name.to_s ] || [] ) + child.inner_text.split("\n").collect{ | value | value.empty? ? nil : value.strip }.compact
when /^scenarios$/i
scenarios = []
child.children.each{ | scenario |
scenario_data = {}
scenario.children.each{ | data |
if child.kind_of?( Nokogiri::XML::Element )
scenario_data[ data.name.to_s ] = ( scenario_data[ data.name.to_s ] || [] ) + data.inner_text.split("\n").collect{ | value | value.empty? ? nil : value.strip }.compact
end
}
scenarios << scenario_data
}
result[ child.name.to_s ] = scenarios
when /^text$/i
else
puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
end
end
}
result
end
|
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb', line 27
def
=
"\nJump back to \l{page start}{top} of this page.
*/"
return
end
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb', line 5
def ( sut_type )
=
"/*!
\\page methods-auto-#{sut_type}
\\target page start
\\title Methods for #{sut_type} test objects
Table of contents:
\\tableofcontents section2
\\part Methods for #{sut_type}
These methods can be used with a #{sut_type} SUT.
"
return
end
|
#read_behaviour_hash_files(folder) ⇒ Object
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 386
def read_behaviour_hash_files( folder )
Dir.glob( File.join( folder, '*.hash' ) ).each{ | file |
@current_file = file
content = open( file, 'r' ).read
process_behaviour_hash_file( open( file, 'r' ).read ).each_pair{ | key, value |
@behaviour_hashes[ key.to_s ] = ( @behaviour_hashes[ key.to_s ] || [] ) | value
}
}
abort "No behaviour XML files found from folder '#{ folder }'" if @behaviour_hashes.empty?
end
|
#read_behaviour_xml_files(folder) ⇒ Object
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 363
def read_behaviour_xml_files( folder )
if File.directory?( folder )
files = Dir.glob( File.join( folder, '*.xml' ) )
else
files = [ folder ]
end
files.each{ | file |
@current_file = file
@behaviours << { :filename => file, :behaviours => process_behaviour_file( open( file, 'r' ).read ) }
}
puts "Behaviour XML files: #{ @behaviours.count }"
end
|
#read_test_result_files(folder) ⇒ Object
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
# File 'lib/tdriver-devtools/doc/generate.rb', line 347
def read_test_result_files( folder )
Dir.glob( File.join( folder, '*.xml' ) ).each{ | file |
@current_file = file
@feature_tests << process_result_file( open( file, 'r' ).read )
}
puts "\nTest result files: #{ @feature_tests.count }"
end
|
#resolve_hash_path(hash, path_string) ⇒ Object
173
174
175
176
177
178
179
180
181
|
# File 'lib/tdriver/util/other/config.rb', line 173
def resolve_hash_path( hash, path_string )
return [ "", hash ] if path_string.nil? or ( path_string.kind_of?( String) and path_string.empty? )
path = hash; path_array = path_string.split( "/" ); current_path = []
[ path_array[ -1 ], ( path_array.collect{ | key |
current_path = current_path + [ key ]
if !path.has_key?( key.to_sym ); puts "No such key/hash found (%s)\n\n" % [ current_path.join( "::" ) ]; exit; end
path = path[ key.to_sym ]
}.compact)[ -1 ] ]
end
|
#safe_require(*paths) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/tdriver-devtools/tdriver-devtools.rb', line 23
def safe_require( *paths )
found = false
paths.each{ | path |
begin
require path
found = true
break
rescue LoadError
end
}
abort("Unable to load one of files: %s" % paths.inspect ) unless found
end
|