Changeset: 5e9163d30f68 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5e9163d30f68 Modified Files: testing/Mtest.py.in Branch: Oct2012 Log Message:
For normal test output, squeeze long test names to fit on single line. diffs (82 lines): diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in --- a/testing/Mtest.py.in +++ b/testing/Mtest.py.in @@ -58,7 +58,10 @@ quiet = False releaserun = False -if os.name != 'nt' and os.isatty(sys.stdout.fileno()): +# whether output goes to a tty +isatty = os.isatty(sys.stdout.fileno()) + +if os.name != 'nt' and isatty: # color output a little RED = '\033[1;31m' GREEN = '\033[0;32m' @@ -161,6 +164,26 @@ except ImportError: p += os.pathsep + os.environ['PYTHONPATH'] os.environ['PYTHONPATH'] = p +ttywidth = 0 +if os.name != 'nt' and isatty and os.isatty(sys.stdin.fileno()): + try: + proc = subprocess.Popen(['stty', '-a'], stdout = subprocess.PIPE, + stderr = subprocess.PIPE) + except OSError: + pass + else: + out, err = proc.communicate() + res = re.search('columns ([0-9]+)', out) + if res is not None: + ttywidth = int(res.group(1)) + else: + res = re.search(' ([0-9]+) columns', out) + if res is not None: + ttywidth = int(res.group(1)) + if ttywidth < 60: + # rediculously narrow tty, ignore value + ttywidth = 0 + import string # for whitespace def splitcommand(cmd): '''Like string.split, except take quotes into account.''' @@ -1031,7 +1054,17 @@ def SkipTest(env, TST, EXT, REASON, leng REASON = REASON[3:] if REASON.endswith('.'): REASON = REASON[:-1] - STDOUT.write('%s%-*s skipped (%s)\n' % (prompt(), length, TST, REASON)) + if length + 10 + len(REASON) + 11 > ttywidth: + # 10 - length of prompt() + # 11 - length of " skipped ()" + l = ttywidth - 10 - 11 - len(REASON) + if len(TST) <= l: + s = '%-*s' % (l, TST) + else: + s = '%s...%s' % (TST[:l/2 - 2], TST[-(l/2 - 1):]) + else: + s = '%-*s' % (length, TST) + STDOUT.write('%s%s skipped (%s)\n' % (prompt(), s, REASON)) if testweb: return None @@ -2570,8 +2603,18 @@ def DoIt(env, SERVER, CALL, TST, EXT, PR (prompt(), os.path.join(env['TSTDIR'], TST + EXT), PRELUDE and PRELUDE[0] or '', TIMEOUT, CTIMEOUT, STIMEOUT)) else: - STDOUT.write('%s%-*s ' % (prompt(), length, TST)) - if os.isatty(STDOUT.fileno()): + if ttywidth > 0 and length + 10 + 21 > ttywidth: + # 10 - length of prompt() + # 21 - length of time plus result + l = ttywidth - 10 - 21 - 1 + if len(TST) <= l: + s = '%-*s ' % (l, TST) + else: + s = '%s...%s ' % (TST[:l/2 - 2], TST[-(l/2-1):]) + else: + s = '%-*s ' % (length, TST) + STDOUT.write('%s%s' % (prompt(), s)) + if isatty: s = '(<=%d,%d,%d)' % (TIMEOUT, CTIMEOUT, STIMEOUT) STDOUT.write(s + '\b' * len(s)) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list