qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [4/8] qpid-proton git commit: WI: print tests 3
Date Tue, 26 Jan 2016 23:45:11 GMT
WI: print tests 3


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e494040d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e494040d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e494040d

Branch: refs/heads/fix
Commit: e494040d665a835a2e35da3ffcfa47b740811f00
Parents: 3682984
Author: Alan Conway <aconway@redhat.com>
Authored: Tue Jan 26 15:14:44 2016 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Tue Jan 26 15:14:44 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/example_test.py | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e494040d/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index b3b9c72..d815bbc 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -28,6 +28,9 @@ import platform
 from os.path import dirname as dirname
 from threading import Thread, Event
 
+# FIXME aconway 2016-01-26:
+os.environ["PN_TRACE_FRM"] = "0"
+
 class ExampleTest(unittest.TestCase):
     """Base class for tests that run example programs and verify their output."""
 
@@ -36,12 +39,17 @@ class ExampleTest(unittest.TestCase):
         self.procs = []
 
     def tearDown(self):
-        print >>sys.stderr, "FIXME tearDown", self.id()
-        for p in self.procs:
-            try:
-                print >>sys.stderr, "FIXME kill", p.args
-                p.kill()
-            except: pass
+        try:
+            print >>sys.stderr, "FIXME tearDown", self.id()
+            for p in self.procs:
+                try:
+                    print >>sys.stderr, "FIXME kill", id(p), p.args
+                    p.kill()
+                except Exception, e:
+                    print >>sys.stderr, "FIXME kill ex ", id(p), e
+                    pass
+        finally:
+            print >>sys.stderr, "FIXME tearDown done"
 
     def cmdline(self, *args):
         """Adjust executable name args[0] for windows and/or valgrind"""
@@ -80,9 +88,9 @@ class ExampleTest(unittest.TestCase):
         return "127.0.0.1:%s" % p
 
     def background(self, *args):
-        """Run executable in the backround, return the popen"""
-        print >>sys.stderr, "FIXME backround", args
+        """Run executable in the background, return the popen"""
         p = Popen(self.cmdline(*args), stdout=PIPE, stderr=sys.stderr)
+        print >>sys.stderr, "FIXME backround", args, id(p)
         p.args = args               # Save arguments for debugging output
         self.procs.append(p)
         return p
@@ -91,24 +99,32 @@ class ExampleTest(unittest.TestCase):
         """Wait for executable to exit and verify status, return the output"""
         print >>sys.stderr, "FIXME verify", p.args
         try:
-            out, err = p.communicate()
-        except Exception as e:
-            raise Exception("Error running %s: %s", p.args, e)
-        if p.returncode:
-            raise Exception("""%s exit code %s
-    vvvvvvvvvvvvvvvv
-    %s
-    ^^^^^^^^^^^^^^^^
-    """ % (p.args, p.returncode, out))
-        if platform.system() == "Windows":
-            # Just \n please
-            if out:
-                out = out.translate(None, '\r')
-        return out
+            try:
+                out, err = p.communicate()
+            except Exception as e:
+                raise Exception("Error running %s: %s", p.args, e)
+            if p.returncode:
+                raise Exception("""%s exit code %s
+        vvvvvvvvvvvvvvvv
+        %s
+        ^^^^^^^^^^^^^^^^
+        """ % (p.args, p.returncode, out))
+            if platform.system() == "Windows":
+                # Just \n please
+                if out:
+                    out = out.translate(None, '\r')
+            return out
+        except Exception, e:
+            print >>sys.stderr, "FIXME verify: ", e
+        finally:
+            print >>sys.stderr, "FIXME verify done"
 
     def execute(self, *args):
         """Run a program, verify its exit status and return its output"""
-        return self.verify(self.background(*args))
+        p = self.background(*args)
+        out = self.verify(p)
+        self.procs.remove(p)
+        return out
 
 class BrokerExampleTest(ExampleTest):
     """


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message