Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-116622: Add Android test script#121595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
103f97efb1b54ab99b7696f07a39c71f3cfcd27b0f6bbdfdae7386894561930b519874b3ed4c732f79d764715125c3967ecb60cc4b0758422266e82397d20b8e80dd2709061e756bc136b2ed6c05a26cca0dd03b2d53549c9d5bf5706a1daae3a460cf15b99c56373a1e89e5891f356bbdaad24ca2bae27a3d674f4b06f547c02a5602fbdd305d7862ad8e4bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,7 +25,7 @@ you don't already have the SDK, here's how to install it: | ||
| The `android.py` script also requires the following commands to be on the `PATH`: | ||
| * `curl` | ||
| * `java` | ||
| * `java` (or set the `JAVA_HOME` environment variable) | ||
| * `tar` | ||
| * `unzip` | ||
| @@ -80,18 +80,54 @@ call. For example, if you want a pydebug build that also caches the results from | ||
| ## Testing | ||
| To run the Python test suite on Android: | ||
| * Install Android Studio, if you don't already have it. | ||
| * Follow the instructions in the previous section to build all supported | ||
| architectures. | ||
| * Run `./android.py setup-testbed` to download the Gradle wrapper. | ||
| * Open the `testbed` directory in Android Studio. | ||
| * In the *Device Manager* dock, connect a device or start an emulator. | ||
| Then select it from the drop-down list in the toolbar. | ||
| * Click the "Run" button in the toolbar. | ||
| * The testbed app displays nothing on screen while running. To see its output, | ||
| open the [Logcat window](https://developer.android.com/studio/debug/logcat). | ||
| To run specific tests, or pass any other arguments to the test suite, edit the | ||
| command line in testbed/app/src/main/python/main.py. | ||
| The tests can be run on Linux, macOS, or Windows, although on Windows you'll | ||
| have to build the `cross-build/HOST` subdirectory on one of the other platforms | ||
| and copy it over. | ||
| The test suite can usually be run on a device with 2 GB of RAM, though for some | ||
| configurations or test orders you may need to increase this. As of Android | ||
| Studio Koala, 2 GB is the default for all emulators, although the user interface | ||
| may indicate otherwise. The effective setting is `hw.ramSize` in | ||
| ~/.android/avd/*.avd/hardware-qemu.ini, whereas Android Studio displays the | ||
| value from config.ini. Changing the value in Android Studio will update both of | ||
| these files. | ||
| Before running the test suite, follow the instructions in the previous section | ||
| to build the architecture you want to test. Then run the test script in one of | ||
| the following modes: | ||
| * In `--connected` mode, it runs on a device or emulator you have already | ||
| connected to the build machine. List the available devices with | ||
| `$ANDROID_HOME/platform-tools/adb devices -l`, then pass a device ID to the | ||
| script like this: | ||
| ```sh | ||
| ./android.py test --connected emulator-5554 | ||
| ``` | ||
| * In `--managed` mode, it uses a temporary headless emulator defined in the | ||
| `managedDevices` section of testbed/app/build.gradle.kts. This mode is slower, | ||
| but more reproducible. | ||
| We currently define two devices: `minVersion` and `maxVersion`, corresponding | ||
| to our minimum and maximum supported Android versions. For example: | ||
| ```sh | ||
| ./android.py test --managed maxVersion | ||
| ``` | ||
| By default, the only messages the script will show are Python's own stdout and | ||
| stderr. Add the `-v` option to also show Gradle output, and non-Python logcat | ||
| messages. | ||
freakboy3742 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Any other arguments on the `android.py test` command line will be passed through | ||
| to `python -m test` – use `--` to separate them from android.py's own options. | ||
| See the [Python Developer's | ||
| Guide](https://devguide.python.org/testing/run-write-tests/) for common options | ||
| – most of them will work on Android, except for those that involve subprocesses, | ||
| such as `-j`. | ||
freakboy3742 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Every time you run `android.py test`, changes in pure-Python files in the | ||
| repository's `Lib` directory will be picked up immediately. Changes in C files, | ||
| and architecture-specific files such as sysconfigdata, will not take effect | ||
| until you re-run `android.py make-host` or `build`. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.