1 |
commit: c39406adff994d6483a08edf59c9bf6b84191f68 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 5 21:43:42 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 5 21:43:42 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c39406ad |
7 |
|
8 |
tests/emerge: add a debug mode that shows stdout |
9 |
|
10 |
--- |
11 |
pym/portage/tests/emerge/test_simple.py | 31 ++++++++++++++++++++++++------- |
12 |
1 files changed, 24 insertions(+), 7 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py |
15 |
index 00c395d..20cfa8f 100644 |
16 |
--- a/pym/portage/tests/emerge/test_simple.py |
17 |
+++ b/pym/portage/tests/emerge/test_simple.py |
18 |
@@ -17,6 +17,8 @@ class SimpleEmergeTestCase(TestCase): |
19 |
|
20 |
def testSimple(self): |
21 |
|
22 |
+ debug = False |
23 |
+ |
24 |
install_something = """ |
25 |
S="${WORKDIR}" |
26 |
src_install() { |
27 |
@@ -214,15 +216,30 @@ src_install() { |
28 |
for cp, xml_data in metadata_xml_files: |
29 |
with open(os.path.join(portdir, cp, "metadata.xml"), 'w') as f: |
30 |
f.write(playground.metadata_xml_template % xml_data) |
31 |
+ |
32 |
+ if debug: |
33 |
+ # The subprocess inherits both stdout and stderr, for |
34 |
+ # debugging purposes. |
35 |
+ stdout = None |
36 |
+ else: |
37 |
+ # The subprocess inherits stderr so that any warnings |
38 |
+ # triggered by python -Wd will be visible. |
39 |
+ stdout = subprocess.PIPE |
40 |
+ |
41 |
for args in test_commands: |
42 |
+ |
43 |
proc = subprocess.Popen(args, |
44 |
- env=env, stdout=subprocess.PIPE) |
45 |
- output = proc.stdout.readlines() |
46 |
- proc.wait() |
47 |
- proc.stdout.close() |
48 |
- if proc.returncode != os.EX_OK: |
49 |
- for line in output: |
50 |
- sys.stderr.write(_unicode_decode(line)) |
51 |
+ env=env, stdout=stdout) |
52 |
+ |
53 |
+ if debug: |
54 |
+ proc.wait() |
55 |
+ else: |
56 |
+ output = proc.stdout.readlines() |
57 |
+ proc.wait() |
58 |
+ proc.stdout.close() |
59 |
+ if proc.returncode != os.EX_OK: |
60 |
+ for line in output: |
61 |
+ sys.stderr.write(_unicode_decode(line)) |
62 |
|
63 |
self.assertEqual(os.EX_OK, proc.returncode, |
64 |
"emerge failed with args %s" % (args,)) |