diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-08-16 08:36:46 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-16 08:36:46 (GMT) |
| commit | cf6d14b96656baa911fa7a793ffa085e1ce6f328 (patch) | |
| tree | 59c7413ac079a5323eed683cac6e321081c27930 /Lib/_android_support.py | |
| parent | 0dd89a7f4054bb68e7c201c20f939ba03732bde9 (diff) | |
| download | cpython-cf6d14b96656baa911fa7a793ffa085e1ce6f328.zip cpython-cf6d14b96656baa911fa7a793ffa085e1ce6f328.tar.gz cpython-cf6d14b96656baa911fa7a793ffa085e1ce6f328.tar.bz2 | |
[3.13] gh-116622: Add Android test script (GH-121595) (#123061)
gh-116622: Add Android test script (GH-121595)
Adds a script for running the test suite on Android emulator devices. Starting
with a fresh install of the Android Commandline tools; the script manages
installing other requirements, starting the emulator (if required), and
retrieving results from that emulator.
(cherry picked from commit f84cce6f2588c6437d69a30856d7c4ba00b70ae0)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
Diffstat (limited to 'Lib/_android_support.py')
| -rw-r--r-- | Lib/_android_support.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/_android_support.py b/Lib/_android_support.py index d5d13ec..066e547 100644 --- a/Lib/_android_support.py +++ b/Lib/_android_support.py @@ -31,15 +31,17 @@ def init_streams(android_log_write, stdout_prio, stderr_prio): logcat = Logcat(android_log_write) sys.stdout = TextLogStream( - stdout_prio, "python.stdout", errors=sys.stdout.errors) + stdout_prio, "python.stdout", sys.stdout.fileno(), + errors=sys.stdout.errors) sys.stderr = TextLogStream( - stderr_prio, "python.stderr", errors=sys.stderr.errors) + stderr_prio, "python.stderr", sys.stderr.fileno(), + errors=sys.stderr.errors) class TextLogStream(io.TextIOWrapper): - def __init__(self, prio, tag, **kwargs): + def __init__(self, prio, tag, fileno=None, **kwargs): kwargs.setdefault("encoding", "UTF-8") - super().__init__(BinaryLogStream(prio, tag), **kwargs) + super().__init__(BinaryLogStream(prio, tag, fileno), **kwargs) self._lock = RLock() self._pending_bytes = [] self._pending_bytes_count = 0 @@ -98,9 +100,10 @@ class TextLogStream(io.TextIOWrapper): class BinaryLogStream(io.RawIOBase): - def __init__(self, prio, tag): + def __init__(self, prio, tag, fileno=None): self.prio = prio self.tag = tag + self._fileno = fileno def __repr__(self): return f"<BinaryLogStream {self.tag!r}>" @@ -122,6 +125,12 @@ class BinaryLogStream(io.RawIOBase): logcat.write(self.prio, self.tag, b) return len(b) + # This is needed by the test suite --timeout option, which uses faulthandler. + def fileno(self): + if self._fileno is None: + raise io.UnsupportedOperation("fileno") + return self._fileno + # When a large volume of data is written to logcat at once, e.g. when a test # module fails in --verbose3 mode, there's a risk of overflowing logcat's own |
