From: Zac Medico Date: Mon, 5 Sep 2011 21:43:42 +0000 (-0700) Subject: tests/emerge: add a debug mode that shows stdout X-Git-Tag: v2.2.0_alpha54~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c39406adff994d6483a08edf59c9bf6b84191f68;p=portage.git tests/emerge: add a debug mode that shows stdout --- 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,))