couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [41/47] couchdb commit: updated refs/heads/enable-csp-default to dbd38a1
Date Fri, 28 Nov 2014 21:00:43 GMT
Run dev/run script in quite mode for javascript tests


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/390e9228
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/390e9228
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/390e9228

Branch: refs/heads/enable-csp-default
Commit: 390e9228e8f9c175bc67f7b69d4bf68bcfbf0687
Parents: 9ad3f9b
Author: Alexander Shorin <kxepal@apache.org>
Authored: Sat Nov 15 19:19:36 2014 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Sun Nov 16 00:51:15 2014 +0300

----------------------------------------------------------------------
 Makefile |  2 +-
 dev/run  | 26 ++++++++++++++++++++------
 2 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/390e9228/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index e881f61..986d2dc 100644
--- a/Makefile
+++ b/Makefile
@@ -68,4 +68,4 @@ eunit: compile
 	@rebar -r eunit skip_deps=meck,mochiweb,lager,snappy,couch_replicator,fabric,folsom
 
 javascript: compile
-	@dev/run test/javascript/run
+	@dev/run -q test/javascript/run

http://git-wip-us.apache.org/repos/asf/couchdb/blob/390e9228/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index 3f98bf3..932fbae 100755
--- a/dev/run
+++ b/dev/run
@@ -44,22 +44,26 @@ def log(msg):
     def decorator(func):
         @functools.wraps(func)
         def wrapper(*args, **kwargs):
+            def print_(chars):
+                if log.verbose:
+                    sys.stdout.write(chars)
+                    sys.stdout.flush()
             callargs = dict(zip(inspect.getargspec(func).args, args))
             callargs.update(kwargs)
-            sys.stdout.write(msg.format(**callargs) + '... ')
-            sys.stdout.flush()
+            print_(msg.format(**callargs) + '... ')
             try:
                 res = func(*args, **kwargs)
+            except KeyboardInterrupt:
+                print_('ok\n')
             except:
-                sys.stdout.write('failed\n')
+                print_('failed\n')
                 raise
             else:
-                sys.stdout.write('ok\n')
+                print_('ok\n')
                 return res
-            finally:
-                sys.stdout.flush()
         return wrapper
     return decorator
+log.verbose = True
 
 
 def main():
@@ -74,12 +78,17 @@ def main():
 def setup():
     opts, args = setup_argparse()
     ctx = setup_context(opts, args)
+    setup_logging(ctx)
     setup_dirs(ctx)
     check_beams(ctx)
     setup_configs(ctx)
     return ctx
 
 
+def setup_logging(ctx):
+    log.verbose = ctx['verbose']
+
+
 def setup_argparse():
     parser = optparse.OptionParser(description='Runs CouchDB 2.0 dev cluster')
     parser.add_option('-a', '--admin', metavar='USER:PASS', default=None,
@@ -87,6 +96,9 @@ def setup_argparse():
     parser.add_option("-n", "--nodes", metavar="nodes", default=3,
                       type=int,
                       help="Number of development nodes to be spun up")
+    parser.add_option("-q", "--quite",
+                      action="store_false", dest="verbose", default=True,
+                      help="Don't print anything to STDOUT")
     return parser.parse_args()
 
 
@@ -98,6 +110,7 @@ def setup_context(opts, args):
             'devdir': os.path.dirname(fpath),
             'rootdir': os.path.dirname(os.path.dirname(fpath)),
             'cmd': ' '.join(args),
+            'verbose': opts.verbose,
             'procs': []}
 
 
@@ -314,6 +327,7 @@ def run_command(ctx, cmd):
     exit(p.returncode)
 
 
+@log('Restart all nodes')
 def reboot_nodes(ctx):
     kill_processes(ctx)
     boot_nodes(ctx)


Mime
View raw message