Class: UISpecRunner::Drivers::Shell
- Inherits:
-
Object
- Object
- UISpecRunner::Drivers::Shell
- Defined in:
- lib/uispecrunner/drivers/shell.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Shell
constructor
A new instance of Shell.
- #path_to_securityd ⇒ Object
- #run_command(command) ⇒ Object
- #run_specs(env) ⇒ Object
- #start_securityd ⇒ Object
- #stop_securityd ⇒ Object
- #with_env(env) ⇒ Object
Constructor Details
#initialize(config) ⇒ Shell
Returns a new instance of Shell.
8 9 10 |
# File 'lib/uispecrunner/drivers/shell.rb', line 8 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/uispecrunner/drivers/shell.rb', line 6 def config @config end |
Instance Method Details
#path_to_securityd ⇒ Object
42 43 44 |
# File 'lib/uispecrunner/drivers/shell.rb', line 42 def path_to_securityd "#{config.sdk_dir}/usr/libexec/securityd" end |
#run_command(command) ⇒ Object
37 38 39 40 |
# File 'lib/uispecrunner/drivers/shell.rb', line 37 def run_command(command) puts "Executing: #{command}" if config.verbose? system(command) end |
#run_specs(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/uispecrunner/drivers/shell.rb', line 12 def run_specs(env) run_env = config.env.merge(env) run_env.merge!('DYLD_ROOT_PATH' => config.sdk_dir, 'IPHONE_SIMULATOR_ROOT' => config.sdk_dir, 'CFFIXED_USER_HOME' => Dir.tmpdir) puts "Setting environment variables: #{run_env.inspect}" if config.verbose? with_env(run_env) do start_securityd if config.securityd command = "#{config.app_executable_path} -RegisterForSystemEvents" puts "Executing: #{command}" if config.verbose? output = `#{command}` exit_code = $? unless exit_code == 0 puts "[!] Failed specs running UISpec target (exit code #{exit_code})" exit 1 end end end |
#start_securityd ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/uispecrunner/drivers/shell.rb', line 46 def start_securityd run_command("launchctl submit -l UISpecRunnerDaemons -- #{path_to_securityd}") @securityd_running = true Signal.trap("INT") { stop_securityd } Signal.trap("TERM") { stop_securityd } Signal.trap("EXIT") { stop_securityd } end |
#stop_securityd ⇒ Object
54 55 56 57 |
# File 'lib/uispecrunner/drivers/shell.rb', line 54 def stop_securityd run_command("launchctl remove UISpecRunnerDaemons") if @securityd_running @securityd_running = false end |
#with_env(env) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/uispecrunner/drivers/shell.rb', line 29 def with_env(env) before = env.inject({}) { |h, (k, _)| h[k] = ENV[k]; h } env.each { |k, v| ENV[k] = v } yield ensure before.each { |k, v| ENV[k] = v } end |