Class: UISpecRunner::Drivers::WaxSim

Inherits:
Object
  • Object
show all
Defined in:
lib/uispecrunner/drivers/waxsim.rb

Constant Summary collapse

WAXSIM_BIN_DIR =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'ext', 'bin'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ WaxSim

Returns a new instance of WaxSim.



10
11
12
# File 'lib/uispecrunner/drivers/waxsim.rb', line 10

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/uispecrunner/drivers/waxsim.rb', line 8

def config
  @config
end

Instance Method Details

#family_switchObject



18
19
20
# File 'lib/uispecrunner/drivers/waxsim.rb', line 18

def family_switch
  "-f #{config.family}" if config.family
end

#run_specs(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/uispecrunner/drivers/waxsim.rb', line 22

def run_specs(env)
  env_args = env.map { |k,v| "-e #{k}=#{v} "}.join(' ')
  exit_status = nil
  command = %Q{#{waxsim_path} -s #{config.sdk_version} #{family_switch} #{env_args} "#{config.app_path}"}
  puts "Executing command: #{command}" if config.verbose?
  `#{command}`
  
  # TODO: Total hack. Can't figure out how to get the exit status any other way.
  # WaxSim can't get the child pid because the process isn't forked as a child. The output
  # can't be parsed directly because of funkiness with the file descriptors. Better ideas?
  exit_status = `tail /var/log/system.log| grep "Exiting with status code:"`.split(/code\:\s/).last.to_i
  
  return exit_status
end

#waxsim_pathObject



14
15
16
# File 'lib/uispecrunner/drivers/waxsim.rb', line 14

def waxsim_path
  File.join(WAXSIM_BIN_DIR, 'waxsim')
end