[Piglit] [Patch v2 8/8] igt.py: Use subprocess.check_output instead of subprocess.Popen
Dylan Baker
baker.dylan.c at gmail.com
Mon Jan 26 14:01:26 PST 2015
On Monday, January 26, 2015 13:42:27 Ian Romanick wrote:
> On 01/26/2015 11:28 AM, Dylan Baker wrote:
> > This is somewhat simpler way to handle this, since check_output monitors
> > only stdout, and hides stderr, and it gives us a lovely exception if the
> > returncode isn't 0, which allows us to completely bypass the error
> > checking code if there is no error.
> >
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> > ---
> > tests/igt.py | 34 +++++++++++++++-------------------
> > 1 file changed, 15 insertions(+), 19 deletions(-)
> >
> > diff --git a/tests/igt.py b/tests/igt.py
> > index ca8f295..f4a49ac 100644
> > --- a/tests/igt.py
> > +++ b/tests/igt.py
> > @@ -43,7 +43,6 @@ from framework.profile import TestProfile, Test
> > __all__ = ['profile']
> >
> >
> > -
>
> Should this whitespace change have been in patch 3?
Oops, this was accidentally inserted in the docstrings patch. Fixed
locally.
>
> > def check_environment():
> > """Check that the environment that piglit is running in is appropraite.
> >
> > @@ -139,27 +138,24 @@ def list_tests(listname):
> >
> > def add_subtest_cases(test):
> > """Get subtest instances."""
> > - proc = subprocess.Popen(
> > - [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
> > - stdout=subprocess.PIPE,
> > - env=os.environ.copy(),
> > - universal_newlines=True)
> > - out, _ = proc.communicate()
> > -
> > - # a return code of 79 indicates there are no subtests
> > - if proc.returncode == 79:
> > - profile.test_list[grouptools.join('igt', test)] = IGTTest(test)
> > - return
> > + try:
> > + out = subprocess.check_output(
> > + [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
> > + env=os.environ.copy(),
> > + universal_newlines=True)
> > + except subprocess.CalledProcessError as e:
> > + # a return code of 79 indicates there are no subtests
> > + if e.returncode == 79:
> > + profile.test_list[grouptools.join('igt', test)] = IGTTest(test)
> > + elif e.returncode != 0:
> > + print("Error: Could not list subtests for " + test)
> > + else:
> > + raise
> >
> > - if proc.returncode != 0:
> > - print("Error: Could not list subtests for " + test)
> > + # If we reach here there are no subtests.
> > return
> >
> > - subtests = out.split("\n")
> > -
> > - for subtest in subtests:
> > - if subtest == "":
> > - continue
> > + for subtest in (s for s in out.splitlines() if s):
> > profile.test_list[grouptools.join('igt', test, subtest)] = \
> > IGTTest(test, ['--run-subtest', subtest])
> >
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150126/884af7f7/attachment.sig>
More information about the Piglit
mailing list