mirror of https://github.com/ARMmbed/mbed-os.git
Added colorama to toolchain notification function and basic test suite prompts
parent
cff6bc44ea
commit
f2f0f51d16
|
@ -28,6 +28,7 @@ import optparse
|
||||||
import datetime
|
import datetime
|
||||||
import threading
|
import threading
|
||||||
from types import ListType
|
from types import ListType
|
||||||
|
from colorama import Fore, Back, Style
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
@ -172,6 +173,9 @@ class SingleTestRunner(object):
|
||||||
_opts_extend_test_timeout=None):
|
_opts_extend_test_timeout=None):
|
||||||
""" Let's try hard to init this object
|
""" Let's try hard to init this object
|
||||||
"""
|
"""
|
||||||
|
from colorama import init
|
||||||
|
init()
|
||||||
|
|
||||||
PATTERN = "\\{(" + "|".join(self.TEST_RESULT_MAPPING.keys()) + ")\\}"
|
PATTERN = "\\{(" + "|".join(self.TEST_RESULT_MAPPING.keys()) + ")\\}"
|
||||||
self.RE_DETECT_TESTCASE_RESULT = re.compile(PATTERN)
|
self.RE_DETECT_TESTCASE_RESULT = re.compile(PATTERN)
|
||||||
# Settings related to test loops counters
|
# Settings related to test loops counters
|
||||||
|
@ -759,7 +763,7 @@ class SingleTestRunner(object):
|
||||||
separator = "::"
|
separator = "::"
|
||||||
time_info = " in %.2f of %d sec" % (round(elapsed_time, 2), duration)
|
time_info = " in %.2f of %d sec" % (round(elapsed_time, 2), duration)
|
||||||
result = separator.join(tokens) + " [" + test_result +"]" + time_info
|
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):
|
def shape_test_loop_ok_result_count(self, test_all_result):
|
||||||
""" Reformats list of results to simple string
|
""" Reformats list of results to simple string
|
||||||
|
@ -842,7 +846,7 @@ class SingleTestRunner(object):
|
||||||
cmd += ["-R", str(reset_tout)]
|
cmd += ["-R", str(reset_tout)]
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Executing '" + " ".join(cmd) + "'"
|
print Fore.MAGENTA + "Executing '" + " ".join(cmd) + "'" + Fore.RESET
|
||||||
print "Test::Output::Start"
|
print "Test::Output::Start"
|
||||||
|
|
||||||
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
|
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
|
||||||
|
@ -851,7 +855,7 @@ class SingleTestRunner(object):
|
||||||
line = ''
|
line = ''
|
||||||
output = []
|
output = []
|
||||||
start_time = time()
|
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)
|
c = get_char_from_queue(obs)
|
||||||
if c:
|
if c:
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import colorama
|
||||||
from os import stat, walk
|
from os import stat, walk
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
|
@ -49,6 +50,23 @@ def print_notify(event, silent=False):
|
||||||
if not silent:
|
if not silent:
|
||||||
print '%s: %s' % (event['action'].title(), basename(event['file']))
|
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):
|
def print_notify_verbose(event, silent=False):
|
||||||
""" Default command line notification with more verbose mode
|
""" 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.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.options = options if options is not None else []
|
||||||
|
|
||||||
self.macros = macros or []
|
self.macros = macros or []
|
||||||
|
@ -704,6 +722,8 @@ class mbedToolchain:
|
||||||
def var(self, key, value):
|
def var(self, key, value):
|
||||||
self.notify({'type': 'var', 'key': key, 'val': 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 ARM_BIN
|
||||||
from workspace_tools.settings import GCC_ARM_PATH, GCC_CR_PATH, GCC_CS_PATH, CW_EWL_PATH, CW_GCC_PATH
|
from workspace_tools.settings import GCC_ARM_PATH, GCC_CR_PATH, GCC_CS_PATH, CW_EWL_PATH, CW_GCC_PATH
|
||||||
|
|
Loading…
Reference in New Issue