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.
27 28 29 30 31 32 33 34 35 |
# File 'lib/openc3/script/suite_results.rb', line 27 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.
25 26 27 |
# File 'lib/openc3/script/suite_results.rb', line 25 def context @context end |
#metadata ⇒ Object
Returns the value of attribute metadata.
25 26 27 |
# File 'lib/openc3/script/suite_results.rb', line 25 def @metadata end |
Instance Method Details
#complete ⇒ Object
101 102 103 104 |
# File 'lib/openc3/script/suite_results.rb', line 101 def complete @stop_time = Time.now.sys () end |
#footer ⇒ Object
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 168 169 170 171 172 |
# File 'lib/openc3/script/suite_results.rb', line 136 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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/openc3/script/suite_results.rb', line 110 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
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 95 96 97 98 99 |
# File 'lib/openc3/script/suite_results.rb', line 59 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
178 179 180 |
# File 'lib/openc3/script/suite_results.rb', line 178 def puts(string) @report << (Time.now.sys.formatted + ': ' + string) end |
#report ⇒ Object
106 107 108 |
# File 'lib/openc3/script/suite_results.rb', line 106 def report @report.join("\n") end |
#start(test_type, test_suite_class, test_class = nil, test_case = nil, settings = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/openc3/script/suite_results.rb', line 37 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 |