Class: BaseChip::Test
- Inherits:
-
Object
- Object
- BaseChip::Test
- Includes:
- Base, Dsl, Runable, Taskable, TrackState
- Defined in:
- lib/base_chip/test.rb
Instance Attribute Summary collapse
-
#action_extensions ⇒ Object
Returns the value of attribute action_extensions.
-
#original_actions ⇒ Object
Returns the value of attribute original_actions.
Attributes included from Dsl
Instance Method Summary collapse
-
#bundle_name ⇒ Object
def depends(dep=nil) ;(@action_extensions && @action_extensions.depends ) || super(dep) end.
- #bundle_tgz ⇒ Object
-
#clean ⇒ Object
SAFE TO DELETE? def configuration_hash SAFE TO DELETE? super.merge @action_extensions.configuration_hash SAFE TO DELETE? end.
- #clobber ⇒ Object
-
#configure ⇒ Object
def actions parent.actions end.
- #deep_configure ⇒ Object
-
#name_it ⇒ Object
@action_extensions.name_it @name = @action_extensions.name end def find_parent_values super find_parent_values_of_underlying_action end.
-
#random_generator ⇒ Object
one random generator per test, all subordinate actions use it.
- #rerun_data ⇒ Object
- #run ⇒ Object
- #totals ⇒ Object
Methods included from Base
Methods included from Dsl
#add_child_mode_as_child, included, #inherit, #mode, #mode?, #type_plural
Methods included from Runable
Methods included from TrackState
Methods included from Taskable
Instance Attribute Details
#action_extensions ⇒ Object
Returns the value of attribute action_extensions.
34 35 36 |
# File 'lib/base_chip/test.rb', line 34 def action_extensions @action_extensions end |
#original_actions ⇒ Object
Returns the value of attribute original_actions.
33 34 35 |
# File 'lib/base_chip/test.rb', line 33 def original_actions @original_actions end |
Instance Method Details
#bundle_name ⇒ Object
def depends(dep=nil) ;(@action_extensions && @action_extensions.depends ) || super(dep) end
120 |
# File 'lib/base_chip/test.rb', line 120 def bundle_name ; name end |
#bundle_tgz ⇒ Object
121 |
# File 'lib/base_chip/test.rb', line 121 def bundle_tgz ; "#{@directory}.tgz" end |
#clean ⇒ Object
SAFE TO DELETE? def configuration_hash SAFE TO DELETE? super.merge @action_extensions.configuration_hash SAFE TO DELETE? end
181 182 |
# File 'lib/base_chip/test.rb', line 181 def clean end |
#clobber ⇒ Object
183 184 185 186 187 188 |
# File 'lib/base_chip/test.rb', line 183 def clobber FileUtils.rm_rf directory if Dir.glob("#{test_list.directory}/*").empty? FileUtils.rm_rf test_list.directory end end |
#configure ⇒ Object
def actions
parent.actions
end
39 40 41 42 43 44 |
# File 'lib/base_chip/test.rb', line 39 def configure return if @configured name_it @directory ||= "#{parent.directory}/#{@name}" super end |
#deep_configure ⇒ Object
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 |
# File 'lib/base_chip/test.rb', line 45 def deep_configure super return if @deep_configured @deep_configured = true @test_actions = [@test_actions] unless @test_actions.is_a? Array # @original_actions = @block.dereference_workload([@actions])[0] fault "No test_actions exist for test list '#{@test_list}' to run in '#{@configuration.full_name}'" unless @configuration.actions unless (@original_actions = @configuration.dereference_workload(@test_actions)) && @original_actions.size > 0 fault "Test list '#{@test_list.name}' in block:configuration '#{@block.name}:#{@configuration.name}' specified nonexistant action(s) '#{@test_actions}'. #{@test_list.file}" end @action_extensions = @original_actions.map do |a| append_depends a.depends a2 = a.clone a2.clear a2.parent = self # don't think I need to set foster here, because test list is a peer to action a2.deep_configure a2 end @action_extensions.sort! do |a1,a2| if a1.deep_depends.map{|d|d.name}.include? a2.name 1 else -1 end end end |
#name_it ⇒ Object
@action_extensions.name_it
@name = @action_extensions.name
end def find_parent_values
super
end
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/base_chip/test.rb', line 101 def name_it if BaseChip..random_bundle_names @name ||= random_name elsif parent.autoname and not @name if parent.autoname.respond_to? :each parent.autoname.each do |an| if md = /#{an}/.match(@args) @name ||= (md[1] || md.to_s) break end end else if md = /#{parent.autoname}/.match(@args) @name ||= (md[1] || md.to_s) end end end end |
#random_generator ⇒ Object
one random generator per test, all subordinate actions use it
191 192 193 |
# File 'lib/base_chip/test.rb', line 191 def random_generator @random_generator ||= BaseChip.new_random_generator end |
#rerun_data ⇒ Object
195 196 197 198 199 200 |
# File 'lib/base_chip/test.rb', line 195 def rerun_data { 'full_name' => full_name , 'seed' => random_generator.seed , 'append_arguments' => BaseChip.. append_arguments , 'replace_arguments' => BaseChip..replace_arguments } end |
#run ⇒ Object
129 130 131 132 133 134 135 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 173 174 175 176 |
# File 'lib/base_chip/test.rb', line 129 def run if @run_test_in_tmp bundle_name = random_string run_directory = "/tmp/#{bundle_name}" else bundle_name = name run_directory = @directory end FileUtils.rm_rf run_directory FileUtils.mkdir_p run_directory Dir.pushd run_directory File.open('seed','w') do |f| f.write random_generator.seed end File.open('rerun.yaml','w') do |f| f.write rerun_data.to_yaml end @action_extensions.each do |a| a.random_generator = Random.new(random_generator.rand(0x1_0000_0000)) a.foreground = @foreground a.inner_run take_state(a) return unless pass? end Dir.chdir '..' if (@clean_passing_test && pass? && !@foreground) FileUtils.rm_rf run_directory else bundle_tgz = nil if @zip_failing_test || (@zip_passing_test && pass?) bundle_tgz = run_directory + ".tgz" @bundle_tgz = @directory + ".tgz" tgz = Zlib::GzipWriter.new(File.open(bundle_tgz, 'wb')) Archive::Tar::Minitar.pack(bundle_name, tgz) FileUtils.rm_rf bundle_name end if @run_test_in_tmp FileUtils.mkdir_p "#{@directory}/../" FileUtils.mv((bundle_tgz || run_directory), "#{@directory}/../") end end Dir.popd puts "Debug information here: #{@bundle_tgz || @directory}" if @foreground end |
#totals ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/base_chip/test.rb', line 122 def totals return @totals if @totals @totals = {} @action_extensions.each do |a| @totals.merge! a.totals end end |