class BaseChip::Test

Attributes

action_extensions[RW]
original_actions[RW]

Public Instance Methods

bundle_name() click to toggle source

def depends(dep=nil) ;(@action_extensions && @action_extensions.depends ) || super(dep) end

# File lib/base_chip/test.rb, line 120
def bundle_name        ; name                                                        end
bundle_tgz() click to toggle source
# File lib/base_chip/test.rb, line 121
def bundle_tgz         ; "#{@directory}.tgz"                                         end
clean() click to toggle source

SAFE TO DELETE? def configuration_hash SAFE TO DELETE? super.merge @action_extensions.configuration_hash SAFE TO DELETE? end

# File lib/base_chip/test.rb, line 181
def clean
end
clobber() click to toggle source
# 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() click to toggle source

def actions

parent.actions

end

Calls superclass method
# File lib/base_chip/test.rb, line 39
def configure
  return if @configured
  name_it
  @directory ||= "#{parent.directory}/#{@name}"
  super
end
deep_configure() click to toggle source
Calls superclass method
# 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() click to toggle source
@action_extensions.name_it
@name = @action_extensions.name

end def find_parent_values

super
find_parent_values_of_underlying_action

end

# File lib/base_chip/test.rb, line 101
def name_it
  if BaseChip.options.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() click to toggle source

one random generator per test, all subordinate actions use it

# File lib/base_chip/test.rb, line 191
def random_generator
  @random_generator ||= BaseChip.new_random_generator
end
rerun_data() click to toggle source
# File lib/base_chip/test.rb, line 195
def rerun_data
  { 'full_name'         => full_name                          ,
    'seed'              => random_generator.seed              ,
     'append_arguments' => BaseChip.options. append_arguments ,
    'replace_arguments' => BaseChip.options.replace_arguments }
end
run() click to toggle source
# 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() click to toggle source
# 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