From fb1fe48e4f61e66f420d5a77e0952aa7f80bd66a Mon Sep 17 00:00:00 2001
From: Konstantin Shulgin <konstantin.shulgin@gmail.com>
Date: Mon, 22 Aug 2011 13:05:03 +0400
Subject: [PATCH] feature 'master-valgrind':

Test environment:
 - test-run.py script was reformated to PEP8.
---
 test/test-run.py | 271 +++++++++++++++++++++++------------------------
 1 file changed, 135 insertions(+), 136 deletions(-)

diff --git a/test/test-run.py b/test/test-run.py
index a511941b20..9c2aa91d39 100755
--- a/test/test-run.py
+++ b/test/test-run.py
@@ -34,148 +34,147 @@ from lib.test_suite import TestSuite
 #
 
 class Options:
-  """Handle options of test-runner"""
-  def __init__(self):
-    """Add all program options, with their defaults."""
-
-    parser = argparse.ArgumentParser(
-        description = "Tarantool regression test suite front-end.")
-
-    parser.epilog = "For a complete description, use 'pydoc ./" +\
-        os.path.basename(sys.argv[0]) + "'"
-
-    parser.add_argument(
-        "tests",
-        metavar="test",
-        nargs="*",
-        default = [""],
-        help="""Can be empty. List of test names, to look for in suites. Each
-        name is used as a substring to look for in the path to test file,
-        e.g. "show" will run all tests that have "show" in their name in all
-        suites, "box/show" will only enable tests starting with "show" in
-        "box" suite. Default: run all tests in all specified suites.""")
-
-    parser.add_argument(
-        "--module",
-        dest = 'modules',
-        metavar = "module",
-        nargs="*",
-        default = ["box"],
-        help = "List of modules to test. Default: \"box\"")
-
-    parser.add_argument(
-        "--suite",
-        dest = 'suites',
-        metavar = "suite",
-        nargs="*",
-        default = [],
-        help = """List of tests suites to look for tests in. Default: "" -
-	means find all available.""")
-
-    parser.add_argument(
-        "--force",
-        dest = "is_force",
-        action = "store_true",
-        default = False,
-        help = """Go on with other tests in case of an individual test failure.
-                 Default: false.""")
-
-    parser.add_argument(
-        "--start-and-exit",
-        dest = "start_and_exit",
-        action = "store_true",
-        default = False,
-        help = """Start the server from the first specified suite and
-         exit without running any tests. Default: false.""")
-
-    parser.add_argument(
-        "--gdb",
-        dest = "gdb",
-        action = "store_true",
-        default = False,
-        help = """Start the server under 'gdb' debugger.
-        See also --start-and-exit. This option is mutually exclusive with
-        --valgrind. Default: false.""")
-
-    parser.add_argument(
-        "--valgrind",
-        dest = "valgrind",
-        action = "store_true",
-        default = False,
-        help = "Run the server under 'valgrind'. Default: false.")
-
-    parser.add_argument(
-        "--builddir",
-        dest = "builddir",
-        default = "..",
-        help = """Path to project build directory. Default: " + "../.""")
-
-    parser.add_argument(
-        "--vardir",
-        dest = "vardir",
-        default = "var",
-        help = """Path to data directory. Default: var.""")
-
-    parser.add_argument(
-        "--mem",
-        dest = "mem",
-        action = "store_true",
-        default = False,
-        help = """Run test suite in memory, using tmpfs or ramdisk.
-        Is used only if vardir is not an absolute path. In that case
-        vardir is sym-linked to /dev/shm/<vardir>.
-        Linux only. Default: false.""")
-
-    self.args = parser.parse_args()
-    self.check()
-
-  def check(self):
-    """Check the arguments for correctness."""
-    check_error = False
-    if self.args.gdb and self.args.valgrind:
-      print "Error: option --gdb is not compatible with option --valgrind"
-      check_error = True
-    if check_error:
-      exit(-1)
+    """Handle options of test-runner"""
+    def __init__(self):
+        """Add all program options, with their defaults."""
+
+        parser = argparse.ArgumentParser(
+                description = "Tarantool regression test suite front-end.")
+
+        parser.epilog = "For a complete description, use 'pydoc ./" +\
+                os.path.basename(sys.argv[0]) + "'"
+
+        parser.add_argument(
+                "tests",
+                metavar="test",
+                nargs="*",
+                default = [""],
+                help="""Can be empty. List of test names, to look for in suites. Each
+                name is used as a substring to look for in the path to test file,
+                e.g. "show" will run all tests that have "show" in their name in all
+                suites, "box/show" will only enable tests starting with "show" in
+                "box" suite. Default: run all tests in all specified suites.""")
+
+        parser.add_argument(
+                "--module",
+                dest = 'modules',
+                metavar = "module",
+                nargs="*",
+                default = ["box"],
+                help = "List of modules to test. Default: \"box\"")
+
+        parser.add_argument(
+                "--suite",
+                dest = 'suites',
+                metavar = "suite",
+                nargs="*",
+                default = [],
+                help = """List of tests suites to look for tests in. Default: "" -
+                means find all available.""")
+
+        parser.add_argument(
+                "--force",
+                dest = "is_force",
+                action = "store_true",
+                default = False,
+                help = """Go on with other tests in case of an individual test failure.
+                Default: false.""")
+
+        parser.add_argument(
+                "--start-and-exit",
+                dest = "start_and_exit",
+                action = "store_true",
+                default = False,
+                help = """Start the server from the first specified suite and
+                exit without running any tests. Default: false.""")
+
+        parser.add_argument(
+                "--gdb",
+                dest = "gdb",
+                action = "store_true",
+                default = False,
+                help = """Start the server under 'gdb' debugger.
+                See also --start-and-exit. This option is mutually exclusive with
+                --valgrind. Default: false.""")
+
+        parser.add_argument(
+                "--valgrind",
+                dest = "valgrind",
+                action = "store_true",
+                default = False,
+                help = "Run the server under 'valgrind'. Default: false.")
+
+        parser.add_argument(
+                "--builddir",
+                dest = "builddir",
+                default = "..",
+                help = """Path to project build directory. Default: " + "../.""")
+
+        parser.add_argument(
+                "--vardir",
+                dest = "vardir",
+                default = "var",
+                help = """Path to data directory. Default: var.""")
+
+        parser.add_argument(
+                "--mem",
+                dest = "mem",
+                action = "store_true",
+                default = False,
+                help = """Run test suite in memory, using tmpfs or ramdisk.
+                Is used only if vardir is not an absolute path. In that case
+                vardir is sym-linked to /dev/shm/<vardir>.
+                Linux only. Default: false.""")
+
+        self.args = parser.parse_args()
+        self.check()
+
+    def check(self):
+        """Check the arguments for correctness."""
+        check_error = False
+        if self.args.gdb and self.args.valgrind:
+            print "Error: option --gdb is not compatible with option --valgrind"
+            check_error = True
+        if check_error:
+            exit(-1)
 
 #######################################################################
 # Program body
 #######################################################################
 
 def main():
-  options = Options()
-  oldcwd = os.getcwd()
-  # Change the current working directory to where all test
-  # collections are supposed to reside.
-  os.chdir(os.path.dirname(sys.argv[0]))
-  failed_tests = 0
-
-  try:
-    print "Started", " ".join(sys.argv)
-    suite_names = []
-    if options.args.suites != []:
-      suite_names = options.args.suites
-    else:
-      for root, dirs, names in os.walk(os.getcwd()):
-        if "suite.ini" in names:
-	  suite_names.append(os.path.basename(root))
-    suites = []
-    for suite_name in suite_names:
-      suite = TestSuite(suite_name, options.args)
-      if suite.ini["module"] not in options.args.modules:
-        continue
-
-      suites.append(suite)
-
-    for suite in suites:
-      failed_tests += suite.run_all()
-  except RuntimeError as e:
-    print "\nFatal error: {0}. Execution aborted.".format(e)
-    return (-1)
-  finally:
-    os.chdir(oldcwd)
-
-  return -failed_tests 
+    options = Options()
+    oldcwd = os.getcwd()
+    # Change the current working directory to where all test
+    # collections are supposed to reside.
+    os.chdir(os.path.dirname(sys.argv[0]))
+    failed_tests = 0
+
+    try:
+        print "Started", " ".join(sys.argv)
+        suite_names = []
+        if options.args.suites != []:
+            suite_names = options.args.suites
+        else:
+            for root, dirs, names in os.walk(os.getcwd()):
+                if "suite.ini" in names:
+                    suite_names.append(os.path.basename(root))
+        suites = []
+        for suite_name in suite_names:
+            suite = TestSuite(suite_name, options.args)
+            if suite.ini["module"] not in options.args.modules:
+                continue
+            suites.append(suite)
+
+        for suite in suites:
+            failed_tests += suite.run_all()
+    except RuntimeError as e:
+        print "\nFatal error: {0}. Execution aborted.".format(e)
+        return (-1)
+    finally:
+        os.chdir(oldcwd)
+
+    return -failed_tests
 
 if __name__ == "__main__":
   exit(main())
-- 
GitLab