Author: rhs
Date: Mon Aug 20 10:31:57 2007
New Revision: 567764

URL: http://svn.apache.org/viewvc?rev=567764&view=rev
Log:
Permit skipping of self tests and specify a folder for the spec file. Patch is 
mostly as supplied by [EMAIL PROTECTED] with minor modifications.

Modified:
    incubator/qpid/trunk/qpid/python/qpid/testlib.py
    incubator/qpid/trunk/qpid/python/tests/codec.py
    incubator/qpid/trunk/qpid/python/tests/spec.py

Modified: incubator/qpid/trunk/qpid/python/qpid/testlib.py
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/testlib.py?rev=567764&r1=567763&r2=567764&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/testlib.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/testlib.py Mon Aug 20 10:31:57 2007
@@ -45,6 +45,9 @@
     else: return value
 
 class TestRunner:
+
+    SPEC_FOLDER = "../specs"
+
     """Runs unit tests.
 
     Parses command line arguments, provides utility functions for tests,
@@ -67,6 +70,8 @@
   -d/--debug               : enable debug logging.
   -i/--ignore <test>       : ignore the named test.
   -I/--ignore-file         : file containing patterns to ignore.
+  -S/--skip-self-test      : skips the client self tests in the 'tests folder'
+  -F/--spec-folder         : folder that contains the specs to be loaded
   """
         sys.exit(1)
 
@@ -98,8 +103,13 @@
         self.ignore = []
         self.specfile = "0-8"
         self.errata = []
+        self.skip_self_test = False
+
         try:
-            opts, self.tests = getopt(args, "s:e:b:h?dvi:I:", ["help", "spec", 
"errata=", "server", "verbose", "ignore", "ignore-file"])
+            opts, self.tests = getopt(args, "s:e:b:h?dvSi:I:F:",
+                                      ["help", "spec", "errata=", "server",
+                                       "verbose", "skip-self-test", "ignore",
+                                       "ignore-file", "spec-folder"])
         except GetoptError, e:
             self._die(str(e))
         for opt, value in opts:
@@ -111,18 +121,23 @@
             if opt in ("-d", "--debug"): 
logging.basicConfig(level=logging.DEBUG)
             if opt in ("-i", "--ignore"): self.ignore.append(value)
             if opt in ("-I", "--ignore-file"): self.ignoreFile(value)
+            if opt in ("-S", "--skip-self-test"): self.skip_self_test = True
+            if opt in ("-F", "--spec-folder"): TestRunner.SPEC_FOLDER = value
        # Abbreviations for default settings.
         if (self.specfile == "0-8"):
-                   self.specfile = "../specs/amqp.0-8.xml"
-        if (self.specfile == "0-9"):
-            self.specfile = "../specs/amqp.0-9.xml"
-            self.errata.append("../specs/amqp-errata.0-9.xml")
+                   self.specfile = self.get_spec_file("amqp.0-8.xml")
+        elif (self.specfile == "0-9"):
+            self.specfile = self.get_spec_file("amqp.0-9.xml")
+            self.errata.append(self.get_spec_file("amqp-errata.0-9.xml"))
+
        if (self.specfile == None):
            self._die("No XML specification provided")
         print "Using specification from:", self.specfile
         self.spec = qpid.spec.load(self.specfile, *self.errata)
+
         if len(self.tests) == 0:
-            self.tests=findmodules("tests")
+            if not self.skip_self_test:
+                self.tests=findmodules("tests")
             if self.use08spec():
                 self.tests+=findmodules("tests_0-8")
             elif self.spec.major == 0 and self.spec.minor == 10:
@@ -166,6 +181,8 @@
         client.start({"LOGIN": user, "PASSWORD": password}, 
tune_params=tune_params)
         return client
 
+    def get_spec_file(self, fname):
+        return TestRunner.SPEC_FOLDER + os.sep + fname
 
 # Global instance for tests to call connect.
 testrunner = TestRunner()

Modified: incubator/qpid/trunk/qpid/python/tests/codec.py
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests/codec.py?rev=567764&r1=567763&r2=567764&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests/codec.py (original)
+++ incubator/qpid/trunk/qpid/python/tests/codec.py Mon Aug 20 10:31:57 2007
@@ -23,6 +23,7 @@
 from qpid.spec import load
 from cStringIO import StringIO
 from qpid.reference import ReferenceId
+from qpid.testlib import testrunner
 
 __doc__ = """
 
@@ -53,7 +54,7 @@
 
 """
 
-SPEC = load("../specs/amqp.0-10-preview.xml")
+SPEC = load(testrunner.get_spec_file("amqp.0-10-preview.xml"))
 
 # --------------------------------------
 # --------------------------------------

Modified: incubator/qpid/trunk/qpid/python/tests/spec.py
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests/spec.py?rev=567764&r1=567763&r2=567764&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests/spec.py (original)
+++ incubator/qpid/trunk/qpid/python/tests/spec.py Mon Aug 20 10:31:57 2007
@@ -1,11 +1,11 @@
 from unittest import TestCase
 from qpid.spec import load
-
+from qpid.testlib import testrunner
 
 class SpecTest(TestCase):
 
   def check_load(self, *urls):
-    spec = load(*urls)
+    spec = load(*map(testrunner.get_spec_file, urls))
     qdecl = spec.method("queue_declare")
     assert qdecl != None
     assert not qdecl.content
@@ -44,13 +44,13 @@
       assert args.type == "table"
 
   def test_load_0_8(self):
-    self.check_load("../specs/amqp.0-8.xml")
+    self.check_load("amqp.0-8.xml")
 
   def test_load_0_9(self):
-    self.check_load("../specs/amqp.0-9.xml")
+    self.check_load("amqp.0-9.xml")
 
   def test_load_0_9_errata(self):
-    self.check_load("../specs/amqp.0-9.xml", "../specs/amqp-errata.0-9.xml")
+    self.check_load("amqp.0-9.xml", "amqp-errata.0-9.xml")
 
   def test_load_0_10(self):
-    self.check_load("../specs/amqp.0-10-preview.xml")
+    self.check_load("amqp.0-10-preview.xml")


Reply via email to