Class: Mesa
- Inherits:
-
Object
- Object
- Mesa
- Defined in:
- lib/mesa_test.rb
Instance Attribute Summary collapse
-
#mesa_dir ⇒ Object
readonly
Returns the value of attribute mesa_dir.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
-
#test_cases ⇒ Object
readonly
Returns the value of attribute test_cases.
-
#test_data ⇒ Object
readonly
Returns the value of attribute test_data.
-
#test_names ⇒ Object
readonly
Returns the value of attribute test_names.
Class Method Summary collapse
Instance Method Summary collapse
-
#check_mod(mod) ⇒ Object
TEST SUITE METHODS.
- #clean ⇒ Object
- #destroy ⇒ Object
-
#each_test_clean(mod: :all) ⇒ Object
based off of ‘$MESA_DIR/star/test_suite/each_test_run_and_diff` from revision 10000.
- #each_test_load_results(mod: :all) ⇒ Object
- #each_test_run_and_diff(mod: :all, log_results: false) ⇒ Object
-
#find_test_case(test_case_name: nil, mod: :all) ⇒ Object
can accept a number (in string form) as a name for indexed access.
-
#initialize(mesa_dir: ) ⇒ Mesa
constructor
A new instance of Mesa.
- #install ⇒ Object
- #installed? ⇒ Boolean
-
#load_test_source_data(mod: :all) ⇒ Object
load data from the ‘do1_test_source` file that gets used in a lot of testing.
- #test_suite_dir(mod: nil) ⇒ Object
-
#version_number ⇒ Object
read version number from $MESA_DIR/data/version_number.
Constructor Details
#initialize(mesa_dir: ) ⇒ Mesa
Returns a new instance of Mesa.
336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/mesa_test.rb', line 336 def initialize(mesa_dir: ENV['MESA_DIR']) @mesa_dir = mesa_dir # these get populated by calling #load_test_data @test_data = {} @test_names = {} @test_cases = {} # way to output colored text @shell = Thor::Shell::Color.new end |
Instance Attribute Details
#mesa_dir ⇒ Object (readonly)
Returns the value of attribute mesa_dir.
323 324 325 |
# File 'lib/mesa_test.rb', line 323 def mesa_dir @mesa_dir end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
323 324 325 |
# File 'lib/mesa_test.rb', line 323 def shell @shell end |
#test_cases ⇒ Object (readonly)
Returns the value of attribute test_cases.
323 324 325 |
# File 'lib/mesa_test.rb', line 323 def test_cases @test_cases end |
#test_data ⇒ Object (readonly)
Returns the value of attribute test_data.
323 324 325 |
# File 'lib/mesa_test.rb', line 323 def test_data @test_data end |
#test_names ⇒ Object (readonly)
Returns the value of attribute test_names.
323 324 325 |
# File 'lib/mesa_test.rb', line 323 def test_names @test_names end |
Class Method Details
.download(version_number: nil, new_mesa_dir: nil) ⇒ Object
325 326 327 328 329 330 331 332 333 334 |
# File 'lib/mesa_test.rb', line 325 def self.download(version_number: nil, new_mesa_dir: nil) new_mesa_dir ||= File.join(ENV['HOME'], 'mesa-test-r' + version_number.to_s) success = system("svn co -r #{version_number} "+ "svn://svn.code.sf.net/p/mesa/code/trunk #{new_mesa_dir}") unless success raise MesaDirError, "Encountered a problem in download mesa " + "revision #{version_number}." end Mesa.new(mesa_dir: new_mesa_dir) end |
Instance Method Details
#check_mod(mod) ⇒ Object
TEST SUITE METHODS
381 382 383 384 385 |
# File 'lib/mesa_test.rb', line 381 def check_mod(mod) return if MesaTestCase.modules.include? mod raise TestCaseDirError, "Invalid module: #{mod}. Must be one of: " + MesaTestCase.modules.join(', ') end |
#clean ⇒ Object
357 358 359 360 361 362 363 364 |
# File 'lib/mesa_test.rb', line 357 def clean visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " + "running `clean` in #{mesa_dir}." do puts './clean' system('./clean') end self end |
#destroy ⇒ Object
375 376 377 |
# File 'lib/mesa_test.rb', line 375 def destroy FileUtils.rm_rf mesa_dir end |
#each_test_clean(mod: :all) ⇒ Object
based off of ‘$MESA_DIR/star/test_suite/each_test_run_and_diff` from revision 10000
459 460 461 462 463 464 465 466 467 468 |
# File 'lib/mesa_test.rb', line 459 def each_test_clean(mod: :all) if mod == :all MesaTestCase.modules.each { |this_mod| each_test_clean mod: this_mod } else check_mod mod test_names[mod].each do |test_name| test_cases[mod][test_name].clean end end end |
#each_test_load_results(mod: :all) ⇒ Object
486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/mesa_test.rb', line 486 def each_test_load_results(mod: :all) if mod == :all MesaTestCase.modules.each do |this_mod| each_test_load_results(mod: this_mod) end else test_names[mod].each do |test_name| test_cases[mod][test_name].load_results end end end |
#each_test_run_and_diff(mod: :all, log_results: false) ⇒ Object
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
# File 'lib/mesa_test.rb', line 470 def each_test_run_and_diff(mod: :all, log_results: false) each_test_clean(mod: mod) if mod == :all MesaTestCase.modules.each do |this_mod| each_test_run_and_diff(mod: this_mod, log_results: log_results) end else test_names[mod].each do |test_name| test_cases[mod][test_name].do_one test_cases[mod][test_name].log_results if log_results end log_summary if log_results end end |
#find_test_case(test_case_name: nil, mod: :all) ⇒ Object
can accept a number (in string form) as a name for indexed access
449 450 451 452 453 454 455 |
# File 'lib/mesa_test.rb', line 449 def find_test_case(test_case_name: nil, mod: :all) if /\A[0-9]+\z/ =~ test_case_name find_test_case_by_number(test_number: test_case_name.to_i, mod: mod) else find_test_case_by_name(test_case_name: test_case_name, mod: mod) end end |
#install ⇒ Object
366 367 368 369 370 371 372 373 |
# File 'lib/mesa_test.rb', line 366 def install visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " + "running `install` in #{mesa_dir}." do puts './install' system('./install') end self end |
#installed? ⇒ Boolean
498 499 500 |
# File 'lib/mesa_test.rb', line 498 def installed? check_mesa_dir end |
#load_test_source_data(mod: :all) ⇒ Object
load data from the ‘do1_test_source` file that gets used in a lot of testing
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/mesa_test.rb', line 394 def load_test_source_data(mod: :all) # allow for brainless loading of all module data if mod == :all MesaTestCase.modules.each do |this_mod| load_test_source_data(mod: this_mod) end else check_mod mod # load data from the source file source_lines = IO.readlines( File.join(test_suite_dir(mod: mod), 'do1_test_source') ) # initialize data hash to empty hash and name array to empty array @test_data[mod] = {} @test_names[mod] = [] @test_cases[mod] = {} # read through each line and find four data, name, success string, final # model name, and photo. Either of model name and photo can be "skip" source_lines.each do |line| no_skip = /^do_one (.+)\s+"([^"]*)"\s+"([^"]+)"\s+(x?\d+)/ one_skip = /^do_one (.+)\s+"([^"]*)"\s+"([^"]+)"\s+skip/ two_skip = /^do_one (.+)\s+"([^"]*)"\s+skip\s+skip/ found_test = false if line =~ no_skip found_test = true @test_data[mod][$1] = { success_string: $2, final_model: $3, photo: $4} elsif line =~ one_skip found_test = true @test_data[mod][$1] = { success_string: $2, final_model: $3, photo: nil } elsif line =~ two_skip found_test = true @test_data[mod][$1] = { success_string: $2, final_model: nil, photo: nil } end if found_test @test_names[mod] << $1 unless @test_names.include? $1 end end # make MesaTestCase objects accessible by name @test_names[mod].each do |test_name| data = @test_data[mod][test_name] @test_cases[mod][test_name] = MesaTestCase.new(test: test_name, mesa: self, success_string: data[:success_string], mod: mod, final_model: data[:final_model], photo: data[:photo]) end end end |
#test_suite_dir(mod: nil) ⇒ Object
387 388 389 390 |
# File 'lib/mesa_test.rb', line 387 def test_suite_dir(mod: nil) check_mod mod File.join(mesa_dir, mod.to_s, 'test_suite') end |
#version_number ⇒ Object
read version number from $MESA_DIR/data/version_number
349 350 351 352 353 354 355 |
# File 'lib/mesa_test.rb', line 349 def version_number contents = '' File.open(File.join(mesa_dir, 'data', 'version_number'), 'r') do |f| contents = f.read end contents.strip.to_i end |