Method: BaseChip::Action#run

Defined in:
lib/base_chip/action.rb

#runObject



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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/base_chip/action.rb', line 67

def run
  if @run_action_in_tmp
    bundle_name   = random_string
    run_directory = "/tmp/#{bundle_name}"
  else
    bundle_name   = @bundle_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

  # Where the magic happens
  inner_run

  FileUtils.touch "#{run_directory}/.fail_detected" unless self.pass?

  Dir.chdir '..'
  if (@clean_passing_action && pass? && !@foreground)
    FileUtils.rm_rf run_directory
  else
    bundle_tgz = nil
    if @zip_failing_action || (@zip_passing_action && 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_action_in_tmp
      FileUtils.mkdir_p                           "#{@directory}/.."
      FileUtils.mv((bundle_tgz || run_directory), "#{@directory}/..")
    end
  end

  puts "Debug information here: #{@bundle_tgz || @directory}" if @foreground

  # p @totals if @foreground
  Dir.popd
end