]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse: runtests: Wrap OSError exceptions which are test failures.
authornejucomo <nejucomo@gmail.com>
Sat, 7 Jun 2008 07:07:18 +0000 (00:07 -0700)
committernejucomo <nejucomo@gmail.com>
Sat, 7 Jun 2008 07:07:18 +0000 (00:07 -0700)
contrib/fuse/runtests.py

index c1908220c43460597d70d13162abe0281800fa59..fe47983d23e6ac20950474f37102883249e60d1f 100644 (file)
@@ -283,7 +283,7 @@ class SystemTest (object):
             raise TestFailure('Attached test directory not found: %r', testdir)
             
     def test_empty_directory_listing(self, testcap, testdir):
-        listing = os.listdir(testdir)
+        listing = wrap_os_error(os.listdir, testdir)
         if listing:
             raise TestFailure('Expected empty directory, found: %r', listing)
     
@@ -308,14 +308,14 @@ class SystemTest (object):
 
         names.sort()
             
-        listing = os.listdir(testdir)
+        listing = wrap_os_error(os.listdir, testdir)
         listing.sort()
         if listing != names:
             tmpl = 'Expected directory list containing %r but fuse gave %r'
             raise TestFailure(tmpl, names, listing)
 
         for file, size in filesizes.items():
-            st = os.stat(os.path.join(testdir, file))
+            st = wrap_os_error(os.stat, os.path.join(testdir, file))
             if st.st_size != size:
                 tmpl = 'Expected %r size of %r but fuse returned %r'
                 raise TestFailure(tmpl, file, size, st.st_size)
@@ -497,6 +497,13 @@ def gather_output(*args, **kwargs):
     return (exitcode, output)
     
 
+def wrap_os_error(meth, *args):
+    try:
+        return meth(*args)
+    except os.error, e:
+        raise TestFailure('%s', e)
+
+
 ExpectedCreationOutput = r'(introducer|client) created in (?P<path>.*?)\n'
 ExpectedStartOutput = r'STARTING (?P<path>.*?)\n(introducer|client) node probably started'