Skip to content

Commit d92eea9

Browse files
committed
[build_script] Use built XCTest for Linux tests
Previously, tests on Linux could only be run using the installed swift-corelibs-xctest. Modify the script to use the built XCTest instead of the installed one. In addition, since the script no longer relies on the installed XCTest, move the `--test` logic such that it can be used even if `--module-install-path` and `--library-install-path` are not specified.
1 parent 73ff15a commit d92eea9

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

Tests/Functional/lit.cfg

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ def _getenv(name):
2828
'run.'.format(name))
2929
return value
3030

31-
swift_exec = [_getenv('SWIFT_EXEC')]
31+
built_products_dir = _getenv('BUILT_PRODUCTS_DIR')
32+
swift_exec = [
33+
_getenv('SWIFT_EXEC'),
34+
'-Xlinker', '-rpath',
35+
'-Xlinker', built_products_dir,
36+
'-L', built_products_dir,
37+
'-I', built_products_dir,
38+
]
3239

3340
if platform.system() == 'Darwin':
3441
# On OS X, we need to make sure swiftc references the
3542
# proper SDK, has a deployment target set, and more...
3643
# Here we rely on environment variables, produced by xcodebuild.
3744
sdk_root = _getenv('SDKROOT')
38-
built_products_dir = _getenv('BUILT_PRODUCTS_DIR')
3945
platform_name = _getenv('PLATFORM_NAME')
4046
deployment_target = _getenv('MACOSX_DEPLOYMENT_TARGET')
4147

@@ -44,11 +50,8 @@ if platform.system() == 'Darwin':
4450
swift_exec.extend([
4551
'-sdk', sdk_root,
4652
'-target', target,
47-
'-L', built_products_dir,
48-
'-I', built_products_dir,
4953
'-F', built_products_dir,
50-
'-Xlinker', '-rpath',
51-
'-Xlinker', built_products_dir])
54+
])
5255

5356
# Having prepared the swiftc command, we set the substitution.
5457
config.substitutions.append(('%{swiftc}', ' '.join(swift_exec)))

build_script.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,19 @@ def main():
136136
cmd = ['cp', os.path.join(build_dir, install_mod_doc), os.path.join(module_path, install_mod_doc)]
137137
subprocess.check_call(cmd)
138138

139-
if args.test:
140-
lit_path = os.path.join(
141-
os.path.dirname(SOURCE_DIR), 'llvm', 'utils', 'lit', 'lit.py')
142-
lit_flags = '-sv --no-progress-bar'
143-
tests_path = os.path.join(SOURCE_DIR, 'Tests', 'Functional')
144-
run('SWIFT_EXEC={swiftc} {lit_path} {lit_flags} '
145-
'{tests_path}'.format(swiftc=swiftc,
146-
lit_path=lit_path,
147-
lit_flags=lit_flags,
148-
tests_path=tests_path))
139+
if args.test:
140+
lit_path = os.path.join(
141+
os.path.dirname(SOURCE_DIR), 'llvm', 'utils', 'lit', 'lit.py')
142+
lit_flags = '-sv --no-progress-bar'
143+
tests_path = os.path.join(SOURCE_DIR, 'Tests', 'Functional')
144+
run('SWIFT_EXEC={swiftc} '
145+
'BUILT_PRODUCTS_DIR={built_products_dir} '
146+
'{lit_path} {lit_flags} '
147+
'{tests_path}'.format(swiftc=swiftc,
148+
built_products_dir=build_dir,
149+
lit_path=lit_path,
150+
lit_flags=lit_flags,
151+
tests_path=tests_path))
149152

150153
note('Done.')
151154

0 commit comments

Comments
 (0)