Added colorama to toolchain notification function and basic test suite prompts

pull/900/head
Przemek Wirkus 2015-02-10 23:38:01 +00:00
parent cff6bc44ea
commit f2f0f51d16
2 changed files with 28 additions and 4 deletions

View File

@ -28,6 +28,7 @@ import optparse
import datetime
import threading
from types import ListType
from colorama import Fore, Back, Style
from prettytable import PrettyTable
from time import sleep, time
@ -172,6 +173,9 @@ class SingleTestRunner(object):
_opts_extend_test_timeout=None):
""" Let's try hard to init this object
"""
from colorama import init
init()
PATTERN = "\\{(" + "|".join(self.TEST_RESULT_MAPPING.keys()) + ")\\}"
self.RE_DETECT_TESTCASE_RESULT = re.compile(PATTERN)
# Settings related to test loops counters
@ -759,7 +763,7 @@ class SingleTestRunner(object):
separator = "::"
time_info = " in %.2f of %d sec" % (round(elapsed_time, 2), duration)
result = separator.join(tokens) + " [" + test_result +"]" + time_info
return result
return Fore.MAGENTA + result + Fore.RESET
def shape_test_loop_ok_result_count(self, test_all_result):
""" Reformats list of results to simple string
@ -842,7 +846,7 @@ class SingleTestRunner(object):
cmd += ["-R", str(reset_tout)]
if verbose:
print "Executing '" + " ".join(cmd) + "'"
print Fore.MAGENTA + "Executing '" + " ".join(cmd) + "'" + Fore.RESET
print "Test::Output::Start"
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
@ -851,7 +855,7 @@ class SingleTestRunner(object):
line = ''
output = []
start_time = time()
while (time() - start_time) < (duration + 5): # Extra 5 seconds for flashing
while (time() - start_time) < (duration):
c = get_char_from_queue(obs)
if c:
if verbose:

View File

@ -17,6 +17,7 @@ limitations under the License.
import re
import sys
import colorama
from os import stat, walk
from copy import copy
from time import time, sleep
@ -49,6 +50,23 @@ def print_notify(event, silent=False):
if not silent:
print '%s: %s' % (event['action'].title(), basename(event['file']))
def print_notify_color(event, silent=False):
""" Default command line notification with colors
"""
from colorama import Fore, Back, Style
if event['type'] in ['info', 'debug']:
print Fore.GREEN + event['message'] + Fore.RESET
elif event['type'] == 'cc':
event['severity'] = event['severity'].title()
event['file'] = basename(event['file'])
print Fore.YELLOW + '[%(severity)s] %(file)s@%(line)s: %(message)s'% event + Fore.RESET
elif event['type'] == 'progress':
if not silent:
print '%s: %s' % (event['action'].title(), basename(event['file']))
def print_notify_verbose(event, silent=False):
""" Default command line notification with more verbose mode
"""
@ -215,7 +233,7 @@ class mbedToolchain:
self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])
self.notify_fun = notify if notify is not None else print_notify
self.notify_fun = notify if notify is not None else print_notify_color
self.options = options if options is not None else []
self.macros = macros or []
@ -704,6 +722,8 @@ class mbedToolchain:
def var(self, key, value):
self.notify({'type': 'var', 'key': key, 'val': value})
from colorama import init
init()
from workspace_tools.settings import ARM_BIN
from workspace_tools.settings import GCC_ARM_PATH, GCC_CR_PATH, GCC_CS_PATH, CW_EWL_PATH, CW_GCC_PATH