# 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
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__))
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
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)
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
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)."""
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")
# 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)