Class: TDRunner::TDRunnerParameters
- Inherits:
-
Object
- Object
- TDRunner::TDRunnerParameters
- Defined in:
- lib/tdrunner_profile.rb
Overview
Calss for holding the tdrunner execution parameters
Instance Method Summary collapse
-
#check_duration(duration_value) ⇒ Object
method to check that the format of the duration value is correct - e.g.
-
#check_if_parameters_contain_a_framework_command(args) ⇒ Object
method for checking the framework command.
-
#combine_with_existing_tdriver_report(report_location) ⇒ Object
method for combining a TDriver report with the current tdrunner execution.
- #create_failed_sip(failed_sip_profile) ⇒ Object
- #duration_value ⇒ Object
- #execution_mode ⇒ Object
- #execution_profile ⇒ Object
- #failed_execution_profile ⇒ Object
-
#format_tdrunner_date(date_time) ⇒ Object
method for checking the end time for tdrunner run.
-
#initialize(args) ⇒ TDRunnerParameters
constructor
intializes tdrunner execution parameters and loads them to memory.
- #lpt_run ⇒ Object
- #make_execution_profile ⇒ Object
-
#parse_tdrunner_parameters(args) ⇒ Object
Parser method for tdrunner commandline parameters -H prameter defines the runtime -d parameter is for the end time stamp -i parameter is for the iteration number for the tests -m parameter is for creating a test set execution profile without running the tests.
-
#sip_file(tdrunner_profile, profile_folder = nil) ⇒ Object
Locates sip file.
- #start_time ⇒ Object
- #tdrunner_ordered ⇒ Object
- #tdrunner_teardown ⇒ Object
- #test_framework ⇒ Object
- #test_framework_command ⇒ Object
Constructor Details
#initialize(args) ⇒ TDRunnerParameters
intializes tdrunner execution parameters and loads them to memory
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/tdrunner_profile.rb', line 116 def initialize(args) @test_framework=nil @test_framework_command=Array.new @execution_mode='-i' @lpt_run=1 @duration_value=0 @execution_profile=nil @tdrunner_teardown=false @tdrunner_ordered=false @tdrunner_combine_report=nil @start_time=nil @failed_execution_profile=nil parse_tdrunner_parameters(args) end |
Instance Method Details
#check_duration(duration_value) ⇒ Object
method to check that the format of the duration value is correct - e.g. 4, 4.5, 4:23 are correct
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/tdrunner_profile.rb', line 137 def check_duration(duration_value) ret=false if (/^\d+$/.match(duration_value) or /^\d+.\d+$/.match(duration_value)) ret=true elsif (/^\d+:\d+$/.match(duration_value)) if(duration_value.split(':') [1].to_i)<60 ret=true end end ret end |
#check_if_parameters_contain_a_framework_command(args) ⇒ Object
method for checking the framework command
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 |
# File 'lib/tdrunner_profile.rb', line 156 def check_if_parameters_contain_a_framework_command(args) parameters_contains_framework_command=false is_directory=false args.each do |value| is_directory=File.directory?(value) if value=='test_suite' if is_directory==false parameters_contains_framework_command=true @test_framework='test_suite' end end if value=='test_unit' if is_directory==false parameters_contains_framework_command=true @test_framework='test_unit' end end if value=='cucumber' if is_directory==false parameters_contains_framework_command=true @test_framework='cucumber' end end end parameters_contains_framework_command end |
#combine_with_existing_tdriver_report(report_location) ⇒ Object
method for combining a TDriver report with the current tdrunner execution
150 151 152 153 |
# File 'lib/tdrunner_profile.rb', line 150 def combine_with_existing_tdriver_report(report_location) Kernel::raise ArgumentError.new("Report folder does not exists") if File.directory?(report_location)==false TDriverReportAPI::tdriver_report_combine_reports(report_location) end |
#create_failed_sip(failed_sip_profile) ⇒ Object
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 |
# File 'lib/tdrunner_profile.rb', line 320 def create_failed_sip(failed_sip_profile) sip_file=nil failed_sip_profile=failed_sip_profile+'.sip' if failed_sip_profile.include?('.sip')==false #check if failed_sip_profile already exists in current dir if File.file?(failed_sip_profile) sip_file = failed_sip_profile end #check if path given if sip_file==nil failed_sip_profile=failed_sip_profile.gsub(/\\/,'/') dirs = File.dirname(failed_sip_profile) if (dirs != ".") #check if the dirs exist, if not create the dirs FileUtils.mkdir_p(dirs) if !File.exist?(dirs) sip_file=failed_sip_profile else FileUtils.mkdir_p 'config' if File::directory?('config')==false sip_file=File.join('config/', failed_sip_profile) end #File.open(sip_file, 'w') { |file| file.write('') } end return sip_file end |
#duration_value ⇒ Object
394 395 396 |
# File 'lib/tdrunner_profile.rb', line 394 def duration_value() @duration_value end |
#execution_mode ⇒ Object
388 389 390 |
# File 'lib/tdrunner_profile.rb', line 388 def execution_mode() @execution_mode end |
#execution_profile ⇒ Object
400 401 402 |
# File 'lib/tdrunner_profile.rb', line 400 def execution_profile() @execution_profile end |
#failed_execution_profile ⇒ Object
406 407 408 |
# File 'lib/tdrunner_profile.rb', line 406 def failed_execution_profile() @failed_execution_profile end |
#format_tdrunner_date(date_time) ⇒ Object
method for checking the end time for tdrunner run
132 133 134 |
# File 'lib/tdrunner_profile.rb', line 132 def format_tdrunner_date(date_time) Time.parse(date_time) end |
#lpt_run ⇒ Object
391 392 393 |
# File 'lib/tdrunner_profile.rb', line 391 def lpt_run() @lpt_run end |
#make_execution_profile ⇒ Object
403 404 405 |
# File 'lib/tdrunner_profile.rb', line 403 def make_execution_profile() @make_execution_profile end |
#parse_tdrunner_parameters(args) ⇒ Object
Parser method for tdrunner commandline parameters -H prameter defines the runtime -d parameter is for the end time stamp -i parameter is for the iteration number for the tests -m parameter is for creating a test set execution profile without running the tests
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 |
# File 'lib/tdrunner_profile.rb', line 188 def parse_tdrunner_parameters(args) hour_defined=false end_date_defined=false start_date_defined=false iterations_defined=false execution_profile_defined=false make_execution_profile=false combine_report_defined=false make_failed_execution_profile_defined=false parameters_contains_framework_command=check_if_parameters_contain_a_framework_command(args) args.each do |value| if hour_defined==true @execution_mode='-H' if @execution_mode!='-m' @duration_value=value.to_s if !check_duration(@duration_value) puts 'Error duration '+ @duration_value+ ' is not valid!' exit end hour_defined=false end if end_date_defined==true @execution_mode='-d' if @execution_mode!='-m' @lpt_run=Time.new @lpt_run=format_tdrunner_date(value) if @lpt_run < Time.now puts 'Error date '+ @lpt_run.to_s + ' is in the past!' exit end end_date_defined=false end if start_date_defined==true @start_time=format_tdrunner_date(value) if @start_time < Time.now puts 'Error date '+ @start_time.to_s + ' is in the past!' exit end start_date_defined=false end if iterations_defined==true @execution_mode='-i' if @execution_mode!='-m' @lpt_run=value.to_i iterations_defined=false end if execution_profile_defined==true #@execution_mode='-e' @execution_profile=value execution_profile_defined=false end if make_execution_profile==true @execution_mode='-m' @execution_profile=value make_execution_profile=false end if combine_report_defined==true combine_report_defined=false @tdrunner_combine_report=value combine_with_existing_tdriver_report(value) end if make_failed_execution_profile_defined==true make_failed_execution_profile_defined=false @failed_execution_profile=value end if value.to_s == '--teardown' @tdrunner_teardown=true end if value.to_s == '--ordered' @tdrunner_ordered=true end if value.to_s == '-H' hour_defined=true end if value.to_s == '-d' end_date_defined=true end if value.to_s == '-s' start_date_defined=true end if value.to_s == '-i' iterations_defined=true end if value.to_s == '-e' execution_profile_defined=true end if value.to_s == '-m' make_execution_profile=true end if value.to_s == '-c' combine_report_defined=true end if value.to_s == '-t' make_failed_execution_profile_defined=true end end framework_command_start=false args.each do |value| if value=='.' value=Dir.getwd end if framework_command_start==true @test_framework_command << value end if value==@test_framework && parameters_contains_framework_command==true framework_command_start=true else if File.directory?(value) && framework_command_start==false && value!=@tdrunner_combine_report @test_framework_command << value framework_command_start=true end if File.file?(value) && framework_command_start==false && value.include?('.sip')==false @test_framework_command << value framework_command_start=true end end end if @execution_profile!=nil if parameters_contains_framework_command==false profile_location=sip_file(@execution_profile,@test_framework_command) @execution_profile=profile_location else profile_location=sip_file(@execution_profile) @execution_profile=profile_location end end if @failed_execution_profile!=nil failed_profile_location=create_failed_sip(@failed_execution_profile) @failed_execution_profile=failed_profile_location end end |
#sip_file(tdrunner_profile, profile_folder = nil) ⇒ Object
Locates sip file. and be located in the current directory (eg. project root) or in a .config/ or config/ subdirectory of the current directory.
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 |
# File 'lib/tdrunner_profile.rb', line 348 def sip_file(tdrunner_profile,profile_folder=nil) @tdrunner_profile_file=nil tdrunner_profile=tdrunner_profile+'.sip' if tdrunner_profile.include?('.sip')==false if File.file?(tdrunner_profile) @tdrunner_profile_file=tdrunner_profile end if @tdrunner_profile_file==nil profile_finder=TDRunnerFileFinder.new('sip') found_profile_files=profile_finder.get_files(Dir.getwd) found_profile_files.each do |profile_file| if File.basename(profile_file.gsub('\\','/')).downcase==tdrunner_profile.downcase @tdrunner_profile_file=profile_file.gsub('\\','/') end end end if @tdrunner_profile_file==nil if File::directory?('config')==false FileUtils.mkdir_p 'config' end if tdrunner_profile.include?("\\") prof_arr=tdrunner_profile.split("\\") tdrunner_profile=prof_arr.last elsif tdrunner_profile.include?('/') prof_arr=tdrunner_profile.split("/") tdrunner_profile=prof_arr.last end File.open('config/'+tdrunner_profile, 'w') { |file| file.write('') } profile_file=File.join('config','**', tdrunner_profile) end @tdrunner_profile_file ||= Dir.glob(profile_file).first @tdrunner_profile_file end |
#start_time ⇒ Object
412 413 414 |
# File 'lib/tdrunner_profile.rb', line 412 def start_time() @start_time end |
#tdrunner_ordered ⇒ Object
409 410 411 |
# File 'lib/tdrunner_profile.rb', line 409 def tdrunner_ordered() @tdrunner_ordered end |
#tdrunner_teardown ⇒ Object
397 398 399 |
# File 'lib/tdrunner_profile.rb', line 397 def tdrunner_teardown() @tdrunner_teardown end |
#test_framework ⇒ Object
382 383 384 |
# File 'lib/tdrunner_profile.rb', line 382 def test_framework() @test_framework end |
#test_framework_command ⇒ Object
385 386 387 |
# File 'lib/tdrunner_profile.rb', line 385 def test_framework_command() @test_framework_command end |