Method: ICuke::Simulator#launch

Defined in:
lib/icuke/waxsim.rb

#launch(process) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/icuke/waxsim.rb', line 10

def launch(process)
  process = process.with_launch_options({
    :env => {
      'CFFIXED_USER_HOME' => Dir.mktmpdir
    }
  })

  process.setup_commands.each do |cmd|
    fail "Unable to run setup command #{cmd}" if !system(cmd)
    fail "Setup command #{cmd} failed with exit status #{$?}" if $? != 0
  end

  @simulator = BackgroundProcess.run(process.command)
  self.current_process = process

  timeout(30) do
    begin
      view
    rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError
      sleep(0.5)
      retry
    end
  end
end