@@ -58,9 +58,14 @@ def error_exit(msg):
58
58
59
59
60
60
# 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
+
62
67
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 )))
64
69
65
70
66
71
# Return true if the swift build directory is configured with `Xcode`
@@ -81,14 +86,19 @@ def is_subpath(path, d):
81
86
# Convert test path in source directory to corresponding path in build
82
87
# directory. If the path is not sub path of test directories in source,
83
88
# 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
+
85
95
for d , prefix in [(TEST_SOURCE_DIR , 'test-%s' ),
86
96
(VALIDATION_TEST_SOURCE_DIR , 'validation-test-%s' )]:
87
97
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 )] )))
92
102
return path
93
103
94
104
@@ -133,6 +143,9 @@ def main():
133
143
parser .add_argument ("--lit" , default = LIT_BIN_DEFAULT , metavar = "PATH" ,
134
144
help = "lit.py executable path "
135
145
"(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" )
136
149
137
150
args = parser .parse_args ()
138
151
@@ -151,7 +164,7 @@ def main():
151
164
for d in [
152
165
build_dir ,
153
166
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 ):
155
168
build_dir = d
156
169
break
157
170
else :
@@ -164,9 +177,8 @@ def main():
164
177
# $ run-test --build-dir=<swift-build-dir> <test-dir-in-source> ... \
165
178
# --target macosx-x86_64 --target iphonesimulator-i386
166
179
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 ]
170
182
171
183
else :
172
184
# Otherwise, we assume all given paths are valid test paths in the
@@ -181,7 +193,7 @@ def main():
181
193
# Traverse the first test path to find the `build_dir`
182
194
d = os .path .dirname (paths [0 ])
183
195
while d not in ['' , os .sep ]:
184
- if is_swift_build_dir (d ):
196
+ if is_swift_build_dir (d , args . unified ):
185
197
build_dir = d
186
198
break
187
199
d = os .path .dirname (d )
0 commit comments