[Lldb-commits] [lldb] r115832 - /lldb/trunk/test/dotest.py
Johnny Chen
johnny.chen at apple.com
Wed Oct 6 13:40:56 PDT 2010
Author: johnny
Date: Wed Oct 6 15:40:56 2010
New Revision: 115832
URL: http://llvm.org/viewvc/llvm-project?rev=115832&view=rev
Log:
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.
Example:
# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
----------------------------------------------------------------------
Ran 1 test in 1.353s
OK
# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.
/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests
test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
----------------------------------------------------------------------
Ran 3 tests in 4.964s
OK
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=115832&r1=115831&r2=115832&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Wed Oct 6 15:40:56 2010
@@ -54,6 +54,12 @@
# Delay startup in order for the debugger to attach.
delay = False
+# The filter (testcase.testmethod) used to admit tests into our test suite.
+filterspec = None
+
+# If '-g' is specified, the filterspec must be consulted for each test module, default to False.
+fs4all = False
+
# Ignore the build search path relative to this script to locate the lldb.py module.
ignore = False
@@ -81,6 +87,12 @@
-c : read a config file specified after this option
(see also lldb-trunk/example/test/usage-config)
-d : delay startup for 10 seconds (in order for the debugger to attach)
+-f : specify a filter to admit tests into the test suite
+ e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api'
+-g : if specified, only the modules with the corect filter will be run
+ it has no effect if no '-f' option is present
+ '-f filterspec -g' can be used with '-p filename-regexp' to select only
+ the testfile.testclass.testmethod to run
-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build
tree relative to this script; use PYTHONPATH to locate the module
-l : don't skip long running test
@@ -117,6 +129,8 @@
global configFile
global delay
+ global filterspec
+ global fs4all
global ignore
global skipLongRunningTest
global regexp
@@ -148,6 +162,16 @@
elif sys.argv[index].startswith('-d'):
delay = True
index += 1
+ elif sys.argv[index].startswith('-f'):
+ # Increment by 1 to fetch the filter spec.
+ index += 1
+ if index >= len(sys.argv) or sys.argv[index].startswith('-'):
+ usage()
+ filterspec = sys.argv[index]
+ index += 1
+ elif sys.argv[index].startswith('-g'):
+ fs4all = True
+ index += 1
elif sys.argv[index].startswith('-i'):
ignore = True
index += 1
@@ -267,6 +291,8 @@
global suite
global regexp
+ global filterspec
+ global fs4all
for name in names:
if os.path.isdir(os.path.join(dir, name)):
@@ -287,7 +313,35 @@
if not sys.path.count(dir):
sys.path.append(dir)
base = os.path.splitext(name)[0]
- suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
+
+ # Thoroughly check the filterspec against the base module and admit
+ # the (base, filterspec) combination only when it makes sense.
+ if filterspec:
+ # Optimistically set the flag to True.
+ filtered = True
+ module = __import__(base)
+ parts = filterspec.split('.')
+ obj = module
+ for part in parts:
+ try:
+ parent, obj = obj, getattr(obj, part)
+ except AttributeError:
+ # The filterspec has failed.
+ filtered = False
+ break
+ # Forgo this module if the (base, filterspec) combo is invalid
+ # and the '-g' option is present.
+ if fs4all and not filtered:
+ continue
+
+ if filterspec and filtered:
+ suite.addTests(
+ unittest2.defaultTestLoader.loadTestsFromName(filterspec, module))
+ else:
+ # A simple case of just the module name. Also the failover case
+ # from the filterspec branch when the (base, filterspec) combo
+ # doesn't make sense.
+ suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
def lldbLoggings():
More information about the lldb-commits
mailing list