From: Rob Browning Date: Fri, 2 May 2014 17:32:07 +0000 (-0500) Subject: helpers.py: use returncode to get the subprocess exit code in readpipe(). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2b0cffb5ac1f899568f711e10a027b8485c650b6;p=packages%2Fb%2Fbup.git helpers.py: use returncode to get the subprocess exit code in readpipe(). Hello? It's returncode, not retcode -- and how about a test? Signed-off-by: Rob Browning --- diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index a56f656..7d03e26 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -183,7 +183,7 @@ def readpipe(argv): out, err = p.communicate() if p.returncode != 0: raise Exception('subprocess %r failed with status %d' - % (' '.join(argv), p.retcode)) + % (' '.join(argv), p.returncode)) return out diff --git a/lib/bup/t/thelpers.py b/lib/bup/t/thelpers.py index 2e113c8..fd041ff 100644 --- a/lib/bup/t/thelpers.py +++ b/lib/bup/t/thelpers.py @@ -77,3 +77,13 @@ def test_grafted_path_components(): [('', None), ('a', None), ('b', None), ('c', '/'), ('foo', '/foo'), ('bar', '/foo/bar')]) WVEXCEPT(Exception, grafted_path_components, 'foo', []) + + +@wvtest +def test_readpipe(): + x = readpipe(['echo', '42']) + WVPASSEQ(x, '42\n') + try: + readpipe(['bash', '-c', 'exit 42']) + except Exception, ex: + WVPASSEQ(str(ex), "subprocess 'bash -c exit 42' failed with status 42")