def kill_device(device):
   cmd = "ps xww | grep Simulator.app | grep -s {0} | grep -v grep | awk '{{print $1}}'".format(device.uuid)
   output = Executor.execute(cmd)
   if output == '':
     return
   pid = int(output)
   if pid > 0:
     Executor.execute('kill {0}'.format(pid))
def test_error_on_retry_exceeded(mocky):
    mocky.side_effect = [
        Result(1, 'fake-stdout', ''),
        Result(1, 'fake-stdout', '')
    ]
    with pytest.raises(ExecutionError):
        Executor().run('test-cmd', retries=1)
Beispiel #3
0
 def list_device_types(self):
     output = Executor.execute(CMD.format('devicetypes'))
     device_type_list = json.loads(output)['devicetypes']
     return [
         DeviceType(device_type['identifier'], device_type['name'])
         for device_type in device_type_list
     ]
 def get_devices_by_prefix(prefix):
   devices = []
   cmd = 'xcrun simctl list devices'
   result = Executor.execute(cmd).decode("utf-8")
   for line in result.splitlines():
     if line.strip().startswith(prefix):
       devices.append(Device(uuid=line[line.find("(")+1:line.find(")")]))
   return devices
def test_retry_on_fail(mocky):
    mocky.side_effect = [
        Result(1, 'fake-stdout', ''),
        Result(0, 'fake-stdout', '')
    ]
    Executor().run('test-cmd', retries=1)
    expected = [mock.call('test-cmd'), mock.call('test-cmd')]
    assert mocky.mock_calls == expected
Beispiel #6
0
 def list_runtimes(self):
     output = Executor.execute(CMD.format('runtimes'))
     runtime_list = json.loads(output)['runtimes']
     return [
         RunTime(runtime['availability'], runtime['buildversion'],
                 runtime['identifier'], runtime['name'], runtime['version'])
         for runtime in runtime_list
     ]
Beispiel #7
0
 def list_devices(self):
     output = Executor.execute(CMD.format('devices'))
     os_device_list = json.loads(output)['devices']
     device_array = []
     for os in os_device_list:
         device_array += [
             Device(device_dict['availability'], device_dict['name'], os,
                    device_dict['state'], device_dict['udid'])
             for device_dict in os_device_list[os]
         ]
     return device_array
 def install_device(device, app_path):
   cmd = 'xcrun simctl install {0} {1}'.format(device.uuid, app_path)
   Executor.execute(cmd)
 def delete_device(device):
   cmd = 'xcrun simctl delete {0}'.format(device.uuid)
   Executor.execute(cmd)
 def boot_device(device):
   cmd = 'xcrun simctl boot {0}'.format(device.uuid)
   Executor.execute(cmd)
 def launch_device(device):
   xcode_address = Executor.execute('xcode-select -p')
   cmd = "open -n {0}/Applications/Simulator.app --args -ConnectHardwareKeyboard 0 -CurrentDeviceUDID {1}".format(xcode_address, device.uuid)
   Executor.execute(cmd)
def test_fail_stderr(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', 'fake-stderr')]
    with pytest.raises(ExecutionError, match=r'stderr not empty'):
        Executor().run('test-cmd')
    mocky.assert_called_once_with('test-cmd')
def test_no_retry_on_success(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', '')]
    Executor().run('test-cmd', retries=1)
    mocky.assert_called_once_with('test-cmd')
def test_success_ignore_stderr(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', 'fake-stderr')]
    Executor().run('test-cmd', raise_on_stderr=False)
    mocky.assert_called_once_with('test-cmd')
def test_success_ignore_returncode(mocky):
    mocky.side_effect = [Result(1, 'fake-stdout', '')]
    Executor().run('test-cmd', raise_on_error=False)
    mocky.assert_called_once_with('test-cmd')
 def erase_device(device):
   cmd = 'xcrun simctl erase {0}'.format(device.uuid)
   Executor.execute(cmd)
 def shutdown_device(device):
   cmd = 'xcrun simctl shutdown {0}'.format(device.uuid)
   Executor.execute(cmd)
 def create_device(name, device_type, runtime):
   cmd = 'xcrun simctl create "{0}" "{1}" "{2}"'.format(name, device_type.identifier, runtime.identifier)
   uuid = Executor.execute(cmd).decode('utf-8')
   device = Device(uuid=uuid, name=name)
   return device
Beispiel #19
0
 def read_current_release(self):
     return Executor(chdir=self.manifest_dir).run(
         ["git", "describe", "--tags", "--abbrev=0"]).stdout
def test_fail_returncode(mocky):
    mocky.side_effect = [Result(1, 'fake-stdout', '')]
    with pytest.raises(ExecutionError, match=r'execution status NOT zero'):
        Executor().run('test-cmd')
    mocky.assert_called_once_with('test-cmd')