]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/t/thelpers.py
helpers.py: use returncode to get the subprocess exit code in readpipe().
[bup.git] / lib / bup / t / thelpers.py
index e4e24cdd151dc8b64df165e23c2641453ba1d7b6..fd041ffb792e3586259581dd70719ccf7b4c867a 100644 (file)
@@ -48,10 +48,42 @@ def test_stripped_path_components():
              [('', '/foo/bar/baz')])
     WVEXCEPT(Exception, stripped_path_components, 'foo', [])
 
+
 @wvtest
 def test_grafted_path_components():
     WVPASSEQ(grafted_path_components([('/chroot', '/')], '/foo'),
              [('', '/'), ('foo', '/foo')])
-    WVPASSEQ(grafted_path_components([('/foo/bar', '')], '/foo/bar/baz/bax'),
-             [('', None), ('baz', None), ('bax', '/foo/bar/baz/bax')])
+    WVPASSEQ(grafted_path_components([('/foo/bar', '/')], '/foo/bar/baz/bax'),
+             [('', '/foo/bar'),
+              ('baz', '/foo/bar/baz'),
+              ('bax', '/foo/bar/baz/bax')])
+    WVPASSEQ(grafted_path_components([('/foo/bar/baz', '/bax')],
+                                     '/foo/bar/baz/1/2'),
+             [('', None),
+              ('bax', '/foo/bar/baz'),
+              ('1', '/foo/bar/baz/1'),
+              ('2', '/foo/bar/baz/1/2')])
+    WVPASSEQ(grafted_path_components([('/foo', '/bar/baz/bax')],
+                                     '/foo/bar'),
+             [('', None),
+              ('bar', None),
+              ('baz', None),
+              ('bax', '/foo'),
+              ('bar', '/foo/bar')])
+    WVPASSEQ(grafted_path_components([('/foo/bar/baz', '/a/b/c')],
+                                     '/foo/bar/baz'),
+             [('', None), ('a', None), ('b', None), ('c', '/foo/bar/baz')])
+    WVPASSEQ(grafted_path_components([('/', '/a/b/c/')], '/foo/bar'),
+             [('', 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")