Skip to content

Commit a90a4d0

Browse files
committed
[test] Modify run-test to allow unified LLVM builds
The unified LLVM builds use a slightly different structure than the Swift standalone builds. Modify the run-test utility tool to allow using it in both standalone and unified builds.
1 parent 25949c2 commit a90a4d0

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

utils/run-test

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,14 @@ def error_exit(msg):
5858

5959

6060
# Return true if the path looks like swift build directory.
61-
def is_swift_build_dir(path):
61+
def is_swift_build_dir(path, unified_build_dir):
62+
if not unified_build_dir:
63+
tests_path = [path, "test-%s" % host_target]
64+
else:
65+
tests_path = [path, "tools", "swift", "test-%s" % host_target]
66+
6267
return (os.path.exists(os.path.join(path, "CMakeCache.txt")) and
63-
os.path.isdir(os.path.join(path, "test-%s" % host_target)))
68+
os.path.isdir(os.path.join(*tests_path)))
6469

6570

6671
# Return true if the swift build directory is configured with `Xcode`
@@ -81,14 +86,19 @@ def is_subpath(path, d):
8186
# Convert test path in source directory to corresponding path in build
8287
# directory. If the path is not sub path of test directories in source,
8388
# return the path as is.
84-
def normalize_test_path(path, build_dir, variant):
89+
def normalize_test_path(path, build_dir, variant, unified_build_dir):
90+
if not unified_build_dir:
91+
tests_path = [build_dir]
92+
else:
93+
tests_path = [build_dir, "tools", "swift"]
94+
8595
for d, prefix in [(TEST_SOURCE_DIR, 'test-%s'),
8696
(VALIDATION_TEST_SOURCE_DIR, 'validation-test-%s')]:
8797
if is_subpath(path, d):
88-
return os.path.normpath(os.path.join(
89-
build_dir,
90-
prefix % variant,
91-
os.path.relpath(path, d)))
98+
return os.path.normpath(os.path.join(*(
99+
tests_path +
100+
[prefix % variant,
101+
os.path.relpath(path, d)])))
92102
return path
93103

94104

@@ -133,6 +143,9 @@ def main():
133143
parser.add_argument("--lit", default=LIT_BIN_DEFAULT, metavar="PATH",
134144
help="lit.py executable path "
135145
"(default: ${LLVM_SOURCE_DIR}/utils/lit/lit.py)")
146+
parser.add_argument("--unified", action="store_true",
147+
help="The build directory is an unified LLVM build, "
148+
"not a standalone Swift build")
136149

137150
args = parser.parse_args()
138151

@@ -151,7 +164,7 @@ def main():
151164
for d in [
152165
build_dir,
153166
os.path.join(build_dir, 'swift-%s' % host_target)]:
154-
if is_swift_build_dir(d):
167+
if is_swift_build_dir(d, args.unified):
155168
build_dir = d
156169
break
157170
else:
@@ -164,9 +177,8 @@ def main():
164177
# $ run-test --build-dir=<swift-build-dir> <test-dir-in-source> ... \
165178
# --target macosx-x86_64 --target iphonesimulator-i386
166179
for target in targets:
167-
paths += map(
168-
lambda p: normalize_test_path(p, build_dir, target),
169-
args.paths)
180+
paths += [normalize_test_path(p, build_dir, target, args.unified)
181+
for p in args.paths]
170182

171183
else:
172184
# Otherwise, we assume all given paths are valid test paths in the
@@ -181,7 +193,7 @@ def main():
181193
# Traverse the first test path to find the `build_dir`
182194
d = os.path.dirname(paths[0])
183195
while d not in ['', os.sep]:
184-
if is_swift_build_dir(d):
196+
if is_swift_build_dir(d, args.unified):
185197
build_dir = d
186198
break
187199
d = os.path.dirname(d)

0 commit comments

Comments
 (0)