Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F0E9A10614 for ; Fri, 7 Feb 2014 05:18:47 +0000 (UTC) Received: (qmail 43549 invoked by uid 500); 7 Feb 2014 05:18:46 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 43390 invoked by uid 500); 7 Feb 2014 05:18:45 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 43375 invoked by uid 99); 7 Feb 2014 05:18:44 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Feb 2014 05:18:44 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BA11391E583; Fri, 7 Feb 2014 05:18:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Fri, 07 Feb 2014 05:18:43 -0000 Message-Id: <66eb86781b004cc9ad46991a1b65a850@git.apache.org> In-Reply-To: <2fa5c0060d3d4fdbaed577bae4fa598a@git.apache.org> References: <2fa5c0060d3d4fdbaed577bae4fa598a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] couchdb commit: updated refs/heads/1843-feature-bigcouch to 1000aca Add colors to pass/fail results for JS tests More boredom while watching the test suite run. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1000acae Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1000acae Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1000acae Branch: refs/heads/1843-feature-bigcouch Commit: 1000acae60036ea8fb8d181c5aad14145d774901 Parents: 35342c4 Author: Paul J. Davis Authored: Thu Feb 6 23:18:11 2014 -0600 Committer: Paul J. Davis Committed: Thu Feb 6 23:18:11 2014 -0600 ---------------------------------------------------------------------- test/javascript/run | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/1000acae/test/javascript/run ---------------------------------------------------------------------- diff --git a/test/javascript/run b/test/javascript/run index a0f1112..65562d7 100755 --- a/test/javascript/run +++ b/test/javascript/run @@ -45,10 +45,34 @@ SCRIPTS = """ RUNNER = "test/javascript/cli_runner.js" -def run_couchjs(test, longname): - padding = (longname - len(test)) * " " - sys.stderr.write(test + " " + padding) - sys.stderr.flush() +def mkformatter(tests): + longest = max(map(len, tests)) + green = "\033[32m" + red = "\033[31m" + clear = "\033[0m" + if not sys.stderr.isatty(): + green, read, clear = "", "", "" + def _colorized(passed): + if passed: + return green + "pass" + clear + else: + return red + "fail" + clear + def _fmt(test): + if isinstance(test, basestring): + padding = (longest - len(test)) * " " + sys.stderr.write(test + " " + padding) + sys.stderr.flush() + elif isinstance(test, bool): + if test: + sys.stderr.write(_colorized(test) + os.linesep) + else: + sys.stderr.write(_colorized(test) + os.linesep) + sys.stderr.flush() + return _fmt + + +def run_couchjs(test, fmt): + fmt(test) cmd = [COUCHJS, "-H"] + SCRIPTS + [test, RUNNER] p = sp.Popen( cmd, @@ -66,11 +90,7 @@ def run_couchjs(test, longname): else: sys.stderr.write(line) p.wait() - if p.returncode == 0: - sys.stderr.write("pass" + os.linesep) - else: - sys.stderr.write("fail" + os.linesep) - sys.stderr.flush() + fmt(p.returncode == 0) def options(): @@ -98,9 +118,9 @@ def main(): else: sys.stderr.write("Unknown test: " + name + os.linesep) exit(1) - longname = max(map(len, tests)) + fmt = mkformatter(tests) for test in tests: - run_couchjs(test, longname) + run_couchjs(test, fmt)