def _run(self, args: List[str], timeout: Optional[float], mode: EvaluationMode) -> Task: exc.raise_if_not_found(self._absolute_path(self.path), file_type=exc.FileType.FILE) task = Task(self._absolute_path(self.path), args=args) task.run(timeout=timeout) return task
def _assemble_instrumentation(self) -> None: base_args = ['-p', self.LAUNCHER_DIR] tasks = ['wrapper'] gradle = Task.spawn('gradle', args=base_args + tasks) gradle.raise_if_failed(message='Cannot generate Gradle wrapper') tasks = ['clean', 'assembleRelease'] gradle = Task.spawn(path.join(self.LAUNCHER_DIR, 'gradlew'), args=base_args + tasks) gradle.raise_if_failed(message='Gradle build failed')
def _detect_connected_device(self) -> str: """Returns the name of a connected device.""" task = Task('instruments', args=['-s', 'devices']) task.run() for line in task.stdout.splitlines(): components = line.split(' (', 1) if len(components ) == 2 and not components[1].endswith('(Simulator)'): return components[0] exc.raise_ioerror(errno.ENODEV, message='No connected devices.')
def _task(self, args: List[str]) -> Task: return Task(self._absolute_path(self.path), args=args)
def setup(self) -> None: args = self._common_args() + ['build-for-testing'] Task.spawn(self.path, args=args, output_action=OutputAction.DISCARD)
def _uninstall_instrumentation(self) -> None: adb = Task.spawn(self.path, args=['uninstall', self.PACKAGE]) adb.raise_if_failed( message='Cannot uninstall instrumentation from device')
def _install_instrumentation(self) -> None: adb = Task.spawn(self.path, args=['install', self.APK_PATH]) adb.raise_if_failed(message='Cannot install instrumentation on device')
def _is_instrumentation_installed(self) -> bool: args = ['shell', f'cmd package list packages {self.PACKAGE}'] adb = Task.spawn(self.path, args=args) adb.raise_if_failed(message='Cannot start Android Debug Bridge') return True if adb.stdout else False