From 171b430afbfb6da0d98cd70b2831b20971371b66 Mon Sep 17 00:00:00 2001
From: nejucomo <nejucomo@gmail.com>
Date: Sat, 7 Jun 2008 00:07:18 -0700
Subject: [PATCH] fuse: runtests: Wrap OSError exceptions which are test
 failures.

---
 contrib/fuse/runtests.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/contrib/fuse/runtests.py b/contrib/fuse/runtests.py
index c1908220..fe47983d 100644
--- a/contrib/fuse/runtests.py
+++ b/contrib/fuse/runtests.py
@@ -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'
 
-- 
2.45.2