Method: Oats::Variation#variation_hash

Defined in:
lib/oats/test_list.rb

#variation_hash(pre_test, post_test) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
130
131
132
133
134
135
136
137
138
# File 'lib/oats/test_list.rb', line 89

def variation_hash(pre_test, post_test)
  err_msg = nil
  testlist = self
  $log ||= Rails.logger
  testlist.tests.each_with_index do |tst,idx|
    unless tst.instance_of?(TestCase)
      msg = "Expected a test case in #{testlist.list_name} but got:"
      $log.error "#{msg} #{tst.inspect}"
      msg = "... in job:"
      $log.error "#{msg} #{self.inspect}"
      msg = "Deleting the TestList #{tst.id}"
      err_msg = "Deleted unexpected sub-TestList: #{tst.id}"
      $log.error msg
      testlist.tests.delete(tst)
      next
    end
  end
  testlist.parent = nil

  thash = {
    'fail' => testlist.fail,
    'pass' => testlist.pass,
    'skip' => testlist.skip,
    'total' => testlist.total,
    'start_time' => testlist.start_time,
    'end_time' => testlist.end_time,
    'tests' => []
  }
  if pre_test and ! pre_test.errors.empty?
    thash['tests'].push(pre_test)
    thash['fail'] = thash['fail'] ? (thash['fail'] +1) : 1
  end
  if post_test and ! post_test.errors.empty?
    thash['tests'].push(post_test)
    thash['fail'] = thash['fail'] ? (thash['fail'] +1) : 1
  end
  thash['results_error'] = err_msg if err_msg
  testlist.tests.each do |t|
    tc = { 'id' => t.id,
      'status' => t.status,
      'error_capture_file' => t.error_capture_file,
      'result' => t.result,
      'timed_out' => t.timed_out?,
      'start_time' => t.start_time,
      'end_time' => t.end_time      }
    tc['errors'] = t.errors if t.errors
    thash['tests'].push tc
  end
  return thash
end