Add a simple progress bar when neither '-v' nor '-t' is specified.

llvm-svn: 144940
This commit is contained in:
Johnny Chen 2011-11-18 00:19:29 +00:00
parent 459532e1d5
commit 316651ab21
1 changed files with 22 additions and 5 deletions

View File

@ -161,6 +161,9 @@ svn_info = ''
# Default verbosity is 0. # Default verbosity is 0.
verbose = 0 verbose = 0
# Set to True only if verbose is 0 and LLDB trace mode is off.
progress_bar = False
# By default, search from the script directory. # By default, search from the script directory.
testdirs = [ sys.path[0] ] testdirs = [ sys.path[0] ]
@ -344,6 +347,7 @@ def parseOptionsAndInitTestdirs():
global filters global filters
global fs4all global fs4all
global ignore global ignore
global progress_bar
global runHooks global runHooks
global skip_build_and_cleanup global skip_build_and_cleanup
global skip_long_running_test global skip_long_running_test
@ -530,6 +534,10 @@ def parseOptionsAndInitTestdirs():
if dont_do_python_api_test and just_do_python_api_test: if dont_do_python_api_test and just_do_python_api_test:
usage() usage()
# The simple progress bar is turned on only if verbose == 0 and LLDB_COMMAND_TRACE is not 'YES'
if ("LLDB_COMMAND_TRACE" not in os.environ or os.environ["LLDB_COMMAND_TRACE"]!="YES") and verbose==0:
progress_bar = True
# Gather all the dirs passed on the command line. # Gather all the dirs passed on the command line.
if len(sys.argv) > index: if len(sys.argv) > index:
testdirs = map(os.path.abspath, sys.argv[index:]) testdirs = map(os.path.abspath, sys.argv[index:])
@ -1076,11 +1084,10 @@ for ia in range(len(archs) if iterArchs else 1):
#print "sys.stdout name is", sys.stdout.name #print "sys.stdout name is", sys.stdout.name
# First, write out the number of collected test cases. # First, write out the number of collected test cases.
if not noHeaders: sys.stderr.write(separator + "\n")
sys.stderr.write(separator + "\n") sys.stderr.write("Collected %d test%s\n\n"
sys.stderr.write("Collected %d test%s\n\n" % (suite.countTestCases(),
% (suite.countTestCases(), suite.countTestCases() != 1 and "s" or ""))
suite.countTestCases() != 1 and "s" or ""))
class LLDBTestResult(unittest2.TextTestResult): class LLDBTestResult(unittest2.TextTestResult):
""" """
@ -1122,6 +1129,16 @@ for ia in range(len(archs) if iterArchs else 1):
self.stream.write(self.fmt % self.counter) self.stream.write(self.fmt % self.counter)
super(LLDBTestResult, self).startTest(test) super(LLDBTestResult, self).startTest(test)
def stopTest(self, test):
"""Called when the given test has been run"""
if progress_bar:
sys.__stdout__.write('.')
sys.__stdout__.flush()
if self.counter == suite.countTestCases():
sys.__stdout__.write('\n')
super(LLDBTestResult, self).stopTest(test)
def addError(self, test, err): def addError(self, test, err):
global sdir_has_content global sdir_has_content
sdir_has_content = True sdir_has_content = True