Re: [Lldb-commits] [lldb] r237602 - Refactored dotest arg parser so that it's accessible from dosep

2015-05-22 Thread Vince Harron
Up for review

http://reviews.llvm.org/D9937

On Thu, May 21, 2015 at 4:17 PM, Vince Harron  wrote:

> Yeah, on it.
>
> On Thu, May 21, 2015 at 4:03 PM, Zachary Turner 
> wrote:
>
>> This breaks dotest.py --help, and many other command line options.
>>
>> Would you mind fixing this?  I took a stab at it but it turns out to be a
>> little more involved than I have time for.
>>
>> On Mon, May 18, 2015 at 12:45 PM Vince Harron 
>> wrote:
>>
>>> Author: vharron
>>> Date: Mon May 18 14:40:54 2015
>>> New Revision: 237602
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=237602&view=rev
>>> Log:
>>> Refactored dotest arg parser so that it's accessible from dosep
>>>
>>> This allows dosep to understand an act on dotest arguments
>>>
>>> Differential Revision: http://reviews.llvm.org/D9820
>>>
>>>
>>> Added:
>>> lldb/trunk/test/dotest_args.py
>>> Modified:
>>> lldb/trunk/test/dosep.py
>>> lldb/trunk/test/dotest.py
>>>
>>> Modified: lldb/trunk/test/dosep.py
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=237602&r1=237601&r2=237602&view=diff
>>>
>>> ==
>>> --- lldb/trunk/test/dosep.py (original)
>>> +++ lldb/trunk/test/dosep.py Mon May 18 14:40:54 2015
>>> @@ -25,6 +25,7 @@ import multiprocessing
>>>  import os
>>>  import platform
>>>  import re
>>> +import dotest_args
>>>  import shlex
>>>  import subprocess
>>>  import sys
>>> @@ -152,16 +153,16 @@ def walk_and_invoke(test_directory, test
>>>
>>>  return (timed_out, failed, passed)
>>>
>>> -def getExpectedTimeouts(dotest_options):
>>> +def getExpectedTimeouts(platform_name):
>>>  # returns a set of test filenames that might timeout
>>>  # are we running against a remote target?
>>> -m = re.search('\sremote-(\w+)', dotest_options)
>>> -if m:
>>> -target = m.group(1)
>>> -remote = True
>>> -else:
>>> +if platform_name is None:
>>>  target = sys.platform
>>>  remote = False
>>> +else:
>>> +m = re.search('remote-(\w+)', platform_name)
>>> +target = m.group(1)
>>> +remote = True
>>>
>>>  expected_timeout = set()
>>>
>>> @@ -225,7 +226,10 @@ Run lldb test suite using a separate pro
>>>help="""The number of threads to use when running
>>> tests separately.""")
>>>
>>>  opts, args = parser.parse_args()
>>> -dotest_options = opts.dotest_options
>>> +dotest_option_string = opts.dotest_options
>>> +
>>> +dotest_argv = shlex.split(dotest_option_string)
>>> +dotest_options = dotest_args.getArguments(dotest_argv)
>>>
>>>  # The root directory was specified on the command line
>>>  if len(args) == 0:
>>> @@ -245,13 +249,13 @@ Run lldb test suite using a separate pro
>>>  num_threads = 1
>>>
>>>  system_info = " ".join(platform.uname())
>>> -(timed_out, failed, passed) = walk_and_invoke(test_directory,
>>> test_subdir, dotest_options,
>>> +(timed_out, failed, passed) = walk_and_invoke(test_directory,
>>> test_subdir, dotest_option_string,
>>>num_threads)
>>>  timed_out = set(timed_out)
>>>  num_tests = len(failed) + len(passed)
>>>
>>>  # remove expected timeouts from failures
>>> -expected_timeout = getExpectedTimeouts(dotest_options)
>>> +expected_timeout =
>>> getExpectedTimeouts(dotest_options.lldb_platform_name)
>>>  for xtime in expected_timeout:
>>>  if xtime in timed_out:
>>>  timed_out.remove(xtime)
>>>
>>> Modified: lldb/trunk/test/dotest.py
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=237602&r1=237601&r2=237602&view=diff
>>>
>>> ==
>>> --- lldb/trunk/test/dotest.py (original)
>>> +++ lldb/trunk/test/dotest.py Mon May 18 14:40:54 2015
>>> @@ -22,6 +22,7 @@ for available options.
>>>
>>>  import commands
>>>  import os
>>> +import dotest_args
>>>  import errno
>>>  import platform
>>>  import progress
>>> @@ -34,26 +35,6 @@ import inspect
>>>  import unittest2
>>>  import lldbtest_config
>>>
>>> -if sys.version_info >= (2, 7):
>>> -argparse = __import__('argparse')
>>> -else:
>>> -argparse = __import__('argparse_compat')
>>> -
>>> -def parse_args(parser):
>>> -""" Returns an argument object. LLDB_TEST_ARGUMENTS environment
>>> variable can
>>> -be used to pass additional arguments if a compatible (>=2.7)
>>> argparse
>>> -library is available.
>>> -"""
>>> -if sys.version_info >= (2, 7):
>>> -args = ArgParseNamespace()
>>> -
>>> -if ('LLDB_TEST_ARGUMENTS' in os.environ):
>>> -print "Arguments passed through environment: '%s'" %
>>> os.environ['LLDB_TEST_ARGUMENTS']
>>> -args =
>>> parser.parse_args([sys.argv[0]].__add__(os.environ['LLDB_TEST_ARGUMENTS'].split()),namespace=args)
>>> -
>>> -return parser.par

Re: [Lldb-commits] [lldb] r237602 - Refactored dotest arg parser so that it's accessible from dosep

2015-05-21 Thread Vince Harron
Yeah, on it.

On Thu, May 21, 2015 at 4:03 PM, Zachary Turner  wrote:

> This breaks dotest.py --help, and many other command line options.
>
> Would you mind fixing this?  I took a stab at it but it turns out to be a
> little more involved than I have time for.
>
> On Mon, May 18, 2015 at 12:45 PM Vince Harron  wrote:
>
>> Author: vharron
>> Date: Mon May 18 14:40:54 2015
>> New Revision: 237602
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=237602&view=rev
>> Log:
>> Refactored dotest arg parser so that it's accessible from dosep
>>
>> This allows dosep to understand an act on dotest arguments
>>
>> Differential Revision: http://reviews.llvm.org/D9820
>>
>>
>> Added:
>> lldb/trunk/test/dotest_args.py
>> Modified:
>> lldb/trunk/test/dosep.py
>> lldb/trunk/test/dotest.py
>>
>> Modified: lldb/trunk/test/dosep.py
>> URL:
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=237602&r1=237601&r2=237602&view=diff
>>
>> ==
>> --- lldb/trunk/test/dosep.py (original)
>> +++ lldb/trunk/test/dosep.py Mon May 18 14:40:54 2015
>> @@ -25,6 +25,7 @@ import multiprocessing
>>  import os
>>  import platform
>>  import re
>> +import dotest_args
>>  import shlex
>>  import subprocess
>>  import sys
>> @@ -152,16 +153,16 @@ def walk_and_invoke(test_directory, test
>>
>>  return (timed_out, failed, passed)
>>
>> -def getExpectedTimeouts(dotest_options):
>> +def getExpectedTimeouts(platform_name):
>>  # returns a set of test filenames that might timeout
>>  # are we running against a remote target?
>> -m = re.search('\sremote-(\w+)', dotest_options)
>> -if m:
>> -target = m.group(1)
>> -remote = True
>> -else:
>> +if platform_name is None:
>>  target = sys.platform
>>  remote = False
>> +else:
>> +m = re.search('remote-(\w+)', platform_name)
>> +target = m.group(1)
>> +remote = True
>>
>>  expected_timeout = set()
>>
>> @@ -225,7 +226,10 @@ Run lldb test suite using a separate pro
>>help="""The number of threads to use when running
>> tests separately.""")
>>
>>  opts, args = parser.parse_args()
>> -dotest_options = opts.dotest_options
>> +dotest_option_string = opts.dotest_options
>> +
>> +dotest_argv = shlex.split(dotest_option_string)
>> +dotest_options = dotest_args.getArguments(dotest_argv)
>>
>>  # The root directory was specified on the command line
>>  if len(args) == 0:
>> @@ -245,13 +249,13 @@ Run lldb test suite using a separate pro
>>  num_threads = 1
>>
>>  system_info = " ".join(platform.uname())
>> -(timed_out, failed, passed) = walk_and_invoke(test_directory,
>> test_subdir, dotest_options,
>> +(timed_out, failed, passed) = walk_and_invoke(test_directory,
>> test_subdir, dotest_option_string,
>>num_threads)
>>  timed_out = set(timed_out)
>>  num_tests = len(failed) + len(passed)
>>
>>  # remove expected timeouts from failures
>> -expected_timeout = getExpectedTimeouts(dotest_options)
>> +expected_timeout =
>> getExpectedTimeouts(dotest_options.lldb_platform_name)
>>  for xtime in expected_timeout:
>>  if xtime in timed_out:
>>  timed_out.remove(xtime)
>>
>> Modified: lldb/trunk/test/dotest.py
>> URL:
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=237602&r1=237601&r2=237602&view=diff
>>
>> ==
>> --- lldb/trunk/test/dotest.py (original)
>> +++ lldb/trunk/test/dotest.py Mon May 18 14:40:54 2015
>> @@ -22,6 +22,7 @@ for available options.
>>
>>  import commands
>>  import os
>> +import dotest_args
>>  import errno
>>  import platform
>>  import progress
>> @@ -34,26 +35,6 @@ import inspect
>>  import unittest2
>>  import lldbtest_config
>>
>> -if sys.version_info >= (2, 7):
>> -argparse = __import__('argparse')
>> -else:
>> -argparse = __import__('argparse_compat')
>> -
>> -def parse_args(parser):
>> -""" Returns an argument object. LLDB_TEST_ARGUMENTS environment
>> variable can
>> -be used to pass additional arguments if a compatible (>=2.7)
>> argparse
>> -library is available.
>> -"""
>> -if sys.version_info >= (2, 7):
>> -args = ArgParseNamespace()
>> -
>> -if ('LLDB_TEST_ARGUMENTS' in os.environ):
>> -print "Arguments passed through environment: '%s'" %
>> os.environ['LLDB_TEST_ARGUMENTS']
>> -args =
>> parser.parse_args([sys.argv[0]].__add__(os.environ['LLDB_TEST_ARGUMENTS'].split()),namespace=args)
>> -
>> -return parser.parse_args(namespace=args)
>> -else:
>> -return parser.parse_args()
>>
>>  def is_exe(fpath):
>>  """Returns true if fpath is an executable."""
>> @@ -388,9 +369,6 @@ def unique_string_match(yourentry,list):
>> ca

[Lldb-commits] [lldb] r237602 - Refactored dotest arg parser so that it's accessible from dosep

2015-05-18 Thread Vince Harron
Author: vharron
Date: Mon May 18 14:40:54 2015
New Revision: 237602

URL: http://llvm.org/viewvc/llvm-project?rev=237602&view=rev
Log:
Refactored dotest arg parser so that it's accessible from dosep

This allows dosep to understand an act on dotest arguments

Differential Revision: http://reviews.llvm.org/D9820


Added:
lldb/trunk/test/dotest_args.py
Modified:
lldb/trunk/test/dosep.py
lldb/trunk/test/dotest.py

Modified: lldb/trunk/test/dosep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=237602&r1=237601&r2=237602&view=diff
==
--- lldb/trunk/test/dosep.py (original)
+++ lldb/trunk/test/dosep.py Mon May 18 14:40:54 2015
@@ -25,6 +25,7 @@ import multiprocessing
 import os
 import platform
 import re
+import dotest_args
 import shlex
 import subprocess
 import sys
@@ -152,16 +153,16 @@ def walk_and_invoke(test_directory, test
 
 return (timed_out, failed, passed)
 
-def getExpectedTimeouts(dotest_options):
+def getExpectedTimeouts(platform_name):
 # returns a set of test filenames that might timeout
 # are we running against a remote target?
-m = re.search('\sremote-(\w+)', dotest_options)
-if m:
-target = m.group(1)
-remote = True
-else:
+if platform_name is None:
 target = sys.platform
 remote = False
+else:
+m = re.search('remote-(\w+)', platform_name)
+target = m.group(1)
+remote = True
 
 expected_timeout = set()
 
@@ -225,7 +226,10 @@ Run lldb test suite using a separate pro
   help="""The number of threads to use when running tests 
separately.""")
 
 opts, args = parser.parse_args()
-dotest_options = opts.dotest_options
+dotest_option_string = opts.dotest_options
+
+dotest_argv = shlex.split(dotest_option_string)
+dotest_options = dotest_args.getArguments(dotest_argv)
 
 # The root directory was specified on the command line
 if len(args) == 0:
@@ -245,13 +249,13 @@ Run lldb test suite using a separate pro
 num_threads = 1
 
 system_info = " ".join(platform.uname())
-(timed_out, failed, passed) = walk_and_invoke(test_directory, test_subdir, 
dotest_options,
+(timed_out, failed, passed) = walk_and_invoke(test_directory, test_subdir, 
dotest_option_string,
   num_threads)
 timed_out = set(timed_out)
 num_tests = len(failed) + len(passed)
 
 # remove expected timeouts from failures
-expected_timeout = getExpectedTimeouts(dotest_options)
+expected_timeout = getExpectedTimeouts(dotest_options.lldb_platform_name)
 for xtime in expected_timeout:
 if xtime in timed_out:
 timed_out.remove(xtime)

Modified: lldb/trunk/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=237602&r1=237601&r2=237602&view=diff
==
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon May 18 14:40:54 2015
@@ -22,6 +22,7 @@ for available options.
 
 import commands
 import os
+import dotest_args
 import errno
 import platform
 import progress
@@ -34,26 +35,6 @@ import inspect
 import unittest2
 import lldbtest_config
 
-if sys.version_info >= (2, 7):
-argparse = __import__('argparse')
-else:
-argparse = __import__('argparse_compat')
-
-def parse_args(parser):
-""" Returns an argument object. LLDB_TEST_ARGUMENTS environment variable 
can
-be used to pass additional arguments if a compatible (>=2.7) argparse
-library is available.
-"""
-if sys.version_info >= (2, 7):
-args = ArgParseNamespace()
-
-if ('LLDB_TEST_ARGUMENTS' in os.environ):
-print "Arguments passed through environment: '%s'" % 
os.environ['LLDB_TEST_ARGUMENTS']
-args = 
parser.parse_args([sys.argv[0]].__add__(os.environ['LLDB_TEST_ARGUMENTS'].split()),namespace=args)
-
-return parser.parse_args(namespace=args)
-else:
-return parser.parse_args()
 
 def is_exe(fpath):
 """Returns true if fpath is an executable."""
@@ -388,9 +369,6 @@ def unique_string_match(yourentry,list):
candidate = item
return candidate
 
-class ArgParseNamespace(object):
-pass
-
 def validate_categories(categories):
 """For each category in categories, ensure that it's a valid category (or 
a prefix thereof).
If a category is invalid, print a message and quit.
@@ -513,93 +491,7 @@ def parseOptionsAndInitTestdirs():
 platform_system = platform.system()
 platform_machine = platform.machine()
 
-parser = argparse.ArgumentParser(description='description', 
prefix_chars='+-', add_help=False)
-group = None
-
-# Helper function for boolean options (group will point to the current 
group when executing X)
-X = lambda optstr, helpstr, **kwargs: group.ad