You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/07 06:18:43 UTC
[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 <pa...@gmail.com>
Authored: Thu Feb 6 23:18:11 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
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)