[Lldb-commits] [lldb] r339929 - [dotest] Make --test-subdir work with --no-multiprocess

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 16 12:56:38 PDT 2018


Author: vedantk
Date: Thu Aug 16 12:56:38 2018
New Revision: 339929

URL: http://llvm.org/viewvc/llvm-project?rev=339929&view=rev
Log:
[dotest] Make --test-subdir work with --no-multiprocess

The single-process test runner is invoked in a number of different
scenarios, including when multiple test dirs are specified or (afaict)
when lit is used to drive the test suite.

Unfortunately the --test-subdir option did not work with the single
process test runner, breaking an important use case (using lit to run
swift-lldb Linux tests):

  Failure URL: https://ci.swift.org/job/swift-PR-Linux/6841

We won't be able to run lldb tests within swift PR testing without
filtering down the set of tests.

This change makes --test-subdir work with the single-process runner.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/configuration.py
    lldb/trunk/packages/Python/lldbsuite/test/dosep.py
    lldb/trunk/packages/Python/lldbsuite/test/dotest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/configuration.py?rev=339929&r1=339928&r2=339929&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py Thu Aug 16 12:56:38 2018
@@ -110,9 +110,13 @@ lldb_platform_working_dir = None
 # The base directory in which the tests are being built.
 test_build_dir = None
 
+# The only directory to scan for tests. If multiple test directories are
+# specified, and an exclusive test subdirectory is specified, the latter option
+# takes precedence.
+exclusive_test_subdir = None
+
 # Parallel execution settings
 is_inferior_test_runner = False
-multiprocess_test_subdir = None
 num_threads = None
 no_multiprocess_test_runner = False
 test_runner_name = None
@@ -144,3 +148,34 @@ def shouldSkipBecauseOfCategories(test_c
             return True
 
     return False
+
+
+def get_absolute_path_to_exclusive_test_subdir():
+    """
+    If an exclusive test subdirectory is specified, return its absolute path.
+    Otherwise return None.
+    """
+    test_directory = os.path.dirname(os.path.realpath(__file__))
+
+    if not exclusive_test_subdir:
+        return
+
+    if len(exclusive_test_subdir) > 0:
+        test_subdir = os.path.join(test_directory, exclusive_test_subdir)
+        if os.path.isdir(test_subdir):
+            return test_subdir
+
+        print('specified test subdirectory {} is not a valid directory\n'
+                .format(test_subdir))
+
+
+def get_absolute_path_to_root_test_dir():
+    """
+    If an exclusive test subdirectory is specified, return its absolute path.
+    Otherwise, return the absolute path of the root test directory.
+    """
+    test_subdir = get_absolute_path_to_exclusive_test_subdir()
+    if test_subdir:
+        return test_subdir
+
+    return os.path.dirname(os.path.realpath(__file__))

Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dosep.py?rev=339929&r1=339928&r2=339929&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dosep.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py Thu Aug 16 12:56:38 2018
@@ -1558,7 +1558,7 @@ def rerun_tests(test_subdir, tests_for_r
     print("\nTest rerun complete\n")
 
 
-def main(num_threads, test_subdir, test_runner_name, results_formatter):
+def main(num_threads, test_runner_name, results_formatter):
     """Run dotest.py in inferior mode in parallel.
 
     @param num_threads the parsed value of the num-threads command line
@@ -1600,16 +1600,7 @@ def main(num_threads, test_subdir, test_
 
     session_dir = os.path.join(os.getcwd(), dotest_options.s)
 
-    # The root directory was specified on the command line
-    test_directory = os.path.dirname(os.path.realpath(__file__))
-    if test_subdir and len(test_subdir) > 0:
-        test_subdir = os.path.join(test_directory, test_subdir)
-        if not os.path.isdir(test_subdir):
-            print(
-                'specified test subdirectory {} is not a valid directory\n'
-                .format(test_subdir))
-    else:
-        test_subdir = test_directory
+    test_subdir = configuration.get_absolute_path_to_root_test_dir()
 
     # clean core files in test tree from previous runs (Linux)
     cores = find('core.*', test_subdir)

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=339929&r1=339928&r2=339929&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Aug 16 12:56:38 2018
@@ -439,7 +439,7 @@ def parseOptionsAndInitTestdirs():
         configuration.num_threads = args.num_threads
 
     if args.test_subdir:
-        configuration.multiprocess_test_subdir = args.test_subdir
+        configuration.exclusive_test_subdir = args.test_subdir
 
     if args.test_runner_name:
         configuration.test_runner_name = args.test_runner_name
@@ -895,6 +895,7 @@ def visit_file(dir, name):
             unittest2.defaultTestLoader.loadTestsFromName(base))
 
 
+# TODO: This should be replaced with a call to find_test_files_in_dir_tree.
 def visit(prefix, dir, names):
     """Visitor function for os.path.walk(path, visit, arg)."""
 
@@ -1172,7 +1173,6 @@ def run_suite():
         from . import dosep
         dosep.main(
             configuration.num_threads,
-            configuration.multiprocess_test_subdir,
             configuration.test_runner_name,
             configuration.results_formatter_object)
         raise Exception("should never get here")
@@ -1267,10 +1267,15 @@ def run_suite():
     # Don't do lldb-server (llgs) tests on anything except Linux.
     configuration.dont_do_llgs_test = not ("linux" in target_platform)
 
-    #
-    # Walk through the testdirs while collecting tests.
-    #
-    for testdir in configuration.testdirs:
+    # Collect tests from the specified testing directories. If a test
+    # subdirectory filter is explicitly specified, limit the search to that
+    # subdirectory.
+    exclusive_test_subdir = configuration.get_absolute_path_to_exclusive_test_subdir()
+    if exclusive_test_subdir:
+        dirs_to_search = [exclusive_test_subdir]
+    else:
+        dirs_to_search = configuration.testdirs
+    for testdir in dirs_to_search:
         for (dirpath, dirnames, filenames) in os.walk(testdir):
             visit('Test', dirpath, filenames)
 




More information about the lldb-commits mailing list