1 |
commit: 0552665627bf85f01ae28cafebc885dcb6d26ef3 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 8 07:31:08 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 8 07:31:50 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=05526656 |
7 |
|
8 |
SimpleEmergeTestCase: run tests in coroutine method |
9 |
|
10 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
11 |
|
12 |
lib/portage/tests/emerge/test_simple.py | 25 ++++++++++++++++++------- |
13 |
1 file changed, 18 insertions(+), 7 deletions(-) |
14 |
|
15 |
diff --git a/lib/portage/tests/emerge/test_simple.py b/lib/portage/tests/emerge/test_simple.py |
16 |
index f5cd6f3d2..6aafff180 100644 |
17 |
--- a/lib/portage/tests/emerge/test_simple.py |
18 |
+++ b/lib/portage/tests/emerge/test_simple.py |
19 |
@@ -1,4 +1,4 @@ |
20 |
-# Copyright 2011-2019 Gentoo Authors |
21 |
+# Copyright 2011-2020 Gentoo Authors |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
|
24 |
import subprocess |
25 |
@@ -14,6 +14,9 @@ from portage.tests import TestCase |
26 |
from portage.tests.resolver.ResolverPlayground import ResolverPlayground |
27 |
from portage.util import (ensure_dirs, find_updated_config_files, |
28 |
shlex_split) |
29 |
+from portage.util.futures import asyncio |
30 |
+from portage.util.futures.compat_coroutine import coroutine |
31 |
+ |
32 |
|
33 |
class SimpleEmergeTestCase(TestCase): |
34 |
|
35 |
@@ -201,6 +204,15 @@ call_has_and_best_version() { |
36 |
|
37 |
playground = ResolverPlayground( |
38 |
ebuilds=ebuilds, installed=installed, debug=debug) |
39 |
+ |
40 |
+ loop = asyncio._wrap_loop() |
41 |
+ loop.run_until_complete(asyncio.ensure_future( |
42 |
+ self._async_test_simple(playground, metadata_xml_files), loop=loop)) |
43 |
+ |
44 |
+ @coroutine |
45 |
+ def _async_test_simple(self, playground, metadata_xml_files): |
46 |
+ |
47 |
+ debug = playground.debug |
48 |
settings = playground.settings |
49 |
eprefix = settings["EPREFIX"] |
50 |
eroot = settings["EROOT"] |
51 |
@@ -487,15 +499,14 @@ move dev-util/git dev-vcs/git |
52 |
else: |
53 |
local_env = env |
54 |
|
55 |
- proc = subprocess.Popen(args, |
56 |
- env=local_env, stdout=stdout) |
57 |
+ proc = yield asyncio.create_subprocess_exec(*args, |
58 |
+ env=local_env, stderr=None, stdout=stdout) |
59 |
|
60 |
if debug: |
61 |
- proc.wait() |
62 |
+ yield proc.wait() |
63 |
else: |
64 |
- output = proc.stdout.readlines() |
65 |
- proc.wait() |
66 |
- proc.stdout.close() |
67 |
+ output, _err = yield proc.communicate() |
68 |
+ yield proc.wait() |
69 |
if proc.returncode != os.EX_OK: |
70 |
for line in output: |
71 |
sys.stderr.write(_unicode_decode(line)) |