Class: RunLoop::CLI::Instruments

Inherits:
Thor
  • Object
show all
Defined in:
lib/run_loop/cli/instruments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#signalObject

Returns the value of attribute signal.



9
10
11
# File 'lib/run_loop/cli/instruments.rb', line 9

def signal
  @signal
end

Instance Method Details

#launchObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/run_loop/cli/instruments.rb', line 101

def launch
  if RunLoop::Xcode.new.version_gte_8?
    puts "Launching applications with Xcode 8 is not supported"
    exit 1
  end

  debug = options[:debug]
  original_value = ENV['DEBUG']

  ENV['DEBUG'] = '1' if debug

  begin
    launch_options = {
          :args => parse_app_launch_args(options),
          :udid => detect_device_udid_from_options(options),
          :app => detect_bundle_id_or_bundle_path(options)
    }
    run_loop = RunLoop.run(launch_options)
    puts JSON.generate(run_loop)
  ensure
    ENV['DEBUG'] = original_value if debug
  end
end

#quitObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/run_loop/cli/instruments.rb', line 28

def quit
  if RunLoop::Xcode.new.version_gte_8?
    puts "instruments quit with Xcode 8 is not supported"
    exit 1
  end

  signal = options[:signal]
  ENV['DEBUG'] = '1' if options[:debug]
  instruments = RunLoop::Instruments.new
  instruments.instruments_pids.each do |pid|
    terminator = RunLoop::ProcessTerminator.new(pid, signal, 'instruments')
    unless terminator.kill_process
      terminator = RunLoop::ProcessTerminator.new(pid, 'KILL', 'instruments')
      terminator.kill_process
    end
  end
end