Class: BaseChip::TestList

Inherits:
Object
  • Object
show all
Includes:
Base, Dsl
Defined in:
lib/base_chip/test_list.rb

Instance Attribute Summary

Attributes included from Dsl

#modes

Instance Method Summary collapse

Methods included from Base

included

Methods included from Dsl

#add_child_mode_as_child, included, #inherit, #mode, #mode?, #type_plural

Constructor Details

#initializeTestList

Returns a new instance of TestList.



31
32
33
34
# File 'lib/base_chip/test_list.rb', line 31

def initialize
  super
  @num_tests = 0
end

Instance Method Details

#configureObject



42
43
44
45
46
47
48
49
50
51
52
53
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
95
96
97
98
99
# File 'lib/base_chip/test_list.rb', line 42

def configure
  return if @configured
  @directory ||= "#{configuration.out_directory}/#{name}"
  super
  return unless @tests
  return unless @permutes
  tests = @tests.values
  @permutes.each_value do |permute|
    permute.configure
    next unless permute.permutations
    tests.map! do |t|
      permute.permutations.values.map do |permutation|
        test = t.dup
        test.name = "#{test.name}_#{permute.name}#{permutation.name}".to_sym
        test.blks += permutation.blks
        test
      end
    end
    tests.flatten!
  end

  if @posts
    tests.each do |t|
      @posts.each_value do |p|
        p.blks.each do |b|
          b.parameters.empty? ? t.instance_exec(&b) : b.call(t)
        end
      end
    end
  end
  if @requirements
    new_tests = []
    tests.each do |t|
      t.configure
      ditch = false
      @requirements.each_value do |m|
        m.blks.each do |b|
          ditch = !(b.parameters.empty? ? t.instance_exec(&b) : b.call(t))
          break if ditch
        end
        break if ditch
      end
      next if ditch
      new_tests << t
    end
    tests = new_tests
  end
  @tests = {}
  tests.each do |t|
    name = t.name
    i = 0
    while @tests[name]
      name = "#{t.name}_#{i+=1}"
    end
    t.name = name.to_sym
    @tests[name] = t
  end
end

#dereference_workload(tests = nil, passive = false) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/base_chip/test_list.rb', line 100

def dereference_workload(tests = nil,passive = false)
  configure
  tests ||= ['all']
  out = []
  return out unless @tests
  tests.each do |t|
    if t == 'all'
      out += @tests.values
    else
      if foo = @tests[t.to_sym]
        out << foo
      else
        fault "Could not find test #{t.inspect} in list #{@name.inspect} in block #{@block.name.inspect}" unless passive
      end
    end
  end
  out
end

#old_postObject



39
# File 'lib/base_chip/test_list.rb', line 39

alias old_post        post

#old_requirementObject

def actions

parent.actions

end



38
# File 'lib/base_chip/test_list.rb', line 38

alias old_requirement requirement

#post(name = :no_name, &blk) ⇒ Object



41
# File 'lib/base_chip/test_list.rb', line 41

def post(       name=:no_name,&blk); old_post(       name,&blk) end

#requirement(name = :no_name, &blk) ⇒ Object



40
# File 'lib/base_chip/test_list.rb', line 40

def requirement(name=:no_name,&blk); old_requirement(name,&blk) end