testability-driver-runner 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sierra +19 -0
- data/bin/tdrunner +17 -0
- data/lib/tdrunner.rb +208 -0
- data/lib/tdrunner.yml +1 -0
- data/lib/tdrunner_cucumber.rb +222 -0
- data/lib/tdrunner_cucumber_runners.rb +35 -0
- data/lib/tdrunner_file_finder.rb +45 -0
- data/lib/tdrunner_monitor.rb +473 -0
- data/lib/tdrunner_profile.rb +416 -0
- data/lib/tdrunner_test_unit.rb +433 -0
- data/rakefile +135 -0
- data/readme +186 -0
- data/websi/README +243 -0
- data/websi/Rakefile +10 -0
- data/websi/app/controllers/application_controller.rb +29 -0
- data/websi/app/controllers/report_editor/test_run/cases_controller.rb +307 -0
- data/websi/app/controllers/report_editor_controller.rb +25 -0
- data/websi/app/controllers/websi_controller.rb +478 -0
- data/websi/app/controllers/websi_script.rb +26 -0
- data/websi/app/controllers/websi_support.rb +142 -0
- data/websi/app/helpers/application_helper.rb +22 -0
- data/websi/app/helpers/report_editor/report_editor_helper.rb +26 -0
- data/websi/app/helpers/report_editor/test_run/cases_helper.rb +26 -0
- data/websi/app/helpers/websi_helper.rb +21 -0
- data/websi/app/views/layouts/application.rhtml +17 -0
- data/websi/app/views/websi/execution.html.erb +28 -0
- data/websi/app/views/websi/index.html.erb +23 -0
- data/websi/app/views/websi/profile.html.erb +30 -0
- data/websi/app/views/websi/results.html.erb +30 -0
- data/websi/app/views/websi/tests.html.erb +23 -0
- data/websi/app/views/websi/weights.html.erb +16 -0
- data/websi/config/boot.rb +129 -0
- data/websi/config/database.yml +22 -0
- data/websi/config/environment.rb +60 -0
- data/websi/config/environments/development.rb +36 -0
- data/websi/config/environments/production.rb +47 -0
- data/websi/config/environments/test.rb +47 -0
- data/websi/config/initializers/backtrace_silencers.rb +26 -0
- data/websi/config/initializers/inflections.rb +29 -0
- data/websi/config/initializers/mime_types.rb +24 -0
- data/websi/config/initializers/new_rails_defaults.rb +40 -0
- data/websi/config/initializers/session_store.rb +34 -0
- data/websi/config/locales/en.yml +5 -0
- data/websi/config/routes.rb +62 -0
- data/websi/db/development.sqlite3 +0 -0
- data/websi/db/seeds.rb +26 -0
- data/websi/doc/README_FOR_APP +2 -0
- data/websi/log/development.log +0 -0
- data/websi/log/production.log +0 -0
- data/websi/log/server.log +0 -0
- data/websi/log/test.log +0 -0
- data/websi/public/report_editor/test_run/_index.html +12 -0
- data/websi/public/robots.txt +5 -0
- data/websi/public/stylesheets/tdriver_report_style.css +220 -0
- data/websi/public/tests/config/web_profile.sip +0 -0
- data/websi/public/tests/example_profile.sip +8 -0
- data/websi/public/tests/tdrunner.yml +3 -0
- data/websi/public/tests/web_profile.sip +8 -0
- data/websi/public/tests/websi_parameters.xml +4 -0
- data/websi/script/about +4 -0
- data/websi/script/console +3 -0
- data/websi/script/dbconsole +3 -0
- data/websi/script/destroy +3 -0
- data/websi/script/generate +3 -0
- data/websi/script/performance/benchmarker +3 -0
- data/websi/script/performance/profiler +3 -0
- data/websi/script/plugin +3 -0
- data/websi/script/runner +3 -0
- data/websi/script/server +3 -0
- data/websi/test/functional/websi_controller_test.rb +27 -0
- data/websi/test/performance/browsing_test.rb +28 -0
- data/websi/test/test_helper.rb +57 -0
- data/websi/test/unit/helpers/websi_helper_test.rb +23 -0
- metadata +199 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
|
21
|
+
module TDRunner
|
22
|
+
module TDRunnerCucumber
|
23
|
+
module TDRunnerCucumberRunners
|
24
|
+
def tdrunner_loaded_features()
|
25
|
+
$tdrunner_loaded_features
|
26
|
+
end
|
27
|
+
def set_tdrunner_loaded_features(feature_folder,cucumber_runner)
|
28
|
+
if $tdrunner_loaded_features==nil
|
29
|
+
$tdrunner_loaded_features=[['.'],['.']]
|
30
|
+
end
|
31
|
+
$tdrunner_loaded_features << [[feature_folder],[cucumber_runner]]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
|
21
|
+
class TDRunnerFileFinder
|
22
|
+
def initialize(find_file_extension)
|
23
|
+
@exclude_folders_pattern = [ '.*', '_*' ]
|
24
|
+
@include_files_pattern = [ "*/*.#{find_file_extension}" ]
|
25
|
+
end
|
26
|
+
def file_pattern_matches?( patterns, filepath )
|
27
|
+
patterns.each{ | pattern | return true if File.fnmatch( pattern, filepath ) }; false
|
28
|
+
end
|
29
|
+
def get_files( folder, files_list = [] )
|
30
|
+
if File.directory?( folder )
|
31
|
+
folder = File.expand_path( folder )
|
32
|
+
Dir.open( folder ).each { | entry |
|
33
|
+
# create full filepath
|
34
|
+
filepath = "#{ folder }/#{ entry }"
|
35
|
+
# file: add file to required files list
|
36
|
+
files_list.push( filepath ) if file_pattern_matches?( @include_files_pattern, filepath )
|
37
|
+
# directory: go deeper in folder stack structure if exclusion pattern does not meet
|
38
|
+
files_list |= get_files("#{ filepath }/") if File.directory?( filepath ) and not file_pattern_matches?( @exclude_folders_pattern, entry )
|
39
|
+
}
|
40
|
+
files_list
|
41
|
+
else
|
42
|
+
folder
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,473 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
require 'yaml'
|
20
|
+
|
21
|
+
module TDRunner
|
22
|
+
#TDRunner monitor module for controlling the SIERRA execution
|
23
|
+
module TDRunnerMonitor
|
24
|
+
|
25
|
+
def add_failed_testunit_tests(tdrunner_parameters,case_contents_array,index)
|
26
|
+
if(tdrunner_parameters.failed_execution_profile != nil)
|
27
|
+
failed_case = case_contents_array[index].at(0).to_s
|
28
|
+
if tdrunner_parameters.tdrunner_ordered==false
|
29
|
+
#i.e. no dependencies
|
30
|
+
add_tc_to_failed_array(tdrunner_parameters,failed_case)
|
31
|
+
else
|
32
|
+
add_dependent_tcs_to_failed_array(tdrunner_parameters,case_contents_array,index)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_dependent_tcs_to_failed_array(tdrunner_parameters,case_contents_array,index)
|
38
|
+
temp_array=Array.new
|
39
|
+
|
40
|
+
failed_case = case_contents_array[index].at(0).to_s
|
41
|
+
pos = case_contents_array[index].at(2).count( "-").to_i
|
42
|
+
temp_array<<get_pos_string(pos) + get_test_name(failed_case)+ "(" + get_test_class(failed_case) + ")=1"
|
43
|
+
i = index.to_i - 1
|
44
|
+
|
45
|
+
while( i>0 || i==0 )
|
46
|
+
prev_pos = case_contents_array[i].at(2).count( "-").to_i
|
47
|
+
prev_failed_case = case_contents_array[i].at(0).to_s
|
48
|
+
|
49
|
+
if (pos>prev_pos && prev_pos!=0 )
|
50
|
+
temp_array<<get_pos_string(prev_pos) + get_test_name(prev_failed_case)+ "(" + get_test_class(prev_failed_case) + ")=1"
|
51
|
+
end
|
52
|
+
|
53
|
+
if(prev_pos==0)
|
54
|
+
temp_array<<get_pos_string(prev_pos) + get_test_name(prev_failed_case)+ "(" + get_test_class(prev_failed_case) + ")=1"
|
55
|
+
break
|
56
|
+
end
|
57
|
+
i=i-1
|
58
|
+
end
|
59
|
+
|
60
|
+
$failed_tests ||= Array.new
|
61
|
+
if !$failed_tests.include? temp_array.reverse!
|
62
|
+
class_name = get_test_class(failed_case) + "=1"
|
63
|
+
$failed_tests <<class_name if !value_exists_in_array($failed_tests , class_name)
|
64
|
+
$failed_tests<<temp_array
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_tc_to_failed_array(tdrunner_parameters,testcase)
|
69
|
+
$failed_tests ||= Array.new
|
70
|
+
tc_class=get_test_class(testcase)
|
71
|
+
tc_name=get_test_name(testcase)
|
72
|
+
class_name = tc_class + "=1"
|
73
|
+
tc_name = tc_name+ "(" + tc_class + ")=1"
|
74
|
+
|
75
|
+
if !$failed_tests.include? tc_name
|
76
|
+
$failed_tests <<class_name if !$failed_tests.include? class_name
|
77
|
+
$failed_tests << tc_name
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_pos_string(pos)
|
82
|
+
pos_str=""
|
83
|
+
if(pos>0)
|
84
|
+
pos_str=Array.new(pos, "-").join.to_s
|
85
|
+
end
|
86
|
+
return pos_str
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_test_name(testcase_name)
|
90
|
+
name=testcase_name.gsub(/[)]/,'')
|
91
|
+
name_arr=name.split('(')
|
92
|
+
return name_arr[0].to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_test_class(testcase_name)
|
96
|
+
name=testcase_name.gsub(/[)]/,'')
|
97
|
+
name_arr=name.split('(')
|
98
|
+
return name_arr[1].to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
def write_failed_sip_file(tdrunner_parameters)
|
102
|
+
if($failed_tests!=nil && tdrunner_parameters.failed_execution_profile != nil && !$failed_tests.empty?)
|
103
|
+
file = File.open(tdrunner_parameters.failed_execution_profile.to_s,'w')
|
104
|
+
$failed_tests.flatten.each { |x| file.write(x.to_s+"\n")}
|
105
|
+
file.close
|
106
|
+
puts 'Failed execution profile created: '+ tdrunner_parameters.failed_execution_profile
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def trap_pause
|
111
|
+
puts "\nExecution paused...\n"
|
112
|
+
puts "\nStop execution Yes or No?:"
|
113
|
+
response=STDIN.gets
|
114
|
+
if response.capitalize == "Yes\n" || response.capitalize == "Y\n"
|
115
|
+
$tdrunner_interrupted=true
|
116
|
+
STDERR.puts "\nFinalizing test... Please wait...\n"
|
117
|
+
STDERR.puts "\nPress ctrl+Break to interrupt immediately\n"
|
118
|
+
exit
|
119
|
+
elsif response.capitalize == "No\n" || response.capitalize == "N\n"
|
120
|
+
STDERR.puts "\nContinuing execution..."
|
121
|
+
else
|
122
|
+
STDERR.puts "\nIncorrect answer"
|
123
|
+
trap_pause
|
124
|
+
end
|
125
|
+
end
|
126
|
+
def trap_interrupt
|
127
|
+
trap('INT') do
|
128
|
+
trap_pause
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
#Method for checking how many seconds TDRunner has run
|
133
|
+
def format_execution_duration(duration_value)
|
134
|
+
secs=0
|
135
|
+
if (/^\d+:\d+$/.match(duration_value.to_s))
|
136
|
+
secs = (duration_value.split(':') [0].to_i*3600) + (duration_value.split(':') [1].to_i*60)
|
137
|
+
elsif (/^\d+\.\d+$/.match(duration_value.to_s))
|
138
|
+
secs = 3600*duration_value.to_f
|
139
|
+
else (/^\d+$/.match(duration_value.to_s))
|
140
|
+
secs=60*duration_value.to_f
|
141
|
+
end
|
142
|
+
secs
|
143
|
+
end
|
144
|
+
|
145
|
+
def exit_tdrunner_execution(message)
|
146
|
+
puts message
|
147
|
+
end
|
148
|
+
|
149
|
+
def remove_extra_ends_from_implementation(found_implementation, ends_to_remove)
|
150
|
+
removed_ends=0
|
151
|
+
current_index=found_implementation.length
|
152
|
+
found_implementation.reverse_each do |reverse_line|
|
153
|
+
current_index-=1
|
154
|
+
if removed_ends < ends_to_remove
|
155
|
+
if reverse_line.include?('end')
|
156
|
+
found_implementation.delete_at(current_index)
|
157
|
+
removed_ends+=1
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
found_implementation
|
162
|
+
end
|
163
|
+
|
164
|
+
def find_missing_method_from_ruby_file(method, loaded_test_files, method_name=nil)
|
165
|
+
found_implementation=Array.new
|
166
|
+
found_setup_implementation=Array.new
|
167
|
+
found_teardown_implementation=Array.new
|
168
|
+
|
169
|
+
loaded_test_files.each do |test_file|
|
170
|
+
if found_implementation == []
|
171
|
+
f = File.open(test_file) or die "Unable to open file..."
|
172
|
+
b_method_found=false
|
173
|
+
|
174
|
+
f.each_line do |line|
|
175
|
+
if b_method_found==true
|
176
|
+
if line.include?('def ')
|
177
|
+
b_method_found=false
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
if b_method_found==true
|
182
|
+
found_implementation << line
|
183
|
+
end
|
184
|
+
|
185
|
+
if line=~/def #{method}(.*)$/
|
186
|
+
if method_name==nil
|
187
|
+
found_implementation << line
|
188
|
+
found_setup_implementation << find_missing_method_from_ruby_file('setup',test_file,"setup_#{method}")
|
189
|
+
found_teardown_implementation << find_missing_method_from_ruby_file('teardown',test_file,"teardown_#{method}")
|
190
|
+
else
|
191
|
+
found_implementation << line.gsub(method, method_name)
|
192
|
+
end
|
193
|
+
b_method_found=true
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
if b_method_found==true
|
198
|
+
found_implementation=remove_extra_ends_from_implementation(found_implementation,1)
|
199
|
+
b_method_found=false
|
200
|
+
elsif found_implementation.length > 1 && b_method_found==false
|
201
|
+
#found_implementation=remove_extra_ends_from_implementation(found_implementation,1)
|
202
|
+
b_method_found=false
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
end
|
207
|
+
found_implementation << found_setup_implementation
|
208
|
+
found_implementation << found_teardown_implementation
|
209
|
+
found_implementation
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_missing_methods(original_test_class,missing_methods,loaded_test_files)
|
213
|
+
ObjectSpace.each_object( Class ){ | test_class |
|
214
|
+
if test_class.ancestors.include?( Test::Unit::TestCase ) && test_class != Test::Unit::TestCase
|
215
|
+
test_class.public_instance_methods( true ).sort.each{ | method |
|
216
|
+
if method =~ /^test_/
|
217
|
+
missing_methods.each do |missing_method|
|
218
|
+
if missing_method.to_s == method
|
219
|
+
method_implementation=find_missing_method_from_ruby_file(method,loaded_test_files)
|
220
|
+
original_test_class.class_eval("module TestModule_#{missing_method.to_s}
|
221
|
+
#{method_implementation.to_s}
|
222
|
+
end")
|
223
|
+
original_test_class.class_eval("include TestModule_#{missing_method.to_s}")
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
}
|
228
|
+
end
|
229
|
+
}
|
230
|
+
original_test_class
|
231
|
+
end
|
232
|
+
|
233
|
+
def get_missing_methods(test_class, case_name_array)
|
234
|
+
missing_methods_arr=Array.new
|
235
|
+
case_name_array.each do |test_case|
|
236
|
+
tc_line_arr=test_case.gsub(')','(').split('(')
|
237
|
+
if tc_line_arr.length > 1
|
238
|
+
if tc_line_arr[1].to_s==test_class.name.to_s
|
239
|
+
b_method_exists=false
|
240
|
+
test_class.public_instance_methods( true ).sort.each{ | method |
|
241
|
+
if method =~ /^test_/
|
242
|
+
if tc_line_arr[0].to_s==method.to_s
|
243
|
+
b_method_exists=true
|
244
|
+
end
|
245
|
+
end
|
246
|
+
}
|
247
|
+
if b_method_exists==false
|
248
|
+
missing_methods_arr << tc_line_arr[0].to_s
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
missing_methods_arr
|
254
|
+
end
|
255
|
+
|
256
|
+
#adds missing test methods in to the test class based on tdrunner execution profile
|
257
|
+
def add_missing_methods_in_to_test_class(test_class,tdrunner_parameters,loaded_test_files)
|
258
|
+
|
259
|
+
f = File.open(tdrunner_parameters.execution_profile) or die "Unable to open file..."
|
260
|
+
case_name_array=[]
|
261
|
+
b_profile_file_exist=false
|
262
|
+
f.each_line do |line|
|
263
|
+
case_arr=line.split('=')
|
264
|
+
if case_arr.length > 1
|
265
|
+
case_name_array << case_arr[0].gsub('-','')
|
266
|
+
b_profile_file_exist=true
|
267
|
+
end
|
268
|
+
end
|
269
|
+
if b_profile_file_exist==true
|
270
|
+
missing_methods=get_missing_methods(test_class, case_name_array)
|
271
|
+
test_class=add_missing_methods(test_class,missing_methods,loaded_test_files)
|
272
|
+
end
|
273
|
+
test_class
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
#Removes duplicates and existing randomizations if found
|
278
|
+
def flatten_tests(tests)
|
279
|
+
clean_test_arr=[]
|
280
|
+
tests.each do |test_case|
|
281
|
+
unless clean_test_arr.include? test_case
|
282
|
+
clean_test_arr.push test_case
|
283
|
+
end
|
284
|
+
end
|
285
|
+
clean_test_arr
|
286
|
+
end
|
287
|
+
|
288
|
+
def get_test_classes(tests)
|
289
|
+
test_classes=[]
|
290
|
+
tests.each do |test_case|
|
291
|
+
if test_case.to_s.include?('(')==false
|
292
|
+
test_classes.push test_case
|
293
|
+
end
|
294
|
+
end
|
295
|
+
test_classes
|
296
|
+
end
|
297
|
+
|
298
|
+
def is_class_included(case_contents_array,class_name)
|
299
|
+
b_class_added=false
|
300
|
+
case_contents_array.each do | case_content|
|
301
|
+
if case_content[0]==class_name
|
302
|
+
b_class_added=true
|
303
|
+
end
|
304
|
+
break if b_class_added==true
|
305
|
+
end
|
306
|
+
b_class_added
|
307
|
+
end
|
308
|
+
|
309
|
+
def order_the_tests(tests,case_contents_array)
|
310
|
+
ordered_tests=[]
|
311
|
+
ordered_contents=[]
|
312
|
+
tests_to_string=[]
|
313
|
+
not_found_tests=[]
|
314
|
+
tests.each do |tc|
|
315
|
+
tests_to_string << tc.to_s
|
316
|
+
end
|
317
|
+
test_classes=get_test_classes(tests)
|
318
|
+
case_contents_array.each do|tc|
|
319
|
+
if not_found_tests.include?(tc[0].to_s)==false
|
320
|
+
index=tests_to_string.index tc[0].to_s
|
321
|
+
if index!=nil
|
322
|
+
ordered_tests.push tests[index]
|
323
|
+
ordered_contents.push tc
|
324
|
+
else
|
325
|
+
tests_to_be_added=tests.find_all{|item| item.to_s % item.to_s == tc[0].to_s }
|
326
|
+
if tests_to_be_added!=[]
|
327
|
+
ordered_tests.push tests_to_be_added.first
|
328
|
+
ordered_contents.push tc
|
329
|
+
else
|
330
|
+
not_found_tests << tc[0].to_s
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
test_classes.each do |test_class|
|
336
|
+
if is_class_included(case_contents_array,test_class.to_s)==false
|
337
|
+
ordered_tests.push test_class
|
338
|
+
ordered_contents.push [test_class.to_s,nil,test_class.to_s,'not run']
|
339
|
+
end
|
340
|
+
end
|
341
|
+
return ordered_tests, ordered_contents
|
342
|
+
end
|
343
|
+
|
344
|
+
def organize_tests(tests,case_contents_array,case_name_array,tdrunner_parameters)
|
345
|
+
organized_tests=[]
|
346
|
+
test_classes=get_test_classes(tests)
|
347
|
+
tests.each do |test_case|
|
348
|
+
profile_index=case_name_array.index test_case.to_s
|
349
|
+
if profile_index == nil
|
350
|
+
File.open(tdrunner_parameters.execution_profile, 'a') { |file| file.write("\n"+test_case.to_s+"=1") } if tdrunner_parameters.execution_mode=='-m'
|
351
|
+
else
|
352
|
+
case_contents_array.each do |test|
|
353
|
+
if test_case.to_s==test[0].to_s
|
354
|
+
|
355
|
+
organized_tests.push test_case
|
356
|
+
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
test_classes.each do |test_class|
|
363
|
+
organized_tests.push test_class
|
364
|
+
end
|
365
|
+
organized_tests
|
366
|
+
end
|
367
|
+
|
368
|
+
def value_exists_in_array(current_array,value)
|
369
|
+
b_exists=false
|
370
|
+
current_array.each do |arr_value|
|
371
|
+
if arr_value.include?(value)
|
372
|
+
b_exists=true
|
373
|
+
end
|
374
|
+
end
|
375
|
+
b_exists
|
376
|
+
end
|
377
|
+
|
378
|
+
#method for randomizing the executed tests
|
379
|
+
def randomize_test_cases(tests,tdrunner_parameters)
|
380
|
+
tests=flatten_tests(tests)
|
381
|
+
if tdrunner_parameters.execution_profile!=nil
|
382
|
+
f = File.open(tdrunner_parameters.execution_profile) or die "Unable to open file..."
|
383
|
+
@case_contents_array=[] # start with an empty array
|
384
|
+
case_name_array=[]
|
385
|
+
b_profile_file_exist=false
|
386
|
+
|
387
|
+
f.each_line do |line|
|
388
|
+
case_arr=line.split('=')
|
389
|
+
if case_arr.length == 2
|
390
|
+
for i in (1..case_arr[1].to_i)
|
391
|
+
@case_contents_array << [case_arr[0].gsub('-',''),nil,case_arr[0],'not run'] #name, parameters, place in tree, test result
|
392
|
+
case_name_array << case_arr[0].gsub('-','')
|
393
|
+
end
|
394
|
+
b_profile_file_exist=true
|
395
|
+
elsif case_arr.length == 3
|
396
|
+
for i in (1..case_arr[1].to_i)
|
397
|
+
@case_contents_array << [case_arr[0].gsub('-',''),case_arr[2],case_arr[0],'not run'] #name, parameters, place in tree, test result
|
398
|
+
case_name_array << case_arr[0].gsub('-','')
|
399
|
+
end
|
400
|
+
b_profile_file_exist=true
|
401
|
+
end
|
402
|
+
end
|
403
|
+
tests=organize_tests(tests,@case_contents_array,case_name_array,tdrunner_parameters)
|
404
|
+
|
405
|
+
end
|
406
|
+
|
407
|
+
if tdrunner_parameters.tdrunner_ordered==false
|
408
|
+
if b_profile_file_exist==true
|
409
|
+
@case_contents_array=@case_contents_array.shuffle
|
410
|
+
tests,@case_contents_array=order_the_tests(tests, @case_contents_array)
|
411
|
+
end
|
412
|
+
else
|
413
|
+
if b_profile_file_exist==true
|
414
|
+
tests,@case_contents_array=order_the_tests(tests, @case_contents_array)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
return tests, @case_contents_array
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
#Method to check how long tdrunner run is active
|
422
|
+
#TDRunner mode is checked from initialized TDRunnerParameters class
|
423
|
+
def tdrunner_active(run_start_time,iteration,tdrunner_parameters)
|
424
|
+
current_run_time=Time.now-run_start_time
|
425
|
+
case tdrunner_parameters.execution_mode
|
426
|
+
when '-H'
|
427
|
+
if (current_run_time<format_execution_duration(tdrunner_parameters.duration_value))
|
428
|
+
true
|
429
|
+
else
|
430
|
+
false
|
431
|
+
end
|
432
|
+
when '-i'
|
433
|
+
if iteration<tdrunner_parameters.lpt_run
|
434
|
+
true
|
435
|
+
else
|
436
|
+
false
|
437
|
+
end
|
438
|
+
when '-d'
|
439
|
+
if Time.now<tdrunner_parameters.lpt_run
|
440
|
+
true
|
441
|
+
else
|
442
|
+
false
|
443
|
+
end
|
444
|
+
when '-m'
|
445
|
+
#exit_tdrunner_execution('Execution profile created: '+ tdrunner_parameters.execution_profile)
|
446
|
+
false
|
447
|
+
when '-e'
|
448
|
+
if iteration<tdrunner_parameters.lpt_run
|
449
|
+
true
|
450
|
+
else
|
451
|
+
false
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
|
457
|
+
#Formater for displaying the execution time
|
458
|
+
def format_duration(seconds)
|
459
|
+
m, s = seconds.divmod(60)
|
460
|
+
"#{m}m#{'%.3f' % s}s"
|
461
|
+
end
|
462
|
+
|
463
|
+
def wait_for_starttime(tdrunner_parameters)
|
464
|
+
#If the start time is defined then only start execution at this time
|
465
|
+
if tdrunner_parameters.start_time!=nil
|
466
|
+
while Time.now < tdrunner_parameters.start_time
|
467
|
+
sleep(1)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
end
|
473
|
+
end
|