]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move teuthology-coverage's arg parsing to scripts/
authorZack Cerza <zack@cerza.org>
Wed, 9 Oct 2013 17:15:33 +0000 (12:15 -0500)
committerZack Cerza <zack@cerza.org>
Fri, 11 Oct 2013 00:09:34 +0000 (19:09 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/coverage.py [new file with mode: 0644]
setup.py
teuthology/coverage.py

diff --git a/scripts/coverage.py b/scripts/coverage.py
new file mode 100644 (file)
index 0000000..3aef9f5
--- /dev/null
@@ -0,0 +1,44 @@
+import argparse
+
+import teuthology.coverage
+
+
+def main():
+    teuthology.coverage.main(parse_args())
+
+
+def parse_args():
+    parser = argparse.ArgumentParser(description="""
+Analyze the coverage of a suite of test runs, generating html output with lcov.
+""")
+    parser.add_argument(
+        '-o', '--lcov-output',
+        help='the directory in which to store results',
+        required=True,
+    )
+    parser.add_argument(
+        '--html-output',
+        help='the directory in which to store html output',
+    )
+    parser.add_argument(
+        '--cov-tools-dir',
+        help='the location of coverage scripts (cov-init and cov-analyze)',
+        default='../../coverage',
+    )
+    parser.add_argument(
+        '--skip-init',
+        help='skip initialization (useful if a run stopped partway through)',
+        action='store_true',
+        default=False,
+    )
+    parser.add_argument(
+        '-v', '--verbose',
+        help='be more verbose',
+        action='store_true',
+        default=False,
+    )
+    parser.add_argument(
+        'test_dir',
+        help='the location of the test results',
+    )
+    return parser.parse_args()
index 75fed91d45a467a3737b903b89316675bfd10486..d1b0c56e91a89bd5db092ffe50aa3f19992f3ef2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ setup(
             'teuthology-lock = scripts.lock:main',
             'teuthology-schedule = scripts.schedule:main',
             'teuthology-updatekeys = scripts.updatekeys:main',
-            'teuthology-coverage = teuthology.coverage:analyze',
+            'teuthology-coverage = scripts.coverage:main',
             'teuthology-results = scripts.results:main',
             'teuthology-report = scripts.report:main',
             ],
index a3dede40ec6fbaed4b2a0679d833ca7dc3773da0..6acc79c28fe8ce10337e347c617f36992050aacc 100644 (file)
@@ -1,4 +1,3 @@
-import argparse
 from contextlib import closing
 import logging
 import os
@@ -7,7 +6,7 @@ import subprocess
 import MySQLdb
 import yaml
 
-from teuthology import misc as teuthology
+from teuthology.misc import read_config
 
 log = logging.getLogger(__name__)
 
@@ -89,42 +88,7 @@ def read_coverage(output):
     return coverage
 
 
-def analyze():
-    parser = argparse.ArgumentParser(description="""
-Analyze the coverage of a suite of test runs, generating html output with lcov.
-""")
-    parser.add_argument(
-        '-o', '--lcov-output',
-        help='the directory in which to store results',
-        required=True,
-    )
-    parser.add_argument(
-        '--html-output',
-        help='the directory in which to store html output',
-    )
-    parser.add_argument(
-        '--cov-tools-dir',
-        help='the location of coverage scripts (cov-init and cov-analyze)',
-        default='../../coverage',
-    )
-    parser.add_argument(
-        '--skip-init',
-        help='skip initialization (useful if a run stopped partway through)',
-        action='store_true',
-        default=False,
-    )
-    parser.add_argument(
-        '-v', '--verbose',
-        help='be more verbose',
-        action='store_true',
-        default=False,
-    )
-    parser.add_argument(
-        'test_dir',
-        help='the location of the test results',
-    )
-    args = parser.parse_args()
-
+def main(args):
     loglevel = logging.INFO
     if args.verbose:
         loglevel = logging.DEBUG
@@ -132,8 +96,9 @@ Analyze the coverage of a suite of test runs, generating html output with lcov.
     logging.basicConfig(
         level=loglevel,
     )
+    log = logging.getLogger(__name__)
 
-    teuthology.read_config(args)
+    read_config(args)
 
     handler = logging.FileHandler(
         filename=os.path.join(args.test_dir, 'coverage.log'),
@@ -146,13 +111,13 @@ Analyze the coverage of a suite of test runs, generating html output with lcov.
     logging.getLogger().addHandler(handler)
 
     try:
-        _analyze(args)
+        analyze(args)
     except Exception:
         log.exception('error generating coverage')
         raise
 
 
-def _analyze(args):
+def analyze(args):
     tests = [
         f for f in sorted(os.listdir(args.test_dir))
         if not f.startswith('.')