Skip to content

[build_script] Use built XCTest for Linux tests #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ If your install of Swift is located at `/swift` and you wish to install XCTest i
./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"
```

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

```sh
./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" \
--test
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README should also be updated with the new build script invocation here!

@briancroom Is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks!

Expand Down
11 changes: 7 additions & 4 deletions Tests/Functional/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ def _getenv(name):
'run.'.format(name))
return value

swift_exec = [_getenv('SWIFT_EXEC')]
built_products_dir = _getenv('BUILT_PRODUCTS_DIR')
swift_exec = [
_getenv('SWIFT_EXEC'),
'-Xlinker', '-rpath',
'-Xlinker', built_products_dir,
]

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

Expand All @@ -47,8 +51,7 @@ if platform.system() == 'Darwin':
'-L', built_products_dir,
'-I', built_products_dir,
'-F', built_products_dir,
'-Xlinker', '-rpath',
'-Xlinker', built_products_dir])
])

# Having prepared the swiftc command, we set the substitution.
config.substitutions.append(('%{swiftc}', ' '.join(swift_exec)))
Expand Down
23 changes: 13 additions & 10 deletions build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,19 @@ def main():
cmd = ['cp', os.path.join(build_dir, install_mod_doc), os.path.join(module_path, install_mod_doc)]
subprocess.check_call(cmd)

if args.test:
lit_path = os.path.join(
os.path.dirname(SOURCE_DIR), 'llvm', 'utils', 'lit', 'lit.py')
lit_flags = '-sv --no-progress-bar'
tests_path = os.path.join(SOURCE_DIR, 'Tests', 'Functional')
run('SWIFT_EXEC={swiftc} {lit_path} {lit_flags} '
'{tests_path}'.format(swiftc=swiftc,
lit_path=lit_path,
lit_flags=lit_flags,
tests_path=tests_path))
if args.test:
lit_path = os.path.join(
os.path.dirname(SOURCE_DIR), 'llvm', 'utils', 'lit', 'lit.py')
lit_flags = '-sv --no-progress-bar'
tests_path = os.path.join(SOURCE_DIR, 'Tests', 'Functional')
run('SWIFT_EXEC={swiftc} '
'BUILT_PRODUCTS_DIR={built_products_dir} '
'{lit_path} {lit_flags} '
'{tests_path}'.format(swiftc=swiftc,
built_products_dir=build_dir,
lit_path=lit_path,
lit_flags=lit_flags,
tests_path=tests_path))

note('Done.')

Expand Down