summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-05 14:43:42 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-05 14:43:42 -0700
commitc39406adff994d6483a08edf59c9bf6b84191f68 (patch)
treebae8e08479c4b92d281299800f27d849538b1cd3 /pym
parent1843d7f56d682003b09189c142899b2550427a28 (diff)
downloadportage-c39406adff994d6483a08edf59c9bf6b84191f68.tar.gz
portage-c39406adff994d6483a08edf59c9bf6b84191f68.tar.bz2
portage-c39406adff994d6483a08edf59c9bf6b84191f68.zip
tests/emerge: add a debug mode that shows stdout
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/tests/emerge/test_simple.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py
index 00c395d01..20cfa8f59 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -17,6 +17,8 @@ class SimpleEmergeTestCase(TestCase):
def testSimple(self):
+ debug = False
+
install_something = """
S="${WORKDIR}"
src_install() {
@@ -214,15 +216,30 @@ src_install() {
for cp, xml_data in metadata_xml_files:
with open(os.path.join(portdir, cp, "metadata.xml"), 'w') as f:
f.write(playground.metadata_xml_template % xml_data)
+
+ if debug:
+ # The subprocess inherits both stdout and stderr, for
+ # debugging purposes.
+ stdout = None
+ else:
+ # The subprocess inherits stderr so that any warnings
+ # triggered by python -Wd will be visible.
+ stdout = subprocess.PIPE
+
for args in test_commands:
+
proc = subprocess.Popen(args,
- env=env, stdout=subprocess.PIPE)
- output = proc.stdout.readlines()
- proc.wait()
- proc.stdout.close()
- if proc.returncode != os.EX_OK:
- for line in output:
- sys.stderr.write(_unicode_decode(line))
+ env=env, stdout=stdout)
+
+ if debug:
+ proc.wait()
+ else:
+ output = proc.stdout.readlines()
+ proc.wait()
+ proc.stdout.close()
+ if proc.returncode != os.EX_OK:
+ for line in output:
+ sys.stderr.write(_unicode_decode(line))
self.assertEqual(os.EX_OK, proc.returncode,
"emerge failed with args %s" % (args,))