validate:tools: Print test result in the terminal after the end of each test

This commit is contained in:
Thibault Saunier 2014-01-15 16:11:39 +01:00
parent 5d172e159e
commit 3bce8f8966
3 changed files with 19 additions and 10 deletions

View file

@ -22,6 +22,7 @@
import os
import re
import time
import utils
import subprocess
import reporters
from loggable import Loggable
@ -152,7 +153,7 @@ class Test(Loggable):
self.build_arguments()
printc("Launching: %s%s\n"
" logs are in %s\n"
" Command: '%s'\n"
" Command: '%s'"
% (Colors.ENDC, self.classname,
self.logfile, self.command), Colors.OKBLUE)
try:
@ -178,6 +179,9 @@ class Test(Loggable):
"Command: '%s'\n"
"=================\n\n"
% (self.classname, self.command))
printc("Result: %s%s\n" % (self.result,
" (" + self.message + ")" if self.message else ""),
color=utils.get_color_for_result(self.result))
return self.result

View file

@ -28,7 +28,6 @@ from utils import printc, path2url, DEFAULT_GST_QA_ASSETS, launch_command
DEFAULT_GST_QA_ASSETS_REPO = "git://people.freedesktop.org/~tsaunier/gst-qa-assets/"
def main():
parser = OptionParser()
# FIXME:

View file

@ -82,6 +82,19 @@ def which(name):
return result
def get_color_for_result(result):
if result is Result.FAILED:
color = Colors.FAIL
elif result is Result.TIMEOUT:
color = Colors.WARNING
elif result is Result.PASSED:
color = Colors.OKGREEN
else:
color = Colors.OKBLUE
return color
def printc(message, color="", title=False):
if title:
length = 0
@ -93,14 +106,7 @@ def printc(message, color="", title=False):
message = length * '=' + "\n" + str(message) + "\n" + length * '='
if hasattr(message, "result") and color == '':
if message.result == Result.FAILED:
color = Colors.FAIL
elif message.result == Result.TIMEOUT:
color = Colors.WARNING
elif message.result == Result.PASSED:
color = Colors.OKGREEN
else:
color = Colors.OKBLUE
color = get_color_for_result(message.result)
print color + str(message) + Colors.ENDC