Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
拉取最新代码
  • Loading branch information
PTMacI7 authored and PTMacI7 committed Nov 8, 2023
2 parents a904dca + d86cadd commit 7af14b3
Show file tree
Hide file tree
Showing 18 changed files with 341 additions and 195 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "coverage"
on:
pull_request:
branches:
- master
- main
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 5
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install pypa/build
run: |
python -m pip install --upgrade pip
pip install flake8 pytest wheel coverage
python3 -m pip install -e .
- name: Run coverage
run: |
coverage run -m pytest -v tests/
coverage xml
coverage report
- name: Run tests with coverage
uses: orgoro/coverage@v3.1
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 7 additions & 11 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@ jobs:
- name: Install pypa/build
run: |
python -m pip install --upgrade pip
pip install flake8 pytest wheel
pip install flake8 pytest wheel coverage
python3 -m pip install -e .
- name: Lint with flake8
- name: Run coverage
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -v tests/
coverage run -m pytest -v tests/
coverage xml
coverage report
- name: Build targz and wheel
run: |
python3 setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
skip-existing: true
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[English](README_EN.md)

QQ交流群: _134535547_ (进群答案: ios)
QQ交流群: _134535547_ (进群答案: 自己猜吧,不行就问gpt)

该工具能够用于与iOS设备进行通信, 提供以下功能

Expand Down Expand Up @@ -115,7 +115,7 @@ $ tidevice ps --json output as json
```bash
# 运行XCTEST
$ tidevice xctest -B com.facebook.wda.WebDriverAgent.Runner
$ tidevice xcuitest -B com.facebook.wda.WebDriverAgent.Runner
[I 210127 11:40:23 _device:909] BundleID: com.facebook.wda.WebDriverAgent.Runner
[I 210127 11:40:23 _device:911] DeviceIdentifier: 12345678901234567890abcdefg
[I 210127 11:40:23 _device:773] SignIdentity: 'Apple Development: -Your-Developer-Name-'
Expand All @@ -125,7 +125,7 @@ $ tidevice xctest -B com.facebook.wda.WebDriverAgent.Runner
[I 210127 11:40:24 _device:875] WebDriverAgent start successfully

# 修改监听端口为8200, 并显示调试日志
$ tidevice xctest -B com.facebook.wda.WebDriverAgent.Runner -e USE_PORT:8200 --debug
$ tidevice xcuitest -B com.facebook.wda.WebDriverAgent.Runner -e USE_PORT:8200 --debug
```

### Relay
Expand Down Expand Up @@ -180,7 +180,7 @@ Ref issue [#46](https://github.com/alibaba/taobao-iphone-device/issues/46)
执行方法

```bash
$ tidevice xctest --bundle-id philhuang.testXCTestUITests.xctrunner --target-bundle-id philhuang.testXCTest
$ tidevice xcuitest --bundle-id philhuang.testXCTestUITests.xctrunner --target-bundle-id philhuang.testXCTest
# ... 省略一部分不重要的信息 ...
[I 210301 15:37:07 _device:887] logProcess: 2021-03-01 15:37:07.924620+0800 testXCTestUITests-Runner[81644:13765443] Running tests...
[I 210301 15:37:07 _device:984] Test runner ready detected
Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Demo <https://github.com/FeiHuang93/XCTest-Demo>
- `philhuang.testXCTest` is the app to test

```bash
$ tidevice xctest --bundle-id philhuang.testXCTestUITests.xctrunner --target-bundle-id philhuang.testXCTest
$ tidevice xcuitest --bundle-id philhuang.testXCTestUITests.xctrunner --target-bundle-id philhuang.testXCTest
# ... ignore some not important part ...
[I 210301 15:37:07 _device:887] logProcess: 2021-03-01 15:37:07.924620+0800 testXCTestUITests-Runner[81644:13765443] Running tests...
[I 210301 15:37:07 _device:984] Test runner ready detected
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ retry
simplejson
tabulate
logzero
loguru
deprecation

# hotfix for HTTPConnectino.request() get an unexpected keyword argument 'chunked'
urllib3<2

# hotfix for ValueError: Invalid version. The only valid version for X509Req is 0.
# ref: https://github.com/certbot/certbot/issues/9722
pyOpenSSL<23.2.0
6 changes: 1 addition & 5 deletions tidevice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@
from ._perf import Performance, DataType
from .exceptions import *
from .datatypes import *
from ._proto import PROGRAM_NAME
from loguru import logger


logger.disable(PROGRAM_NAME)
from ._proto import PROGRAM_NAME
48 changes: 27 additions & 21 deletions tidevice/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
from collections import defaultdict
from datetime import datetime
from pprint import pformat, pprint
from typing import Optional, Union
from typing import Optional

import requests
from logzero import setup_logger
from tabulate import tabulate
from loguru import logger as ulogger

from ._device import Device
from ._imagemounter import cache_developer_image
Expand All @@ -31,13 +30,13 @@
from ._proto import LOG, MODELS, PROGRAM_NAME, ConnectionType
from ._relay import relay
from ._usbmux import Usbmux
from ._utils import get_app_dir, get_binary_by_name, is_atty
from ._utils import is_atty
from ._version import __version__
from ._wdaproxy import WDAService
from .exceptions import MuxError, MuxServiceError, ServiceError

um: Usbmux = None # Usbmux
logger = logging.getLogger(PROGRAM_NAME)
logger = logging.getLogger(__name__)


def _complete_udid(udid: Optional[str] = None) -> str:
Expand Down Expand Up @@ -245,13 +244,12 @@ def cmd_wait_for_device(args):
break


def cmd_xctest(args: argparse.Namespace):
def cmd_xcuitest(args: argparse.Namespace):
"""
Run XCTest required WDA installed.
"""
if args.debug:
ulogger.enable(PROGRAM_NAME)
setup_logger(LOG.xctest, level=logging.DEBUG)
setup_logger(LOG.xcuitest, level=logging.DEBUG)

d = _udid2device(args.udid)
env = {}
Expand All @@ -276,13 +274,18 @@ def cmd_xctest(args: argparse.Namespace):
target_app_args = args.target_app_args.split(',')
logger.info("Target app args: %s", target_app_args)

d.xctest(args.bundle_id,
tests_to_run = set()
if args.tests_to_run:
tests_to_run = set(args.tests_to_run.strip().split(','))
logger.info("Target app args: %s", target_app_args)

d.runwda(args.bundle_id,
target_bundle_id=args.target_bundle_id,
logger=setup_logger(level=logging.INFO),
test_runner_env=env,
test_runner_args=test_runner_args,
target_app_env=target_app_env,
target_app_args=target_app_args)
target_app_args=target_app_args,
tests_to_run=tests_to_run)


def cmd_screenshot(args: argparse.Namespace):
Expand Down Expand Up @@ -462,7 +465,7 @@ def cmd_developer(args: argparse.Namespace):
print(d.imagemounter.lookup())
else:
d = _udid2device(args.udid)
d.mount_developer_image()
d.mount_developer_image(reboot_ok=args.reboot_ok)
return


Expand Down Expand Up @@ -853,9 +856,9 @@ def cmd_test(args: argparse.Namespace):
],
help="relay phone inner port to pc, same as iproxy"),
dict(
action=cmd_xctest,
command="xctest",
aliases=['xcuitest'],
action=cmd_xcuitest,
command="xcuitest",
aliases=['xctest'],
flags=[
dict(args=['--debug'], action='store_true', help='show debug log'),
dict(args=['-B', '--bundle_id', '--bundle-id'],
Expand All @@ -876,6 +879,8 @@ def cmd_test(args: argparse.Namespace):
help="set env to target app with format key:value, support multi --target-app-env"),
dict(args=['--target-app-args'],
help="set command line args to target app with a comma-separated list of strings"),
dict(args=['--tests-to-run'],
help="specify a set of test classes or test methods to run, format: a comma-separated list of Test-Class-Name[/Test-Method-Name]"),
],
help="run XCTest (XCUITest)"),
dict(
Expand Down Expand Up @@ -943,7 +948,10 @@ def cmd_test(args: argparse.Namespace):
help="list mount information"),
dict(args=['--download-all'],
action="store_true",
help="download all developer to local")
help="download all developer to local"),
dict(args=["-r", "--reboot-ok"],
action="store_true",
help="auto reboot device to enable developer mode"),
],
help="mount developer image to device"),
dict(action=cmd_pair, command='pair', help='pair device'),
Expand Down Expand Up @@ -1026,12 +1034,10 @@ def main():
# show_upgrade_message()
return

if args.trace:
ulogger.enable(PROGRAM_NAME)

# log setup
setup_logger(LOG.main,
level=logging.DEBUG if os.getenv("DEBUG") in ("1", "on", "true") else logging.INFO)
if args.trace or os.getenv("TIDEVICE_DEBUG") in ("1", "on", "true"):
setup_logger(LOG.root, level=logging.DEBUG)
else:
setup_logger(LOG.root, level=logging.INFO)

global um
um = Usbmux(args.socket)
Expand Down
8 changes: 6 additions & 2 deletions tidevice/_crash.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import pathlib
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Created on Thu Oct 19 2023 16:03:14 by codeskyblue
"""

from genericpath import isdir
from ._sync import Sync
Expand All @@ -7,7 +11,7 @@
from ._safe_socket import PlistSocketProxy


logger = logging.getLogger(LOG.main)
logger = logging.getLogger(__name__)

# Ref: https://github.com/libimobiledevice/libimobiledevice/blob/master/tools/idevicecrashreport.c

Expand Down
Loading

0 comments on commit 7af14b3

Please sign in to comment.