Class: MesaTestCase
- Inherits:
-
Object
- Object
- MesaTestCase
- Defined in:
- lib/mesa_test.rb
Instance Attribute Summary collapse
-
#data_names ⇒ Object
Returns the value of attribute data_names.
-
#data_types ⇒ Object
writeonly
Sets the attribute data_types.
-
#failure_msg ⇒ Object
readonly
Returns the value of attribute failure_msg.
-
#failure_type ⇒ Object
Returns the value of attribute failure_type.
-
#final_model ⇒ Object
readonly
Returns the value of attribute final_model.
-
#mesa ⇒ Object
readonly
Returns the value of attribute mesa.
-
#mesa_dir ⇒ Object
readonly
Returns the value of attribute mesa_dir.
-
#mesa_version ⇒ Object
readonly
Returns the value of attribute mesa_version.
-
#outcome ⇒ Object
Returns the value of attribute outcome.
-
#photo ⇒ Object
readonly
Returns the value of attribute photo.
-
#runtime_seconds ⇒ Object
readonly
Returns the value of attribute runtime_seconds.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
-
#success_msg ⇒ Object
readonly
Returns the value of attribute success_msg.
-
#success_string ⇒ Object
readonly
Returns the value of attribute success_string.
-
#success_type ⇒ Object
Returns the value of attribute success_type.
-
#test_name ⇒ Object
readonly
Returns the value of attribute test_name.
-
#test_omp_num_threads ⇒ Object
readonly
Returns the value of attribute test_omp_num_threads.
Class Method Summary collapse
Instance Method Summary collapse
- #add_datum(datum_name, datum_type) ⇒ Object
-
#clean ⇒ Object
based on $MESA_DIR/star/test_suite/each_test_clean, revision 10000.
-
#do_one ⇒ Object
based on $MESA_DIR/star/test_suite/each_test_run_and_diff, revision 10000.
-
#initialize(test: nil, mesa: nil, success_string: '', final_model: 'final.mod', photo: nil, mod: nil) ⇒ MesaTestCase
constructor
A new instance of MesaTestCase.
- #load_results ⇒ Object
- #log_results ⇒ Object
- #omp_num_threads ⇒ Object
- #passed? ⇒ Boolean
- #test_case_dir ⇒ Object
- #test_suite_dir ⇒ Object
Constructor Details
#initialize(test: nil, mesa: nil, success_string: '', final_model: 'final.mod', photo: nil, mod: nil) ⇒ MesaTestCase
Returns a new instance of MesaTestCase.
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 |
# File 'lib/mesa_test.rb', line 613 def initialize(test: nil, mesa: nil, success_string: '', final_model: 'final.mod', photo: nil, mod: nil) @test_name = test @mesa_dir = mesa.mesa_dir @mesa = mesa @mesa_version = mesa.version_number @success_string = success_string @final_model = final_model @photo = photo @failure_type = nil @success_type = nil @outcome = :not_tested @runtime_seconds = 0 @test_omp_num_threads = 1 unless MesaTestCase.modules.include? mod raise TestCaseDirError, "Invalid module: #{mod}. Must be one of: " + MesaTestCase.modules.join(', ') end @mod = mod @failure_msg = { run_test_string: "#{test_name} failed: does not match test string", run_checksum: "#{test_name} run failed: checksum for #{final_model} " \ 'does not match after ./rn', run_diff: "#{test_name} run failed: diff #{final_model} " \ 'final_check.mod after ./rn', photo_file: "#{test_name} restart failed: #{photo} does not exist", photo_checksum: "#{test_name} restart failed: checksum for " \ "#{final_model} does not match after ./re", photo_diff: "#{test_name} restart failed: diff #{final_model} " \ 'final_check.mod after ./re' } @success_msg = { run_test_string: "#{test_name} run: found test string: " \ "'#{success_string}'", run_checksum: "#{test_name} run: checksum for #{final_model} matches " \ 'after ./rn', photo_checksum: "#{test_name} restart: checksum for #{final_model} " \ 'matches after ./re #{photo}' } # validate stuff check_mesa_dir check_test_case @data = {} @data_names = [] # way to output colored text to shell @shell = Thor::Shell::Color.new end |
Instance Attribute Details
#data_names ⇒ Object
Returns the value of attribute data_names.
606 607 608 |
# File 'lib/mesa_test.rb', line 606 def data_names @data_names end |
#data_types=(value) ⇒ Object
Sets the attribute data_types
606 607 608 |
# File 'lib/mesa_test.rb', line 606 def data_types=(value) @data_types = value end |
#failure_msg ⇒ Object (readonly)
Returns the value of attribute failure_msg.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def failure_msg @failure_msg end |
#failure_type ⇒ Object
Returns the value of attribute failure_type.
606 607 608 |
# File 'lib/mesa_test.rb', line 606 def failure_type @failure_type end |
#final_model ⇒ Object (readonly)
Returns the value of attribute final_model.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def final_model @final_model end |
#mesa ⇒ Object (readonly)
Returns the value of attribute mesa.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def mesa @mesa end |
#mesa_dir ⇒ Object (readonly)
Returns the value of attribute mesa_dir.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def mesa_dir @mesa_dir end |
#mesa_version ⇒ Object (readonly)
Returns the value of attribute mesa_version.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def mesa_version @mesa_version end |
#outcome ⇒ Object
Returns the value of attribute outcome.
606 607 608 |
# File 'lib/mesa_test.rb', line 606 def outcome @outcome end |
#photo ⇒ Object (readonly)
Returns the value of attribute photo.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def photo @photo end |
#runtime_seconds ⇒ Object (readonly)
Returns the value of attribute runtime_seconds.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def runtime_seconds @runtime_seconds end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def shell @shell end |
#success_msg ⇒ Object (readonly)
Returns the value of attribute success_msg.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def success_msg @success_msg end |
#success_string ⇒ Object (readonly)
Returns the value of attribute success_string.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def success_string @success_string end |
#success_type ⇒ Object
Returns the value of attribute success_type.
606 607 608 |
# File 'lib/mesa_test.rb', line 606 def success_type @success_type end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def test_name @test_name end |
#test_omp_num_threads ⇒ Object (readonly)
Returns the value of attribute test_omp_num_threads.
603 604 605 |
# File 'lib/mesa_test.rb', line 603 def test_omp_num_threads @test_omp_num_threads end |
Class Method Details
.modules ⇒ Object
609 610 611 |
# File 'lib/mesa_test.rb', line 609 def self.modules i[star binary] end |
Instance Method Details
#add_datum(datum_name, datum_type) ⇒ Object
683 684 685 686 687 688 689 690 |
# File 'lib/mesa_test.rb', line 683 def add_datum(datum_name, datum_type) unless data_types.include? datum_type.to_sym raise InvalidDataType, "Invalid data type: #{datum_type}. Must be one "\ 'of ' + data_types.join(', ') + '.' end @data[datum_name] = datum_type @data_names << datum_name end |
#clean ⇒ Object
based on $MESA_DIR/star/test_suite/each_test_clean, revision 10000
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 |
# File 'lib/mesa_test.rb', line 697 def clean shell.say("cleaning #{test_name}", color = :blue) puts '' check_mesa_dir check_test_case in_dir do puts './clean' unless system('./clean') raise TestCaseDirError, 'Encountered an error while running ./clean ' \ "in #{Dir.getwd}." end shell.say 'Removing all files from LOGS, LOGS1, LOGS2, photos, ' \ 'photos1, and photos2', color = :blue FileUtils.rm_f Dir.glob('LOGS/*') FileUtils.rm_f Dir.glob('LOGS1/*') FileUtils.rm_f Dir.glob('LOGS2/*') FileUtils.rm_f Dir.glob('photos/*') FileUtils.rm_f Dir.glob('photos1/*') FileUtils.rm_f Dir.glob('photos2/*') shell.say 'Removing files binary_history.data, out.txt, and ' \ 'test_results.yml', color = :blue FileUtils.rm_f 'binary_history.data' FileUtils.rm_f 'out.txt' if File.directory? File.join('star_history', 'history_out') shell.say 'Removing all files of the form history_out* from ' \ 'star_history', :blue FileUtils.rm_f Dir.glob(File.join('star_history', 'history_out', '*')) end if File.directory? File.join('star_profile', 'profiles_out') shell.say 'Removing all files of the form profiles_out* from ' \ 'star_profile', color = :blue FileUtils.rm_f Dir.glob(File.join('star_profile', 'profiles_out', '*')) end shell.say 'Removing .running', color = :blue FileUtils.rm_f '.running' end end |
#do_one ⇒ Object
based on $MESA_DIR/star/test_suite/each_test_run_and_diff, revision 10000
737 738 739 740 741 742 743 744 745 746 747 |
# File 'lib/mesa_test.rb', line 737 def do_one @test_omp_num_threads = omp_num_threads in_dir do FileUtils.touch '.running' shell.say("building and running #{test_name}", :blue) puts '' build_and_run FileUtils.rm '.running' puts '' end end |
#load_results ⇒ Object
767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/mesa_test.rb', line 767 def load_results # loads all parameters from a previous test run, likely for submission # purposes load_file = File.join(test_case_dir, 'test_results.yml') shell.say "Loading data from #{load_file}...", :blue data = YAML.safe_load(File.read(load_file), [Symbol]) @runtime_seconds = data['runtime_seconds'] @mesa_version = data['mesa_version'] @outcome = data['outcome'].to_sym @test_omp_num_threads = data['omp_num_threads'] @success_type = data['success_type'] @failure_type = data['failure_type'] shell.say "Done loading data from #{load_file}.\n", :green end |
#log_results ⇒ Object
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'lib/mesa_test.rb', line 749 def log_results # gets all parameters that would be submitted as well as computer # information and dumps to a yml file in the test case directory save_file = File.join(test_case_dir, 'test_results.yml') shell.say "Logging test results to #{save_file}...", :blue res = { 'test_case' => test_name, 'runtime_seconds' => runtime_seconds, 'mesa_version' => mesa_version, 'outcome' => outcome, 'omp_num_threads' => test_omp_num_threads, 'success_type' => success_type, 'failure_type' => failure_type } File.open(save_file, 'w') { |f| f.write(YAML.dump(res)) } shell.say "Successfully saved results to file #{save_file}.\n", :green end |
#omp_num_threads ⇒ Object
692 693 694 |
# File 'lib/mesa_test.rb', line 692 def omp_num_threads ENV['OMP_NUM_THREADS'].to_i || 1 end |
#passed? ⇒ Boolean
664 665 666 667 668 669 670 671 672 673 |
# File 'lib/mesa_test.rb', line 664 def passed? if @outcome == :pass true elsif @outcome == :fail false else raise TestCaseDirError, 'Cannot determine pass/fail status of ' \ '#{test_name} yet.' end end |
#test_case_dir ⇒ Object
679 680 681 |
# File 'lib/mesa_test.rb', line 679 def test_case_dir File.join(test_suite_dir, test_name) end |
#test_suite_dir ⇒ Object
675 676 677 |
# File 'lib/mesa_test.rb', line 675 def test_suite_dir mesa.test_suite_dir(mod: @mod) end |