testability-driver 1.3.0 → 1.3.1
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/ext/native_extensions.c +53 -25
- data/lib/matti.rb +0 -5
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +4 -4
- data/lib/tdriver/base/behaviour/factory.rb +120 -7
- data/lib/tdriver/base/errors.rb +1 -1
- data/lib/tdriver/base/state_object.rb +3 -2
- data/lib/tdriver/base/sut/controller.rb +2 -2
- data/lib/tdriver/base/sut/factory.rb +207 -201
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +3 -6
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +1 -1
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +14 -14
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +5 -5
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +14 -14
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +3 -18
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +6 -6
- data/lib/tdriver/base/sut/generic/plugin.rb +4 -9
- data/lib/tdriver/base/sut/sut.rb +2 -6
- data/lib/tdriver/base/test_object/abstract.rb +1 -1
- data/lib/tdriver/base/test_object/adapter.rb +5 -5
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +7 -6
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +18 -18
- data/lib/tdriver/base/test_object/factory.rb +147 -96
- data/lib/tdriver/base/test_object/verification.rb +6 -9
- data/lib/tdriver/base/test_object/xml/adapter.rb +5 -5
- data/lib/tdriver/matti.rb +1 -1
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +17 -8
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +7 -7
- data/lib/tdriver/report/report_api.rb +172 -79
- data/lib/tdriver/report/report_crash_file_capture.rb +4 -7
- data/lib/tdriver/report/report_creator.rb +16 -20
- data/lib/tdriver/report/report_file_capture.rb +3 -3
- data/lib/tdriver/report/report_javascript.rb +3 -3
- data/lib/tdriver/report/report_test_case_run.rb +20 -10
- data/lib/tdriver/report/report_test_run.rb +11 -10
- data/lib/tdriver/report/report_writer.rb +13 -11
- data/lib/tdriver/tdriver.rb +6 -6
- data/lib/tdriver/util/common/array.rb +2 -2
- data/lib/tdriver/util/common/file.rb +9 -11
- data/lib/tdriver/util/common/gem.rb +1 -1
- data/lib/tdriver/util/common/kernel.rb +4 -4
- data/lib/tdriver/util/common/retryable.rb +2 -2
- data/lib/tdriver/util/common/string.rb +2 -3
- data/lib/tdriver/util/hooking/hooking.rb +2 -2
- data/lib/tdriver/util/localisation/localisation.rb +12 -12
- data/lib/tdriver/util/logger/logger.rb +7 -25
- data/lib/tdriver/util/operator_data/operator_data.rb +5 -5
- data/lib/tdriver/util/parameter/parameter.rb +2 -2
- data/lib/tdriver/util/plugin/abstract.rb +4 -3
- data/lib/tdriver/util/plugin/service.rb +31 -4
- data/lib/tdriver/util/recorder/recorder.rb +4 -4
- data/lib/tdriver/util/user_data/user_data.rb +5 -5
- data/lib/tdriver/util/video/camera_windows.rb +1 -1
- data/lib/tdriver/util/xml/builder.rb +3 -1
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +1 -1
- data/lib/tdriver/util/xml/xml.rb +5 -5
- data/lib/tdriver/verify/verify.rb +26 -26
- data/lib/tdriver/version.rb +1 -1
- data/xml/behaviours/generic.xml +1 -2
- metadata +2 -3
- data/lib/tdriver/verify/verify.rb_org +0 -630
@@ -29,7 +29,7 @@ module MobyUtil
|
|
29
29
|
#TODO detect app start for later versions...
|
30
30
|
def self.start_rec( app )
|
31
31
|
|
32
|
-
#
|
32
|
+
#raise ArgumentError.new("Application must be defined.") unless app
|
33
33
|
app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
|
34
34
|
|
35
35
|
app.start_recording
|
@@ -40,13 +40,13 @@ module MobyUtil
|
|
40
40
|
def self.print_script( sut, app, object_identificators = ['text','icontext','label'] )
|
41
41
|
|
42
42
|
# verify that sut type is type of MobyBase::SUT
|
43
|
-
#
|
43
|
+
#raise ArgumentError.new("Sut must be defined.") unless sut
|
44
44
|
sut.check_type( MobyBase::SUT, "Wrong argument type $1 for SUT (expected $2)" )
|
45
45
|
|
46
|
-
#
|
46
|
+
#raise ArgumentError.new("Application must be defined.") unless app
|
47
47
|
app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
|
48
48
|
|
49
|
-
#
|
49
|
+
#raise ArgumentError.new("Object identificators must be set, use defaults if not sure what the use.") unless object_identificators
|
50
50
|
object_identificators.check_type( Array, "Wrong argument type $1 for object identificators (expected $2)" )
|
51
51
|
|
52
52
|
xml_source = app.print_recordings
|
@@ -61,7 +61,7 @@ module MobyUtil
|
|
61
61
|
#
|
62
62
|
def self.retrieve( user_data_lname, language, table_name = nil )
|
63
63
|
|
64
|
-
|
64
|
+
raise UserDataNotFoundError.new( "User data logical name can't be empty" ) if user_data_lname == nil
|
65
65
|
|
66
66
|
# Get Localization parameters for DB Connection
|
67
67
|
db_type = $parameters[ :user_data_db_type, nil ].to_s.downcase
|
@@ -78,13 +78,13 @@ module MobyUtil
|
|
78
78
|
begin
|
79
79
|
result = MobyUtil::DBAccess.query( db_connection, query_string )
|
80
80
|
rescue
|
81
|
-
# if column referring to language is not found then
|
82
|
-
|
83
|
-
|
81
|
+
# if column referring to language is not found then raise error for language not found
|
82
|
+
raise UserDataColumnNotFoundError.new( "User data language column '#{ language }' was not found" ) unless $!.message.index( "Unknown column" ) == nil
|
83
|
+
raise SqlError.new( $!.message )
|
84
84
|
end
|
85
85
|
|
86
86
|
# Return only the first column of the row or and array of the values of the first column if multiple rows have been found
|
87
|
-
|
87
|
+
raise UserDataNotFoundError.new( "No user data for '#{ user_data_lname }' found for language '#{ language }'" ) if ( result.empty?)
|
88
88
|
if result.length > 1
|
89
89
|
result_array = Array.new # array of rows! We want the first column of the first row
|
90
90
|
result.each do |row|
|
@@ -99,7 +99,7 @@ module MobyUtil
|
|
99
99
|
|
100
100
|
if @_control_id == 0
|
101
101
|
|
102
|
-
|
102
|
+
raise RuntimeError.new( "Failed to start video recording.\nFile: " + @_video_file + "\nFPS: " + @_rec_options[ :fps ].to_s + "\nWidth: " + @_rec_options[ :width ].to_s + "\nHeight: " + @_rec_options[ :height ].to_s )
|
103
103
|
|
104
104
|
end
|
105
105
|
|
@@ -29,7 +29,9 @@ module MobyUtil
|
|
29
29
|
|
30
30
|
if block_given?
|
31
31
|
|
32
|
-
|
32
|
+
file, line = caller.first.split( ":" )
|
33
|
+
|
34
|
+
$stderr.puts "#{ file }:#{ line } warning: deprecated method #{ self.class }#new, use MobyUtil::XML#build instead"
|
33
35
|
|
34
36
|
# extend builder behaviour of current parser
|
35
37
|
self.extend( ( MobyUtil::XML.current_parser )::Builder )
|
@@ -50,7 +50,7 @@ module MobyUtil
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def method_missing( method, *args, &block )
|
53
|
-
|
53
|
+
raise RuntimeError.new("Method '#{ method.to_s }' is not supported by #{ self.class.to_s } (#{ @parser.to_s })" )
|
54
54
|
end
|
55
55
|
|
56
56
|
# method to create MobyUtil::XML::Element object
|
data/lib/tdriver/util/xml/xml.rb
CHANGED
@@ -247,12 +247,12 @@ module MobyUtil
|
|
247
247
|
end
|
248
248
|
|
249
249
|
# raise exception
|
250
|
-
|
250
|
+
raise MobyUtil::XML::ParseError, "#{ $!.message.gsub("\n", '') } (#{ $!.class }). #{ dump_location }"
|
251
251
|
|
252
252
|
else
|
253
253
|
|
254
254
|
# raise exception
|
255
|
-
|
255
|
+
raise MobyUtil::XML::ParseError, "#{ $!.message.gsub("\n", '') } (#{ $!.class })"
|
256
256
|
|
257
257
|
end
|
258
258
|
|
@@ -270,11 +270,11 @@ module MobyUtil
|
|
270
270
|
# == return
|
271
271
|
# Document:: XML document object
|
272
272
|
# == raises
|
273
|
-
# IOError:: File
|
273
|
+
# IOError:: File <name> not found
|
274
274
|
def self.parse_file( filename )
|
275
275
|
|
276
276
|
# raise exception if file not found
|
277
|
-
|
277
|
+
raise IOError, "File #{ filename.inspect } not found" unless File.exist?( filename )
|
278
278
|
|
279
279
|
# parse file content
|
280
280
|
parse_string(
|
@@ -315,7 +315,7 @@ module MobyUtil
|
|
315
315
|
|
316
316
|
rescue
|
317
317
|
|
318
|
-
|
318
|
+
raise MobyUtil::XML::BuilderError, "#{ $!.message } (#{ $!.class })"
|
319
319
|
|
320
320
|
end
|
321
321
|
|
@@ -108,10 +108,10 @@ module TDriverVerify
|
|
108
108
|
message = "#{ message.inspect } " if message.length > 0
|
109
109
|
|
110
110
|
# store original timeout value
|
111
|
-
original_timeout_value =
|
111
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
112
112
|
|
113
113
|
# set the testobject timeout to 0 for the duration of the verify call
|
114
|
-
|
114
|
+
TDriver::TestObjectFactory.timeout = 0
|
115
115
|
|
116
116
|
loop do
|
117
117
|
|
@@ -170,7 +170,7 @@ module TDriverVerify
|
|
170
170
|
ensure
|
171
171
|
|
172
172
|
# restore original test object factory timeout value
|
173
|
-
|
173
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
174
174
|
|
175
175
|
# restore logger state
|
176
176
|
$logger.enabled = logging_enabled
|
@@ -232,10 +232,10 @@ module TDriverVerify
|
|
232
232
|
message = "#{ message.inspect } " if message.length > 0
|
233
233
|
|
234
234
|
# store original timeout value
|
235
|
-
original_timeout_value =
|
235
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
236
236
|
|
237
237
|
# set the testobject timeout to 0 for the duration of the verify call
|
238
|
-
|
238
|
+
TDriver::TestObjectFactory.timeout = 0
|
239
239
|
|
240
240
|
# result container
|
241
241
|
result = nil
|
@@ -302,7 +302,7 @@ module TDriverVerify
|
|
302
302
|
ensure
|
303
303
|
|
304
304
|
# restore original test object factory timeout value
|
305
|
-
|
305
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
306
306
|
|
307
307
|
# restore logger state
|
308
308
|
$logger.enabled = logging_enabled
|
@@ -368,10 +368,10 @@ module TDriverVerify
|
|
368
368
|
message = "#{ message.inspect } " if message.length > 0
|
369
369
|
|
370
370
|
# store original timeout value
|
371
|
-
original_timeout_value =
|
371
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
372
372
|
|
373
373
|
# set the testobject timeout to 0 for the duration of the verify call
|
374
|
-
|
374
|
+
TDriver::TestObjectFactory.timeout = 0
|
375
375
|
|
376
376
|
# result container
|
377
377
|
result = nil
|
@@ -441,7 +441,7 @@ module TDriverVerify
|
|
441
441
|
ensure
|
442
442
|
|
443
443
|
# restore original test object factory timeout value
|
444
|
-
|
444
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
445
445
|
|
446
446
|
# restore logger state
|
447
447
|
$logger.enabled = logging_enabled
|
@@ -507,10 +507,10 @@ module TDriverVerify
|
|
507
507
|
message = "#{ message.inspect } " if message.length > 0
|
508
508
|
|
509
509
|
# store original timeout value
|
510
|
-
original_timeout_value =
|
510
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
511
511
|
|
512
512
|
# set the testobject timeout to 0 for the duration of the verify call
|
513
|
-
|
513
|
+
TDriver::TestObjectFactory.timeout = 0
|
514
514
|
|
515
515
|
# result container
|
516
516
|
result = nil
|
@@ -580,7 +580,7 @@ module TDriverVerify
|
|
580
580
|
ensure
|
581
581
|
|
582
582
|
# restore original test object factory timeout value
|
583
|
-
|
583
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
584
584
|
|
585
585
|
# restore logger state
|
586
586
|
$logger.enabled = logging_enabled
|
@@ -644,10 +644,10 @@ module TDriverVerify
|
|
644
644
|
message = "#{ message.inspect } " if message.length > 0
|
645
645
|
|
646
646
|
# store original timeout value
|
647
|
-
original_timeout_value =
|
647
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
648
648
|
|
649
649
|
# set the testobject timeout to 0 for the duration of the verify call
|
650
|
-
|
650
|
+
TDriver::TestObjectFactory.timeout = 0
|
651
651
|
|
652
652
|
# result container
|
653
653
|
result = nil
|
@@ -717,7 +717,7 @@ module TDriverVerify
|
|
717
717
|
ensure
|
718
718
|
|
719
719
|
# restore original test object factory timeout value
|
720
|
-
|
720
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
721
721
|
|
722
722
|
# restore logger state
|
723
723
|
$logger.enabled = logging_enabled
|
@@ -781,10 +781,10 @@ module TDriverVerify
|
|
781
781
|
message = "#{ message.inspect } " if message.length > 0
|
782
782
|
|
783
783
|
# store original timeout value
|
784
|
-
original_timeout_value =
|
784
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
785
785
|
|
786
786
|
# set the testobject timeout to 0 for the duration of the verify call
|
787
|
-
|
787
|
+
TDriver::TestObjectFactory.timeout = 0
|
788
788
|
|
789
789
|
# result container
|
790
790
|
result = nil
|
@@ -854,7 +854,7 @@ module TDriverVerify
|
|
854
854
|
ensure
|
855
855
|
|
856
856
|
# restore original test object factory timeout value
|
857
|
-
|
857
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
858
858
|
|
859
859
|
# restore logger state
|
860
860
|
$logger.enabled = logging_enabled
|
@@ -918,10 +918,10 @@ module TDriverVerify
|
|
918
918
|
message = "#{ message.inspect } " if message.length > 0
|
919
919
|
|
920
920
|
# store original timeout value
|
921
|
-
original_timeout_value =
|
921
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
922
922
|
|
923
923
|
# set the testobject timeout to 0 for the duration of the verify call
|
924
|
-
|
924
|
+
TDriver::TestObjectFactory.timeout = 0
|
925
925
|
|
926
926
|
# result container
|
927
927
|
result = nil
|
@@ -991,7 +991,7 @@ module TDriverVerify
|
|
991
991
|
ensure
|
992
992
|
|
993
993
|
# restore original test object factory timeout value
|
994
|
-
|
994
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
995
995
|
|
996
996
|
# restore logger state
|
997
997
|
$logger.enabled = logging_enabled
|
@@ -1023,7 +1023,7 @@ module TDriverVerify
|
|
1023
1023
|
begin
|
1024
1024
|
|
1025
1025
|
# store original timeout value
|
1026
|
-
original_timeout_value =
|
1026
|
+
original_timeout_value = TDriver::TestObjectFactory.timeout
|
1027
1027
|
|
1028
1028
|
# determine name of caller method
|
1029
1029
|
verify_caller = caller( 1 ).first.to_s
|
@@ -1062,7 +1062,7 @@ module TDriverVerify
|
|
1062
1062
|
message = "#{ message.inspect } " if message.length > 0
|
1063
1063
|
|
1064
1064
|
# set the testobject timeout to 0 for the duration of the verify call
|
1065
|
-
|
1065
|
+
TDriver::TestObjectFactory.timeout = 0
|
1066
1066
|
|
1067
1067
|
# result container
|
1068
1068
|
result = nil
|
@@ -1132,7 +1132,7 @@ module TDriverVerify
|
|
1132
1132
|
ensure
|
1133
1133
|
|
1134
1134
|
# restore original test object factory timeout value
|
1135
|
-
|
1135
|
+
TDriver::TestObjectFactory.timeout = original_timeout_value
|
1136
1136
|
|
1137
1137
|
# restore logger state
|
1138
1138
|
$logger.enabled = logging_enabled
|
@@ -1263,7 +1263,7 @@ module TDriverVerify
|
|
1263
1263
|
if self.kind_of? MobyBase::SUT
|
1264
1264
|
counter = self.dump_count
|
1265
1265
|
else
|
1266
|
-
|
1266
|
+
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
|
1267
1267
|
counter += sut_attributes[:sut].dump_count
|
1268
1268
|
end
|
1269
1269
|
end
|
@@ -1284,7 +1284,7 @@ module TDriverVerify
|
|
1284
1284
|
end
|
1285
1285
|
else
|
1286
1286
|
#refresh all connected suts
|
1287
|
-
|
1287
|
+
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
|
1288
1288
|
begin
|
1289
1289
|
appid = sut_attributes[:sut].get_application_id
|
1290
1290
|
rescue
|
data/lib/tdriver/version.rb
CHANGED
data/xml/behaviours/generic.xml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testability-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Testability Driver team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin/
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-14 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -103,7 +103,6 @@ files:
|
|
103
103
|
- lib/tdriver/base/test_object/loader.rb
|
104
104
|
- lib/tdriver/base/test_object/adapter.rb
|
105
105
|
- lib/tdriver/verify/verify.rb
|
106
|
-
- lib/tdriver/verify/verify.rb_org
|
107
106
|
- lib/tdriver/report/report_graph_generator.rb
|
108
107
|
- lib/tdriver/report/report.rb
|
109
108
|
- lib/tdriver/report/report_file_capture.rb
|
@@ -1,630 +0,0 @@
|
|
1
|
-
|
2
|
-
module TDriverVerify
|
3
|
-
|
4
|
-
# Verifies that the block given to this method evaluates without throwing any exceptions. Verification is synchronized with all connected suts.
|
5
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
6
|
-
#
|
7
|
-
# === params
|
8
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
9
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
10
|
-
# === returns
|
11
|
-
# nil
|
12
|
-
# === raises
|
13
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
14
|
-
# VerificationError:: The verification failed.
|
15
|
-
def verify( timeout = nil, message = nil, &block )
|
16
|
-
|
17
|
-
logging_enabled = MobyUtil::Logger.instance.enabled
|
18
|
-
verify_caller = caller(1).first.to_s
|
19
|
-
begin
|
20
|
-
|
21
|
-
MobyUtil::Logger.instance.enabled = false
|
22
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
23
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
24
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
25
|
-
|
26
|
-
# Set the object creation timeout temporarily to the verification timeout if it is larger
|
27
|
-
original_sync_timeout = nil
|
28
|
-
if !timeout.nil? and (timeout.to_i < MobyBase::TestObjectFactory.instance.timeout)
|
29
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
30
|
-
MobyBase::TestObjectFactory.instance.timeout=(timeout.to_i)
|
31
|
-
end
|
32
|
-
|
33
|
-
timeout_time = Time.new + (timeout.nil? ? 0 : timeout.to_i)
|
34
|
-
timeout_cycle_seconds = 0.5
|
35
|
-
|
36
|
-
loop do
|
37
|
-
|
38
|
-
begin # catch errors thrown in the provided block
|
39
|
-
|
40
|
-
yield
|
41
|
-
# no error => verification ok
|
42
|
-
break
|
43
|
-
|
44
|
-
rescue Exception => e
|
45
|
-
|
46
|
-
source_contents = ""
|
47
|
-
error_msg = ""
|
48
|
-
if Time.new > timeout_time
|
49
|
-
|
50
|
-
error_msg = "Verification at #{verify_caller} failed\n"
|
51
|
-
|
52
|
-
begin
|
53
|
-
source_contents = find_source(verify_caller)
|
54
|
-
rescue Exception
|
55
|
-
# failed to load line from file, do nothing
|
56
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
57
|
-
MobyUtil::Logger.instance.log "behaviour" , "WARNING;Failed to load source line: #{e.backtrace.inspect}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
58
|
-
end
|
59
|
-
|
60
|
-
if !source_contents.empty?
|
61
|
-
error_msg << source_contents
|
62
|
-
end
|
63
|
-
error_msg << "\nNested exception:" << e.message << "\n"
|
64
|
-
Kernel::raise MobyBase::VerificationError.new(error_msg)
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
sleep timeout_cycle_seconds
|
71
|
-
|
72
|
-
if self.kind_of? MobyBase::SUT
|
73
|
-
self.refresh
|
74
|
-
else
|
75
|
-
#refresh all connected suts
|
76
|
-
MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
|
77
|
-
sut_attributes[:sut].refresh if sut_attributes[:is_connected]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
end # do
|
83
|
-
|
84
|
-
rescue Exception => e
|
85
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
86
|
-
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed: #{e.to_s}#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
87
|
-
Kernel::raise e
|
88
|
-
ensure
|
89
|
-
MobyBase::TestObjectFactory.instance.timeout=(original_sync_timeout) unless original_sync_timeout.nil?
|
90
|
-
end
|
91
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
92
|
-
MobyUtil::Logger.instance.log "behaviour" , "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
93
|
-
return nil
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
# Verifies that the block given to this method throws an exception while being evaluated. Verification is synchronized with all connected suts.
|
98
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
99
|
-
#
|
100
|
-
# === params
|
101
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
102
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
103
|
-
# === returns
|
104
|
-
# nil
|
105
|
-
# === raises
|
106
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
107
|
-
# VerificationError:: The verification failed.
|
108
|
-
def verify_not( timeout = nil, message = nil, &block )
|
109
|
-
|
110
|
-
logging_enabled = MobyUtil::Logger.instance.enabled
|
111
|
-
verify_caller = caller(1).first.to_s
|
112
|
-
|
113
|
-
begin
|
114
|
-
|
115
|
-
MobyUtil::Logger.instance.enabled = false
|
116
|
-
|
117
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
118
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?( Integer )
|
119
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?( String )
|
120
|
-
|
121
|
-
# Set the object creation timeout temporarily to the verification timeout if it is larger
|
122
|
-
original_sync_timeout = nil
|
123
|
-
|
124
|
-
if !timeout.nil? and ( timeout.to_i < MobyBase::TestObjectFactory.instance.timeout )
|
125
|
-
|
126
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
127
|
-
MobyBase::TestObjectFactory.instance.timeout=(timeout.to_i)
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
timeout_time = Time.new + (timeout.nil? ? 0 : timeout.to_i)
|
132
|
-
timeout_cycle_seconds = 0.5
|
133
|
-
|
134
|
-
loop do
|
135
|
-
|
136
|
-
artificial_exception_raised = false
|
137
|
-
|
138
|
-
begin # catch errors thrown in the provided block
|
139
|
-
|
140
|
-
yield
|
141
|
-
artificial_exception_raised = true
|
142
|
-
Kernel::raise "test"
|
143
|
-
|
144
|
-
rescue Exception => e
|
145
|
-
|
146
|
-
source_contents = ""
|
147
|
-
error_msg = ""
|
148
|
-
|
149
|
-
# an error was encountered => verification ok
|
150
|
-
break unless artificial_exception_raised
|
151
|
-
|
152
|
-
if Time.new > timeout_time
|
153
|
-
error_msg = "Verification at #{ verify_caller } failed\n"
|
154
|
-
source_contents = find_source( verify_caller )
|
155
|
-
error_msg << source_contents if !source_contents.empty?
|
156
|
-
Kernel::raise MobyBase::VerificationError.new( error_msg )
|
157
|
-
end
|
158
|
-
|
159
|
-
sleep timeout_cycle_seconds
|
160
|
-
|
161
|
-
if self.kind_of? MobyBase::SUT
|
162
|
-
|
163
|
-
self.refresh
|
164
|
-
|
165
|
-
else
|
166
|
-
|
167
|
-
#refresh all connected suts
|
168
|
-
MobyBase::SUTFactory.instance.connected_suts.each do | sut_id, sut_attributes |
|
169
|
-
sut_attributes[:sut].refresh if sut_attributes[ :is_connected ]
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
end # do
|
177
|
-
|
178
|
-
rescue Exception => e
|
179
|
-
|
180
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
181
|
-
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed: #{e.to_s}#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_not;"
|
182
|
-
Kernel::raise e
|
183
|
-
ensure
|
184
|
-
MobyBase::TestObjectFactory.instance.timeout=(original_sync_timeout) unless original_sync_timeout.nil?
|
185
|
-
end
|
186
|
-
|
187
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
188
|
-
MobyUtil::Logger.instance.log "behaviour" , "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_not;"
|
189
|
-
return nil
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
# Verifies that the block given to this method evaluates to true. Verification is synchronized with all connected suts.
|
194
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
195
|
-
#
|
196
|
-
# === params
|
197
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
198
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
199
|
-
# === returns
|
200
|
-
# nil
|
201
|
-
# === raises
|
202
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
203
|
-
# VerificationError:: The verification failed.
|
204
|
-
# RuntimeError:: An unexpected error was encountered during verification.
|
205
|
-
def verify_true( timeout = nil, message = nil, &block )
|
206
|
-
|
207
|
-
logging_enabled = MobyUtil::Logger.instance.enabled
|
208
|
-
|
209
|
-
verify_caller = caller(1).first.to_s
|
210
|
-
|
211
|
-
begin
|
212
|
-
|
213
|
-
MobyUtil::Logger.instance.enabled = false
|
214
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
215
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
216
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
217
|
-
|
218
|
-
# Set the object creation timeout temporarily to the verification timeout if it is larger
|
219
|
-
original_sync_timeout = nil
|
220
|
-
|
221
|
-
if !timeout.nil? and (timeout.to_i < MobyBase::TestObjectFactory.instance.timeout)
|
222
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
223
|
-
MobyBase::TestObjectFactory.instance.timeout=(timeout.to_i)
|
224
|
-
end
|
225
|
-
|
226
|
-
timeout_time = Time.new + (timeout.nil? ? 0 : timeout.to_i)
|
227
|
-
timeout_cycle_seconds = 0.5
|
228
|
-
|
229
|
-
loop do
|
230
|
-
|
231
|
-
begin # catch errors thrown due to verification results
|
232
|
-
|
233
|
-
|
234
|
-
begin # catch errors thrown in the provided block
|
235
|
-
result = yield
|
236
|
-
rescue Exception => e
|
237
|
-
error_msg = "Verification at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
238
|
-
error_msg << find_source(verify_caller)
|
239
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
240
|
-
error_msg << "\n" << e.inspect
|
241
|
-
raise MobyBase::VerificationError.new(error_msg)
|
242
|
-
end
|
243
|
-
|
244
|
-
error_msg = "Verification at #{verify_caller} failed."
|
245
|
-
error_msg << find_source(verify_caller)
|
246
|
-
error_msg << "\nThe block did not return true. It returned: " << result.inspect
|
247
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
248
|
-
raise MobyBase::VerificationError.new(error_msg) unless result == true
|
249
|
-
|
250
|
-
# break loop if no exceptions thrown
|
251
|
-
break
|
252
|
-
|
253
|
-
rescue MobyBase::VerificationError => ve
|
254
|
-
|
255
|
-
# refresh and retry unless timeout reached
|
256
|
-
|
257
|
-
if Time.new > timeout_time
|
258
|
-
Kernel::raise ve
|
259
|
-
end
|
260
|
-
|
261
|
-
sleep timeout_cycle_seconds
|
262
|
-
|
263
|
-
if self.kind_of? MobyBase::SUT
|
264
|
-
self.refresh
|
265
|
-
else
|
266
|
-
|
267
|
-
#refresh all connected suts
|
268
|
-
MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
|
269
|
-
sut_attributes[:sut].refresh if sut_attributes[:is_connected]
|
270
|
-
end
|
271
|
-
|
272
|
-
end
|
273
|
-
|
274
|
-
rescue Exception => e
|
275
|
-
|
276
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
277
|
-
# an unexpected error has occurred
|
278
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
279
|
-
|
280
|
-
end # begin, catch any VerificationErrors
|
281
|
-
|
282
|
-
end # do
|
283
|
-
|
284
|
-
rescue Exception => e
|
285
|
-
|
286
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
287
|
-
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed:#{e.to_s}.\n#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_true;"
|
288
|
-
Kernel::raise e
|
289
|
-
|
290
|
-
ensure
|
291
|
-
|
292
|
-
MobyBase::TestObjectFactory.instance.timeout=(original_sync_timeout) unless original_sync_timeout.nil?
|
293
|
-
end
|
294
|
-
|
295
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
296
|
-
MobyUtil::Logger.instance.log "behaviour" , "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_true;"
|
297
|
-
|
298
|
-
nil
|
299
|
-
|
300
|
-
end
|
301
|
-
|
302
|
-
# Verifies that the block given to this method evaluates to false. Verification is synchronized with all connected suts.
|
303
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
304
|
-
#
|
305
|
-
# === params
|
306
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
307
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
308
|
-
# === returns
|
309
|
-
# nil
|
310
|
-
# === raises
|
311
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
312
|
-
# VerificationError:: The verification failed.
|
313
|
-
# RuntimeError:: An unexpected error was encountered during verification.
|
314
|
-
def verify_false( timeout = nil, message = nil, &block )
|
315
|
-
|
316
|
-
logging_enabled = MobyUtil::Logger.instance.enabled
|
317
|
-
verify_caller = caller(1).first.to_s
|
318
|
-
|
319
|
-
begin
|
320
|
-
MobyUtil::Logger.instance.enabled = false
|
321
|
-
|
322
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
323
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
324
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
325
|
-
|
326
|
-
# Set the object creation timeout temporarily to the verification timeout if it is larger
|
327
|
-
original_sync_timeout = nil
|
328
|
-
|
329
|
-
if !timeout.nil? and (timeout.to_i < MobyBase::TestObjectFactory.instance.timeout)
|
330
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
331
|
-
MobyBase::TestObjectFactory.instance.timeout=(timeout.to_i)
|
332
|
-
end
|
333
|
-
|
334
|
-
timeout_time = Time.new + ( timeout.nil? ? 0 : timeout.to_i )
|
335
|
-
timeout_cycle_seconds = 0.5
|
336
|
-
|
337
|
-
loop do
|
338
|
-
|
339
|
-
begin # catch errors thrown due to verification results
|
340
|
-
|
341
|
-
begin # catch errors thrown in the provided block
|
342
|
-
result = yield
|
343
|
-
rescue Exception => e
|
344
|
-
error_msg = "Verification at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
345
|
-
error_msg << find_source(verify_caller)
|
346
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
347
|
-
error_msg << "\n" << e.inspect
|
348
|
-
raise MobyBase::VerificationError.new(error_msg)
|
349
|
-
end
|
350
|
-
|
351
|
-
error_msg = "Verification at #{verify_caller} failed:"
|
352
|
-
error_msg << find_source(verify_caller)
|
353
|
-
error_msg << "The block did not return false. It returned: " << result.inspect
|
354
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
355
|
-
raise MobyBase::VerificationError.new(error_msg) unless result == false
|
356
|
-
|
357
|
-
# break loop if no exceptions thrown
|
358
|
-
break
|
359
|
-
|
360
|
-
rescue MobyBase::VerificationError => ve
|
361
|
-
|
362
|
-
# refresh and retry unless timeout reached
|
363
|
-
|
364
|
-
if Time.new > timeout_time
|
365
|
-
Kernel::raise ve
|
366
|
-
end
|
367
|
-
|
368
|
-
sleep timeout_cycle_seconds
|
369
|
-
|
370
|
-
if self.kind_of? MobyBase::SUT
|
371
|
-
self.refresh
|
372
|
-
else
|
373
|
-
|
374
|
-
#refresh all connected suts
|
375
|
-
MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
|
376
|
-
sut_attributes[:sut].refresh if sut_attributes[:is_connected]
|
377
|
-
end
|
378
|
-
|
379
|
-
end
|
380
|
-
|
381
|
-
rescue Exception => e
|
382
|
-
|
383
|
-
# an unexpected error has occurred
|
384
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
385
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
386
|
-
|
387
|
-
end # begin, catch any VerificationErrors
|
388
|
-
|
389
|
-
end # do
|
390
|
-
|
391
|
-
rescue Exception => e
|
392
|
-
|
393
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
394
|
-
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed:#{e.to_s}.\n #{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_false;"
|
395
|
-
Kernel::raise e
|
396
|
-
|
397
|
-
ensure
|
398
|
-
|
399
|
-
MobyBase::TestObjectFactory.instance.timeout=(original_sync_timeout) unless original_sync_timeout.nil?
|
400
|
-
|
401
|
-
end
|
402
|
-
|
403
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
404
|
-
MobyUtil::Logger.instance.log "behaviour" , "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_false;"
|
405
|
-
nil
|
406
|
-
|
407
|
-
end
|
408
|
-
|
409
|
-
# Verifies that the block given to this method evaluates to the expected value. Verification is synchronized with all connected suts.
|
410
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
411
|
-
#
|
412
|
-
# === params
|
413
|
-
# expected:: Expected result value of the block
|
414
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
415
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
416
|
-
# === returns
|
417
|
-
# nil
|
418
|
-
# === raises
|
419
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
420
|
-
# VerificationError:: The verification failed.
|
421
|
-
# RuntimeError:: An unexpected error was encountered during verification.
|
422
|
-
def verify_equal( expected, timeout = nil, message = nil, &block )
|
423
|
-
|
424
|
-
logging_enabled = MobyUtil::Logger.instance.enabled
|
425
|
-
verify_caller = caller(1).first.to_s
|
426
|
-
|
427
|
-
begin
|
428
|
-
|
429
|
-
MobyUtil::Logger.instance.enabled = false
|
430
|
-
|
431
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
432
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
433
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
434
|
-
|
435
|
-
# Set the object creation timeout temporarily to the verification timeout if it is larger
|
436
|
-
original_sync_timeout = nil
|
437
|
-
|
438
|
-
if !timeout.nil? and (timeout.to_i < MobyBase::TestObjectFactory.instance.timeout)
|
439
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
440
|
-
MobyBase::TestObjectFactory.instance.timeout=(timeout.to_i)
|
441
|
-
end
|
442
|
-
|
443
|
-
timeout_time = Time.new + (timeout.nil? ? 0 : timeout.to_i)
|
444
|
-
timeout_cycle_seconds = 0.5
|
445
|
-
|
446
|
-
loop do
|
447
|
-
|
448
|
-
begin # catch errors thrown due to verification results
|
449
|
-
|
450
|
-
begin # catch errors thrown in the provided block
|
451
|
-
result = yield
|
452
|
-
rescue Exception => e
|
453
|
-
error_msg = "Verification at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
454
|
-
error_msg << find_source(verify_caller)
|
455
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
456
|
-
error_msg << "\n" << e.inspect
|
457
|
-
raise MobyBase::VerificationError.new(error_msg)
|
458
|
-
end
|
459
|
-
|
460
|
-
error_msg = "Verification at #{verify_caller} failed:"
|
461
|
-
error_msg << find_source(verify_caller)
|
462
|
-
error_msg << "The block did not return #{expected.inspect}. It returned: " << result.inspect
|
463
|
-
error_msg << "\nDetails: " << message unless message.nil?
|
464
|
-
raise MobyBase::VerificationError.new(error_msg) unless result == expected
|
465
|
-
|
466
|
-
# break loop if no exceptions thrown
|
467
|
-
break
|
468
|
-
|
469
|
-
rescue MobyBase::VerificationError => ve
|
470
|
-
|
471
|
-
# refresh and retry unless timeout reached
|
472
|
-
|
473
|
-
if Time.new > timeout_time
|
474
|
-
Kernel::raise ve
|
475
|
-
end
|
476
|
-
|
477
|
-
sleep timeout_cycle_seconds
|
478
|
-
|
479
|
-
if self.kind_of? MobyBase::SUT
|
480
|
-
|
481
|
-
self.refresh
|
482
|
-
|
483
|
-
else
|
484
|
-
|
485
|
-
#refresh all connected suts
|
486
|
-
MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
|
487
|
-
sut_attributes[:sut].refresh if sut_attributes[:is_connected]
|
488
|
-
end
|
489
|
-
|
490
|
-
end
|
491
|
-
|
492
|
-
rescue Exception => e
|
493
|
-
|
494
|
-
# an unexpected error has occurred
|
495
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
496
|
-
|
497
|
-
end # begin, catch any VerificationErrors
|
498
|
-
|
499
|
-
end # do
|
500
|
-
|
501
|
-
rescue Exception => e
|
502
|
-
|
503
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
504
|
-
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed:#{e.to_s}.\n#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_equal;" << expected.to_s
|
505
|
-
Kernel::raise e
|
506
|
-
ensure
|
507
|
-
MobyBase::TestObjectFactory.instance.timeout=(original_sync_timeout) unless original_sync_timeout.nil?
|
508
|
-
end
|
509
|
-
|
510
|
-
MobyUtil::Logger.instance.enabled = logging_enabled
|
511
|
-
MobyUtil::Logger.instance.log "behaviour" , "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_equal;" << expected.to_s
|
512
|
-
|
513
|
-
nil
|
514
|
-
|
515
|
-
end
|
516
|
-
|
517
|
-
|
518
|
-
private
|
519
|
-
|
520
|
-
# Searches for the given source file for a line
|
521
|
-
#
|
522
|
-
# === params
|
523
|
-
# from_file:: String defining the file to load. If at_line is nil, this argument can also contain a path and line number separated by : (eg. some_dir/some_file.rb:123).
|
524
|
-
# at_line:: (optional) Integer, number of the line (first line is 1).
|
525
|
-
# === returns
|
526
|
-
# String:: Contents of the line
|
527
|
-
# === throws
|
528
|
-
# RuntimeError:: from_file is not correctly formed, the file cannot be loaded or the line cannot be found.
|
529
|
-
def find_source(backtrace)
|
530
|
-
|
531
|
-
ret_str = "\n"
|
532
|
-
|
533
|
-
begin
|
534
|
-
|
535
|
-
call_stack = backtrace.to_s.split(':')
|
536
|
-
#puts "call_stack:" << backtrace.to_s
|
537
|
-
|
538
|
-
line_number = 0
|
539
|
-
if (call_stack.size() == 2)
|
540
|
-
line_number = call_stack[1].to_i
|
541
|
-
|
542
|
-
else
|
543
|
-
line_number = call_stack[call_stack.size()-2].to_i
|
544
|
-
end
|
545
|
-
#puts "line number: " << line_number.to_s
|
546
|
-
|
547
|
-
file_path = ""
|
548
|
-
if (call_stack.size() == 2)
|
549
|
-
file_path = call_stack[0]
|
550
|
-
else
|
551
|
-
(call_stack.size()-2).times do |index|
|
552
|
-
file_path << call_stack[index].to_s << ":"
|
553
|
-
end
|
554
|
-
file_path.slice!(file_path.size()-1) # remove the trailing colon
|
555
|
-
end
|
556
|
-
#puts "file path: " << file_path.to_s
|
557
|
-
|
558
|
-
lines_to_read = line_number >= 2 ? 3 : line_number
|
559
|
-
#puts "lines to read: " << lines_to_read.to_s
|
560
|
-
|
561
|
-
start_line = line_number #- (lines_to_read <= 1 ? 0 : 1)
|
562
|
-
#puts "start line:" << start_line.to_s
|
563
|
-
|
564
|
-
File.open(File.expand_path(file_path.to_s), "r") { |source|
|
565
|
-
|
566
|
-
lines = source.readlines
|
567
|
-
Kernel::raise RuntimeError.new("Only \"#{lines.size.to_s}\" lines exist in the source file.")if start_line >= lines.size
|
568
|
-
|
569
|
-
lines_to_read = (lines.size - start_line + 1) < 3 ? (lines.size - start_line + 1) : lines_to_read
|
570
|
-
|
571
|
-
# the array is zero based, first line is at position 0
|
572
|
-
lines_to_read.times do |index|
|
573
|
-
if (line_number == (start_line + index))
|
574
|
-
ret_str << "=> "
|
575
|
-
else
|
576
|
-
ret_str << " "
|
577
|
-
end
|
578
|
-
ret_str << lines[start_line + index - 1]
|
579
|
-
end
|
580
|
-
|
581
|
-
}
|
582
|
-
|
583
|
-
rescue Exception => e
|
584
|
-
|
585
|
-
#puts "exception:" << e.inspect
|
586
|
-
ret_str << "Unable to load source lines.\n" << e.inspect
|
587
|
-
|
588
|
-
end
|
589
|
-
|
590
|
-
return ret_str
|
591
|
-
|
592
|
-
end
|
593
|
-
|
594
|
-
# Searches the backtrace line that is next from verify itself
|
595
|
-
#
|
596
|
-
# === params
|
597
|
-
# backtrace:: Array, exception backtrace
|
598
|
-
# === returns
|
599
|
-
# Integer:: Index of bactrace item
|
600
|
-
# === throws
|
601
|
-
# RuntimeError:: backtrace is nil or empty or correct line not found.
|
602
|
-
def find_line(backtrace)
|
603
|
-
|
604
|
-
Kernel::raise RuntimeError.new("Backtrace was nil") if backtrace.nil?
|
605
|
-
Kernel::raise RuntimeError.new("Backtrace is empty") if backtrace.size <= 0
|
606
|
-
|
607
|
-
moby_found = false
|
608
|
-
|
609
|
-
backtrace.size.times do |index|
|
610
|
-
if (backtrace[index].include?("/util/lib/verify.rb:"))
|
611
|
-
moby_found = true
|
612
|
-
else
|
613
|
-
if (moby_found)
|
614
|
-
return index
|
615
|
-
end
|
616
|
-
end
|
617
|
-
end
|
618
|
-
Kernel::raise RuntimeError.new("Correct line not found from backtrace.")
|
619
|
-
end
|
620
|
-
|
621
|
-
def parse_caller(at)
|
622
|
-
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
|
623
|
-
file = Regexp.last_match[1]
|
624
|
-
line = Regexp.last_match[2].to_i
|
625
|
-
method = Regexp.last_match[3]
|
626
|
-
[file, line, method]
|
627
|
-
end
|
628
|
-
end
|
629
|
-
|
630
|
-
end
|