Class: OpenC3::SuiteResults
- Defined in:
- lib/openc3/script/suite_results.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #complete ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize ⇒ SuiteResults
constructor
A new instance of SuiteResults.
-
#process_result(results) ⇒ Object
process_result can handle an array of OpenC3TestResult objects or a single OpenC3TestResult object.
- #puts(string) ⇒ Object
- #report ⇒ Object
- #start(test_type, test_suite_class, test_class = nil, test_case = nil, settings = nil) ⇒ Object
- #write(string) ⇒ Object
Constructor Details
#initialize ⇒ SuiteResults
Returns a new instance of SuiteResults.
22 23 24 25 26 27 28 29 30 |
# File 'lib/openc3/script/suite_results.rb', line 22 def initialize @report = nil @context = nil @start_time = nil @stop_time = nil @results = nil @settings = nil @metadata = nil end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
20 21 22 |
# File 'lib/openc3/script/suite_results.rb', line 20 def context @context end |
#metadata ⇒ Object
Returns the value of attribute metadata.
20 21 22 |
# File 'lib/openc3/script/suite_results.rb', line 20 def @metadata end |
Instance Method Details
#complete ⇒ Object
96 97 98 99 |
# File 'lib/openc3/script/suite_results.rb', line 96 def complete @stop_time = Time.now.sys () end |
#footer ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/openc3/script/suite_results.rb', line 131 def self.puts "Completed #{@context}" @report << '' @report << "--- Test Summary ---" @report << '' pass_count = 0 skip_count = 0 fail_count = 0 stopped = false @results.each do |result| if result.result == :PASS pass_count += 1 elsif result.result == :SKIP skip_count += 1 elsif result.result == :FAIL fail_count += 1 end if result.stopped stopped = true end end run_time = Time.format_seconds(@stop_time - @start_time) run_time << " (#{@stop_time - @start_time} seconds)" if @stop_time - @start_time > 60 @report << "Run Time: #{run_time}" @report << "Total Tests: #{@results.length}" @report << "Pass: #{pass_count}" @report << "Skip: #{skip_count}" @report << "Fail: #{fail_count}" @report << '' if stopped @report << '*** Test was stopped prematurely ***' @report << '' end end |
#header ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/openc3/script/suite_results.rb', line 105 def header @report << "--- Script Report ---" # @report << '' # if @metadata # begin # items = get_tlm_packet('SYSTEM', 'META') # @report << '' # @report << "Metadata:" # items.each do |item_name, item_value, _| # next if SetTlmDialog::IGNORED_ITEMS.include?(item_name) # @report << "#{item_name} = #{item_value}" # end # rescue DRb::DRbConnError # # Oh well # end # end if @settings @report << '' @report << "Settings:" @settings.each { |setting_name, setting_value| @report << "#{setting_name} = #{setting_value}" } end @report << '' @report << "Results:" self.puts "Executing #{@context}" end |
#process_result(results) ⇒ Object
process_result can handle an array of OpenC3TestResult objects or a single OpenC3TestResult object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/openc3/script/suite_results.rb', line 54 def process_result(results) openc3_lib = Regexp.new(File.join(OpenC3::PATH, 'lib')) # If we were passed an array we concat it to the results global if results.is_a? Array @results.concat(results) # A single result is appended and then turned into an array else @results << results results = [results] end # Process all the results (may be just one) results.each do |result| self.puts("#{result.group}:#{result.script}:#{result.result}") if result. result..each_line do |line| if /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/.match?(line) line.chomp! line = line.inspect.remove_quotes end @report << (' ' + line.strip) end end if result.exceptions @report << " Exceptions:" result.exceptions.each_with_index do |error, index| error.formatted().each_line do |line| next if /in run_text/.match?(line) next if /running_script.rb/.match?(line) next if line&.match?(openc3_lib) if /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/.match?(line) line.chomp! line = line.inspect.remove_quotes end @report << (' ' + line.strip) end @report << '' if index != (result.exceptions.length - 1) end end end end |
#puts(string) ⇒ Object
173 174 175 |
# File 'lib/openc3/script/suite_results.rb', line 173 def puts(string) @report << (Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%6NZ") + ': ' + string) end |
#report ⇒ Object
101 102 103 |
# File 'lib/openc3/script/suite_results.rb', line 101 def report @report.join("\n") end |
#start(test_type, test_suite_class, test_class = nil, test_case = nil, settings = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/openc3/script/suite_results.rb', line 32 def start(test_type, test_suite_class, test_class = nil, test_case = nil, settings = nil) @results = [] @start_time = Time.now.sys @settings = settings @report = [] if test_case # Executing a script @context = "#{test_suite_class.name}:#{test_class.name}:#{test_case} #{test_type}" elsif test_class # Executing a group @context = "#{test_suite_class.name}:#{test_class.name} #{test_type}" else # Executing a suite @context = "#{test_suite_class.name} #{test_type}" end header() end |