qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [2/2] qpid-proton git commit: NO-JIRA: c++ examples, fix broken "skipUnless" workaround
Date Mon, 18 Sep 2017 18:19:11 GMT
NO-JIRA: c++ examples, fix broken "skipUnless" workaround

Revert to previous "try/except NotFoundError" approach.


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

Branch: refs/heads/master
Commit: 06de5185d833ae7e6f35de00b73b66afe8d707df
Parents: 6e05967
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Sep 18 13:58:03 2017 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Sep 18 14:19:04 2017 -0400

----------------------------------------------------------------------
 examples/cpp/example_test.py                    | 84 +++++++++++---------
 .../bindings/cpp/include/proton/returned.hpp    |  1 -
 tools/py/proctest.py                            | 17 ----
 3 files changed, 45 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06de5185/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 6dd8587..8c005c6 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -33,29 +33,29 @@ from string import Template
 createdSASLDb = False
 
 def _cyrusSetup(conf_dir):
-  """Write out simple SASL config.tests
-  """
-  saslpasswd = os.getenv('SASLPASSWD') or find_file('saslpasswd2', os.getenv('PATH'))
-  if saslpasswd:
-    t = Template("""sasldb_path: ${db}
+    """Write out simple SASL config.tests
+    """
+    saslpasswd = os.getenv('SASLPASSWD') or find_file('saslpasswd2', os.getenv('PATH'))
+    if saslpasswd:
+        t = Template("""sasldb_path: ${db}
 mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
 """)
-    abs_conf_dir = os.path.abspath(conf_dir)
-    call(args=['rm','-rf',abs_conf_dir])
-    os.mkdir(abs_conf_dir)
-    db = os.path.join(abs_conf_dir,'proton.sasldb')
-    conf = os.path.join(abs_conf_dir,'proton-server.conf')
-    f = open(conf, 'w')
-    f.write(t.substitute(db=db))
-    f.close()
-
-    cmd_template = Template("echo password | ${saslpasswd} -c -p -f ${db} -u proton user")
-    cmd = cmd_template.substitute(db=db, saslpasswd=saslpasswd)
-    call(args=cmd, shell=True)
-
-    os.environ['PN_SASL_CONFIG_PATH'] = abs_conf_dir
-    global createdSASLDb
-    createdSASLDb = True
+        abs_conf_dir = os.path.abspath(conf_dir)
+        call(args=['rm','-rf',abs_conf_dir])
+        os.mkdir(abs_conf_dir)
+        db = os.path.join(abs_conf_dir,'proton.sasldb')
+        conf = os.path.join(abs_conf_dir,'proton-server.conf')
+        f = open(conf, 'w')
+        f.write(t.substitute(db=db))
+        f.close()
+
+        cmd_template = Template("echo password | ${saslpasswd} -c -p -f ${db} -u proton user")
+        cmd = cmd_template.substitute(db=db, saslpasswd=saslpasswd)
+        call(args=cmd, shell=True)
+
+        os.environ['PN_SASL_CONFIG_PATH'] = abs_conf_dir
+        global createdSASLDb
+        createdSASLDb = True
 
 # Globally initialize Cyrus SASL configuration
 _cyrusSetup('sasl_conf')
@@ -110,14 +110,14 @@ class ContainerExampleTest(BrokerTestCase):
 
     def test_simple_send_recv(self):
         self.assertMultiLineEqual("all messages confirmed\n",
-                         self.proc(["simple_send", "-a", self.addr]).wait_exit())
+                                  self.proc(["simple_send", "-a", self.addr]).wait_exit())
         self.assertMultiLineEqual(recv_expect("simple_recv", self.addr), self.proc(["simple_recv",
"-a", self.addr]).wait_exit())
 
     def test_simple_recv_send(self):
         # Start receiver first, then run sender"""
         recv = self.proc(["simple_recv", "-a", self.addr])
         self.assertMultiLineEqual("all messages confirmed\n",
-                         self.proc(["simple_send", "-a", self.addr]).wait_exit())
+                                  self.proc(["simple_send", "-a", self.addr]).wait_exit())
         self.assertMultiLineEqual(recv_expect("simple_recv", self.addr), recv.wait_exit())
 
 
@@ -127,7 +127,7 @@ class ContainerExampleTest(BrokerTestCase):
             recv = self.proc(["direct_recv", "-a", addr])
             recv.wait_re("listening")
             self.assertMultiLineEqual("all messages confirmed\n",
-                             self.proc(["simple_send", "-a", addr]).wait_exit())
+                                      self.proc(["simple_send", "-a", addr]).wait_exit())
             self.assertMultiLineEqual(recv_expect("direct_recv", addr), recv.wait_exit())
 
     def test_simple_recv_direct_send(self):
@@ -136,7 +136,7 @@ class ContainerExampleTest(BrokerTestCase):
             send = self.proc(["direct_send", "-a", addr])
             send.wait_re("listening")
             self.assertMultiLineEqual(recv_expect("simple_recv", addr),
-                             self.proc(["simple_recv", "-a", addr]).wait_exit())
+                                      self.proc(["simple_recv", "-a", addr]).wait_exit())
             self.assertMultiLineEqual(
                 "direct_send listening on %s\nall messages confirmed\n" % addr,
                 send.wait_exit())
@@ -145,7 +145,7 @@ class ContainerExampleTest(BrokerTestCase):
         server = self.proc(["server", "-a", self.addr])
         server.wait_re("connected")
         self.assertMultiLineEqual(CLIENT_EXPECT,
-                         self.proc(["client", "-a", self.addr]).wait_exit())
+                                  self.proc(["client", "-a", self.addr]).wait_exit())
 
     def test_request_response_direct(self):
         with TestPort() as tp:
@@ -153,7 +153,7 @@ class ContainerExampleTest(BrokerTestCase):
             server = self.proc(["server_direct", "-a", addr])
             server.wait_re("listening")
             self.assertMultiLineEqual(CLIENT_EXPECT,
-                             self.proc(["client", "-a", addr]).wait_exit())
+                                      self.proc(["client", "-a", addr]).wait_exit())
 
     def test_flow_control(self):
         want="""success: Example 1: simple credit
@@ -197,11 +197,13 @@ map{string(k1):int(42), symbol(k2):boolean(0)}
         self.assertTrue(len(out) > 0);
         self.assertEqual(["send"]*len(out), out)
 
-    @unittest.skipUnless(find_exes('scheduled_send'), "not a  C++11 build")
     def test_scheduled_send(self):
-        out = self.proc(["scheduled_send", "-a", self.addr+"scheduled_send", "-t", "0.1",
"-i", "0.001"]).wait_exit().split()
-        self.assertTrue(len(out) > 0);
-        self.assertEqual(["send"]*len(out), out)
+        try:
+            out = self.proc(["scheduled_send", "-a", self.addr+"scheduled_send", "-t", "0.1",
"-i", "0.001"]).wait_exit().split()
+            self.assertTrue(len(out) > 0);
+            self.assertEqual(["send"]*len(out), out)
+        except NotFoundError:
+          sys.stderr.write("SKIP: executable not found, not a C++11 build\n") 
 
     def test_message_properties(self):
         expect="""using put/get: short=123 string=foo symbol=sym
@@ -215,17 +217,21 @@ expected conversion_error: "unexpected type, want: uint got: string"
 """
         self.assertMultiLineEqual(expect, self.proc(["message_properties"]).wait_exit())
 
-    @unittest.skipUnless(find_exes('multithreaded_client'), "not a  C++11 build")
     def test_multithreaded_client(self):
-        got = self.proc(["multithreaded_client", self.addr, "examples", "10"], helgrind=True).wait_exit()
-        self.maxDiff = None
-        self.assertRegexpMatches(got, "10 messages sent and received");
+        try:
+            got = self.proc(["multithreaded_client", self.addr, "examples", "10"], helgrind=True).wait_exit()
+            self.maxDiff = None
+            self.assertRegexpMatches(got, "10 messages sent and received");
+        except NotFoundError:
+          sys.stderr.write("SKIP: executable not found, not a C++11 build\n") 
 
-    @unittest.skipUnless(find_exes('multithreaded_client_flow_control'), "not a  C++11 build")
     def test_multithreaded_client_flow_control(self):
-        got = self.proc(["multithreaded_client_flow_control", self.addr, "examples", "10",
"2"], helgrind=True).wait_exit()
-        self.maxDiff = None
-        self.assertRegexpMatches(got, "20 messages sent and received");
+        try:
+            got = self.proc(["multithreaded_client_flow_control", self.addr, "examples",
"10", "2"], helgrind=True).wait_exit()
+            self.maxDiff = None
+            self.assertRegexpMatches(got, "20 messages sent and received");
+        except NotFoundError:
+          sys.stderr.write("SKIP: executable not found, not a C++11 build\n") 
 
 class ContainerExampleSSLTest(BrokerTestCase):
     """Run the SSL container examples, verify they behave as expected."""

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06de5185/proton-c/bindings/cpp/include/proton/returned.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/returned.hpp b/proton-c/bindings/cpp/include/proton/returned.hpp
index 40f81be..52ecba7 100644
--- a/proton-c/bindings/cpp/include/proton/returned.hpp
+++ b/proton-c/bindings/cpp/include/proton/returned.hpp
@@ -51,7 +51,6 @@ template <class T>
 class PN_CPP_CLASS_EXTERN returned {
   public:
     /// Copy operator required to return a value
-    /// @note Thread-safe
     PN_CPP_EXTERN returned(const returned<T>&);
 
     /// Convert to the proton::object

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06de5185/tools/py/proctest.py
----------------------------------------------------------------------
diff --git a/tools/py/proctest.py b/tools/py/proctest.py
index 45c9154..c829048 100644
--- a/tools/py/proctest.py
+++ b/tools/py/proctest.py
@@ -230,23 +230,6 @@ def find_exes(*filenames):
         if not find_file(f, os.getenv('PATH')): return False
     return True
 
-#### Skip decorators missing in python 2.6
-
-def skip(func, reason):
-    def skipper():
-        print("skipped %s: %s", func, reason)
-    return skipper
-
-def skipIf(func, cond, reason):
-    if cond: return skip(func, reason)
-    else: return func
-
-def skipUnless(func, cond, reason):
-    return skipIf(func, not cond, reason)
-
-if not hasattr(unittest, 'skip'): unittest.skip = skip
-if not hasattr(unittest, 'skipIf'): unittest.skip = skipIf
-if not hasattr(unittest, 'skipUnless'): unittest.skip = skipUnless
 
 from unittest import main
 if __name__ == "__main__":


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


Mime
View raw message