[Lldb-commits] [lldb] r144940 - /lldb/trunk/test/dotest.py

Johnny Chen johnny.chen at apple.com
Thu Nov 17 16:38:51 PST 2011


BTW,
I tried to use the ProgressBar.py from llvm, to no avail.
The Python unittest framework is messing with sys.stdout plus other things that I don't quite understand,
so I take the simple and dumb approach of outputting '.' when each test case is done.
On Nov 17, 2011, at 4:19 PM, Johnny Chen wrote:

> Author: johnny
> Date: Thu Nov 17 18:19:29 2011
> New Revision: 144940
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=144940&view=rev
> Log:
> Add a simple progress bar when neither '-v' nor '-t' is specified.
> 
> Modified:
>    lldb/trunk/test/dotest.py
> 
> Modified: lldb/trunk/test/dotest.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=144940&r1=144939&r2=144940&view=diff
> ==============================================================================
> --- lldb/trunk/test/dotest.py (original)
> +++ lldb/trunk/test/dotest.py Thu Nov 17 18:19:29 2011
> @@ -161,6 +161,9 @@
> # Default verbosity is 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.
> testdirs = [ sys.path[0] ]
> 
> @@ -344,6 +347,7 @@
>     global filters
>     global fs4all
>     global ignore
> +    global progress_bar
>     global runHooks
>     global skip_build_and_cleanup
>     global skip_long_running_test
> @@ -530,6 +534,10 @@
>     if dont_do_python_api_test and just_do_python_api_test:
>         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.
>     if len(sys.argv) > index:
>         testdirs = map(os.path.abspath, sys.argv[index:])
> @@ -1076,11 +1084,10 @@
>         #print "sys.stdout name is", sys.stdout.name
> 
>         # First, write out the number of collected test cases.
> -        if not noHeaders:
> -            sys.stderr.write(separator + "\n")
> -            sys.stderr.write("Collected %d test%s\n\n"
> -                             % (suite.countTestCases(),
> -                                suite.countTestCases() != 1 and "s" or ""))
> +        sys.stderr.write(separator + "\n")
> +        sys.stderr.write("Collected %d test%s\n\n"
> +                         % (suite.countTestCases(),
> +                            suite.countTestCases() != 1 and "s" or ""))
> 
>         class LLDBTestResult(unittest2.TextTestResult):
>             """
> @@ -1122,6 +1129,16 @@
>                     self.stream.write(self.fmt % self.counter)
>                 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):
>                 global sdir_has_content
>                 sdir_has_content = True
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list