Class: Oats::TestList
- Inherits:
-
Object
- Object
- Oats::TestList
- Defined in:
- lib/oats/test_list.rb
Overview
TestList has array of variations
Constant Summary collapse
- @@current =
nil
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Parent variation, start and end times.
-
#id ⇒ Object
readonly
Path of test relative to the dir_tests library.
-
#parent_variation ⇒ Object
Parent variation, start and end times.
-
#path ⇒ Object
readonly
Absolute path to the test.yml.
-
#post_test ⇒ Object
Parent variation, start and end times.
-
#pre_test ⇒ Object
Parent variation, start and end times.
-
#start_time ⇒ Object
Parent variation, start and end times.
-
#variations ⇒ Object
Array of Variation structures.
Class Method Summary collapse
-
.current ⇒ Object
Currently active test list.
- .current=(list) ⇒ Object
- .txt_tests(pth) ⇒ Object
Instance Method Summary collapse
- #add_variation(var) ⇒ Object
-
#initialize(id, path) ⇒ TestList
constructor
A new instance of TestList.
- #testlist_hash ⇒ Object
Constructor Details
#initialize(id, path) ⇒ TestList
Returns a new instance of TestList.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/oats/test_list.rb', line 59 def initialize(id, path) @id = id @path = path @start_time = Time.now.to_i @variations = [] add_variation('default') $log.info "**** TEST LIST [#{@id}]" if id # raise OatsError, "Encountered recursive inclusion of test lists: [#{tree_id}]" if @@current # Make this list a child of current list @parent_variation = @@current.variations.last @parent_variation.tests << self else # record the root $oats_info['test_files'] = self end @@current = self # Repoint the current list end |
Instance Attribute Details
#end_time ⇒ Object
Parent variation, start and end times
12 13 14 |
# File 'lib/oats/test_list.rb', line 12 def end_time @end_time end |
#id ⇒ Object (readonly)
Path of test relative to the dir_tests library
6 7 8 |
# File 'lib/oats/test_list.rb', line 6 def id @id end |
#parent_variation ⇒ Object
Parent variation, start and end times
12 13 14 |
# File 'lib/oats/test_list.rb', line 12 def parent_variation @parent_variation end |
#path ⇒ Object (readonly)
Absolute path to the test.yml
8 9 10 |
# File 'lib/oats/test_list.rb', line 8 def path @path end |
#post_test ⇒ Object
Parent variation, start and end times
12 13 14 |
# File 'lib/oats/test_list.rb', line 12 def post_test @post_test end |
#pre_test ⇒ Object
Parent variation, start and end times
12 13 14 |
# File 'lib/oats/test_list.rb', line 12 def pre_test @pre_test end |
#start_time ⇒ Object
Parent variation, start and end times
12 13 14 |
# File 'lib/oats/test_list.rb', line 12 def start_time @start_time end |
#variations ⇒ Object
Array of Variation structures
10 11 12 |
# File 'lib/oats/test_list.rb', line 10 def variations @variations end |
Class Method Details
.current ⇒ Object
Currently active test list
15 16 17 |
# File 'lib/oats/test_list.rb', line 15 def TestList.current @@current end |
.current=(list) ⇒ Object
18 19 20 |
# File 'lib/oats/test_list.rb', line 18 def TestList.current=(list) @@current = list end |
.txt_tests(pth) ⇒ Object
22 23 24 25 26 |
# File 'lib/oats/test_list.rb', line 22 def TestList.txt_tests(pth) list = IO.readlines(pth) list = list.collect{|x| f=x.chomp.sub(/#.*/,'').strip} return list.delete_if { |x| x == '' } end |
Instance Method Details
#add_variation(var) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/oats/test_list.rb', line 28 def add_variation(var) lv = self.variations.last lv.end_time = Time.now.to_i if lv and ! lv.end_time if variations.empty? or variations.last.name != 'default' variations << Variation.new(var,self) else variations.last.name = var variations.last.start_time = Time.now.to_i end end |
#testlist_hash ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/oats/test_list.rb', line 39 def testlist_hash variation = nil top_level_variations = self.variations[0] unless top_level_variations.nil? or top_level_variations.tests.nil? cur_test_list = top_level_variations.tests[0] if cur_test_list if cur_test_list.instance_of?(TestCase) variation = top_level_variations else variation = cur_test_list.variations[0] end # Oats seems to set the end_time of variations incorrectly as equal to # start time until very end. Compensate for it by borrowing the time from the TestList variation.end_time = cur_test_list.end_time end end return nil unless variation return variation.variation_hash(pre_test, post_test) end |