Skip to content

Commit 383ea5b

Browse files
author
Mike Ferris
committed
Merge pull request #46 from modocache/linux-tests-use-built-product
[build_script] Use built XCTest for Linux tests
2 parents 3314ff2 + cd0f2d5 commit 383ea5b

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ If your install of Swift is located at `/swift` and you wish to install XCTest i
3838
./build_script.py --swiftc="/swift/usr/bin/swiftc" --build-dir="/tmp/XCTest_build" --swift-build-dir="/swift/usr" --library-install-path="/swift/usr/lib/swift/linux" --module-install-path="/swift/usr/lib/swift/linux/x86_64"
3939
```
4040

41-
To run the tests on Linux, pass the `--test` option in combination with options to
42-
install XCTest in your active version of Swift:
41+
To run the tests on Linux, use the `--test` option:
4342

4443
```sh
4544
./build_script.py \
4645
--swiftc="/swift/usr/bin/swiftc" \
4746
--build-dir="/tmp/XCTest_build" \
4847
--swift-build-dir="/swift/usr" \
49-
--library-install-path="/swift/usr/lib/swift/linux" \
50-
--module-install-path="/swift/usr/lib/swift/linux/x86_64" \
5148
--test
5249
```
5350

Tests/Functional/lit.cfg

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ 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+
]
3237

3338
if platform.system() == 'Darwin':
3439
# On OS X, we need to make sure swiftc references the
3540
# proper SDK, has a deployment target set, and more...
3641
# Here we rely on environment variables, produced by xcodebuild.
3742
sdk_root = _getenv('SDKROOT')
38-
built_products_dir = _getenv('BUILT_PRODUCTS_DIR')
3943
platform_name = _getenv('PLATFORM_NAME')
4044
deployment_target = _getenv('MACOSX_DEPLOYMENT_TARGET')
4145

@@ -47,8 +51,7 @@ if platform.system() == 'Darwin':
4751
'-L', built_products_dir,
4852
'-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)