Class: Oats::Variation

Inherits:
Object
  • Object
show all
Defined in:
lib/oats/test_list.rb

Overview

TestList has an array of these

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var, list) ⇒ Variation

Returns a new instance of Variation.



81
82
83
84
85
86
# File 'lib/oats/test_list.rb', line 81

def initialize(var,list)
  @parent = list
  @name = var
  @tests = []
  @start_time = Time.now.to_i
end

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def end_time
  @end_time
end

#env_nameObject

Returns the value of attribute env_name.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def env_name
  @env_name
end

#failObject

Returns the value of attribute fail.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def fail
  @fail
end

#list_nameObject

Returns the value of attribute list_name.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def list_name
  @list_name
end

#nameObject

Returns the value of attribute name.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def name
  @name
end

#parentObject

Returns the value of attribute parent.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def parent
  @parent
end

#passObject

Returns the value of attribute pass.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def pass
  @pass
end

#skipObject

Returns the value of attribute skip.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def skip
  @skip
end

#start_timeObject

Returns the value of attribute start_time.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def start_time
  @start_time
end

#testsObject (readonly)

Returns the value of attribute tests.



79
80
81
# File 'lib/oats/test_list.rb', line 79

def tests
  @tests
end

#totalObject

Returns the value of attribute total.



80
81
82
# File 'lib/oats/test_list.rb', line 80

def total
  @total
end

Instance Method Details

#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