Skip to content

Commit 33ed57e

Browse files
committedAug 16, 2018
[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. llvm-svn: 339929
1 parent 998373c commit 33ed57e

File tree

3 files changed

+49
-18
lines changed

3 files changed

+49
-18
lines changed
 

‎lldb/packages/Python/lldbsuite/test/configuration.py

+36-1
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@
110110
# The base directory in which the tests are being built.
111111
test_build_dir = None
112112

113+
# The only directory to scan for tests. If multiple test directories are
114+
# specified, and an exclusive test subdirectory is specified, the latter option
115+
# takes precedence.
116+
exclusive_test_subdir = None
117+
113118
# Parallel execution settings
114119
is_inferior_test_runner = False
115-
multiprocess_test_subdir = None
116120
num_threads = None
117121
no_multiprocess_test_runner = False
118122
test_runner_name = None
@@ -144,3 +148,34 @@ def shouldSkipBecauseOfCategories(test_categories):
144148
return True
145149

146150
return False
151+
152+
153+
def get_absolute_path_to_exclusive_test_subdir():
154+
"""
155+
If an exclusive test subdirectory is specified, return its absolute path.
156+
Otherwise return None.
157+
"""
158+
test_directory = os.path.dirname(os.path.realpath(__file__))
159+
160+
if not exclusive_test_subdir:
161+
return
162+
163+
if len(exclusive_test_subdir) > 0:
164+
test_subdir = os.path.join(test_directory, exclusive_test_subdir)
165+
if os.path.isdir(test_subdir):
166+
return test_subdir
167+
168+
print('specified test subdirectory {} is not a valid directory\n'
169+
.format(test_subdir))
170+
171+
172+
def get_absolute_path_to_root_test_dir():
173+
"""
174+
If an exclusive test subdirectory is specified, return its absolute path.
175+
Otherwise, return the absolute path of the root test directory.
176+
"""
177+
test_subdir = get_absolute_path_to_exclusive_test_subdir()
178+
if test_subdir:
179+
return test_subdir
180+
181+
return os.path.dirname(os.path.realpath(__file__))

‎lldb/packages/Python/lldbsuite/test/dosep.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ def rerun_tests(test_subdir, tests_for_rerun, dotest_argv, session_dir,
15581558
print("\nTest rerun complete\n")
15591559

15601560

1561-
def main(num_threads, test_subdir, test_runner_name, results_formatter):
1561+
def main(num_threads, test_runner_name, results_formatter):
15621562
"""Run dotest.py in inferior mode in parallel.
15631563
15641564
@param num_threads the parsed value of the num-threads command line
@@ -1600,16 +1600,7 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter):
16001600

16011601
session_dir = os.path.join(os.getcwd(), dotest_options.s)
16021602

1603-
# The root directory was specified on the command line
1604-
test_directory = os.path.dirname(os.path.realpath(__file__))
1605-
if test_subdir and len(test_subdir) > 0:
1606-
test_subdir = os.path.join(test_directory, test_subdir)
1607-
if not os.path.isdir(test_subdir):
1608-
print(
1609-
'specified test subdirectory {} is not a valid directory\n'
1610-
.format(test_subdir))
1611-
else:
1612-
test_subdir = test_directory
1603+
test_subdir = configuration.get_absolute_path_to_root_test_dir()
16131604

16141605
# clean core files in test tree from previous runs (Linux)
16151606
cores = find('core.*', test_subdir)

‎lldb/packages/Python/lldbsuite/test/dotest.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def parseOptionsAndInitTestdirs():
439439
configuration.num_threads = args.num_threads
440440

441441
if args.test_subdir:
442-
configuration.multiprocess_test_subdir = args.test_subdir
442+
configuration.exclusive_test_subdir = args.test_subdir
443443

444444
if args.test_runner_name:
445445
configuration.test_runner_name = args.test_runner_name
@@ -895,6 +895,7 @@ def visit_file(dir, name):
895895
unittest2.defaultTestLoader.loadTestsFromName(base))
896896

897897

898+
# TODO: This should be replaced with a call to find_test_files_in_dir_tree.
898899
def visit(prefix, dir, names):
899900
"""Visitor function for os.path.walk(path, visit, arg)."""
900901

@@ -1172,7 +1173,6 @@ def run_suite():
11721173
from . import dosep
11731174
dosep.main(
11741175
configuration.num_threads,
1175-
configuration.multiprocess_test_subdir,
11761176
configuration.test_runner_name,
11771177
configuration.results_formatter_object)
11781178
raise Exception("should never get here")
@@ -1267,10 +1267,15 @@ def run_suite():
12671267
# Don't do lldb-server (llgs) tests on anything except Linux.
12681268
configuration.dont_do_llgs_test = not ("linux" in target_platform)
12691269

1270-
#
1271-
# Walk through the testdirs while collecting tests.
1272-
#
1273-
for testdir in configuration.testdirs:
1270+
# Collect tests from the specified testing directories. If a test
1271+
# subdirectory filter is explicitly specified, limit the search to that
1272+
# subdirectory.
1273+
exclusive_test_subdir = configuration.get_absolute_path_to_exclusive_test_subdir()
1274+
if exclusive_test_subdir:
1275+
dirs_to_search = [exclusive_test_subdir]
1276+
else:
1277+
dirs_to_search = configuration.testdirs
1278+
for testdir in dirs_to_search:
12741279
for (dirpath, dirnames, filenames) in os.walk(testdir):
12751280
visit('Test', dirpath, filenames)
12761281

0 commit comments

Comments
 (0)
Please sign in to comment.