]> arthur.barton.de Git - bup.git/commitdiff
helpers.py: use returncode to get the subprocess exit code in readpipe().
authorRob Browning <rlb@defaultvalue.org>
Fri, 2 May 2014 17:32:07 +0000 (12:32 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 2 May 2014 17:35:17 +0000 (12:35 -0500)
Hello?  It's returncode, not retcode -- and how about a test?

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py
lib/bup/t/thelpers.py

index a56f656d988df1207c53f73ec50087ff04df0f1b..7d03e262d9d85de3e464dfce8fc2bf6daac1284a 100644 (file)
@@ -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
 
 
index 2e113c897e3f91ab73abcee89af0f2d3fb56638a..fd041ffb792e3586259581dd70719ccf7b4c867a 100644 (file)
@@ -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")